File
Blob: spec/mocks/rpc.go
| 1 | //go:build !no_mocks |
| 2 | |
| 3 | package mocks |
| 4 | |
| 5 | import ( |
| 6 | "context" |
| 7 | "time" |
| 8 | |
| 9 | "go.miragespace.co/specter/spec/protocol" |
| 10 | "go.miragespace.co/specter/spec/rpc" |
| 11 | |
| 12 | "github.com/stretchr/testify/mock" |
| 13 | ) |
| 14 | |
| 15 | type ChordClient struct { |
| 16 | mock.Mock |
| 17 | } |
| 18 | |
| 19 | func (c *ChordClient) Identity(ctx context.Context, req *protocol.IdentityRequest) (*protocol.IdentityResponse, error) { |
| 20 | args := c.Called(ctx, req) |
| 21 | r := args.Get(0) |
| 22 | e := args.Error(1) |
| 23 | if e != nil { |
| 24 | return nil, e |
| 25 | } |
| 26 | return r.(*protocol.IdentityResponse), nil |
| 27 | } |
| 28 | |
| 29 | func (c *ChordClient) Ping(ctx context.Context, req *protocol.PingRequest) (*protocol.PingResponse, error) { |
| 30 | args := c.Called(ctx, req) |
| 31 | r := args.Get(0) |
| 32 | e := args.Error(1) |
| 33 | if e != nil { |
| 34 | return nil, e |
| 35 | } |
| 36 | return r.(*protocol.PingResponse), nil |
| 37 | } |
| 38 | |
| 39 | func (c *ChordClient) Notify(ctx context.Context, req *protocol.NotifyRequest) (*protocol.NotifyResponse, error) { |
| 40 | args := c.Called(ctx, req) |
| 41 | r := args.Get(0) |
| 42 | e := args.Error(1) |
| 43 | if e != nil { |
| 44 | return nil, e |
| 45 | } |
| 46 | return r.(*protocol.NotifyResponse), nil |
| 47 | } |
| 48 | |
| 49 | func (c *ChordClient) FindSuccessor(ctx context.Context, req *protocol.FindSuccessorRequest) (*protocol.FindSuccessorResponse, error) { |
| 50 | args := c.Called(ctx, req) |
| 51 | r := args.Get(0) |
| 52 | e := args.Error(1) |
| 53 | if e != nil { |
| 54 | return nil, e |
| 55 | } |
| 56 | return r.(*protocol.FindSuccessorResponse), nil |
| 57 | } |
| 58 | |
| 59 | func (c *ChordClient) GetSuccessors(ctx context.Context, req *protocol.GetSuccessorsRequest) (*protocol.GetSuccessorsResponse, error) { |
| 60 | args := c.Called(ctx, req) |
| 61 | r := args.Get(0) |
| 62 | e := args.Error(1) |
| 63 | if e != nil { |
| 64 | return nil, e |
| 65 | } |
| 66 | return r.(*protocol.GetSuccessorsResponse), nil |
| 67 | } |
| 68 | |
| 69 | func (c *ChordClient) GetPredecessor(ctx context.Context, req *protocol.GetPredecessorRequest) (*protocol.GetPredecessorResponse, error) { |
| 70 | args := c.Called(ctx, req) |
| 71 | r := args.Get(0) |
| 72 | e := args.Error(1) |
| 73 | if e != nil { |
| 74 | return nil, e |
| 75 | } |
| 76 | return r.(*protocol.GetPredecessorResponse), nil |
| 77 | } |
| 78 | |
| 79 | func (c *ChordClient) RequestToJoin(ctx context.Context, req *protocol.RequestToJoinRequest) (*protocol.RequestToJoinResponse, error) { |
| 80 | args := c.Called(ctx, req) |
| 81 | r := args.Get(0) |
| 82 | e := args.Error(1) |
| 83 | if e != nil { |
| 84 | return nil, e |
| 85 | } |
| 86 | return r.(*protocol.RequestToJoinResponse), nil |
| 87 | } |
| 88 | |
| 89 | func (c *ChordClient) FinishJoin(ctx context.Context, req *protocol.MembershipConclusionRequest) (*protocol.MembershipConclusionResponse, error) { |
| 90 | args := c.Called(ctx, req) |
| 91 | r := args.Get(0) |
| 92 | e := args.Error(1) |
| 93 | if e != nil { |
| 94 | return nil, e |
| 95 | } |
| 96 | return r.(*protocol.MembershipConclusionResponse), nil |
| 97 | } |
| 98 | |
| 99 | func (c *ChordClient) RequestToLeave(ctx context.Context, req *protocol.RequestToLeaveRequest) (*protocol.RequestToLeaveResponse, error) { |
| 100 | args := c.Called(ctx, req) |
| 101 | r := args.Get(0) |
| 102 | e := args.Error(1) |
| 103 | if e != nil { |
| 104 | return nil, e |
| 105 | } |
| 106 | return r.(*protocol.RequestToLeaveResponse), nil |
| 107 | } |
| 108 | |
| 109 | func (c *ChordClient) FinishLeave(ctx context.Context, req *protocol.MembershipConclusionRequest) (*protocol.MembershipConclusionResponse, error) { |
| 110 | args := c.Called(ctx, req) |
| 111 | r := args.Get(0) |
| 112 | e := args.Error(1) |
| 113 | if e != nil { |
| 114 | return nil, e |
| 115 | } |
| 116 | return r.(*protocol.MembershipConclusionResponse), nil |
| 117 | } |
| 118 | |
| 119 | func (c *ChordClient) Put(ctx context.Context, req *protocol.SimpleRequest) (*protocol.SimpleResponse, error) { |
| 120 | args := c.Called(ctx, req) |
| 121 | r := args.Get(0) |
| 122 | e := args.Error(1) |
| 123 | if e != nil { |
| 124 | return nil, e |
| 125 | } |
| 126 | return r.(*protocol.SimpleResponse), nil |
| 127 | } |
| 128 | |
| 129 | func (c *ChordClient) Get(ctx context.Context, req *protocol.SimpleRequest) (*protocol.SimpleResponse, error) { |
| 130 | args := c.Called(ctx, req) |
| 131 | r := args.Get(0) |
| 132 | e := args.Error(1) |
| 133 | if e != nil { |
| 134 | return nil, e |
| 135 | } |
| 136 | return r.(*protocol.SimpleResponse), nil |
| 137 | } |
| 138 | |
| 139 | func (c *ChordClient) Delete(ctx context.Context, req *protocol.SimpleRequest) (*protocol.SimpleResponse, error) { |
| 140 | args := c.Called(ctx, req) |
| 141 | r := args.Get(0) |
| 142 | e := args.Error(1) |
| 143 | if e != nil { |
| 144 | return nil, e |
| 145 | } |
| 146 | return r.(*protocol.SimpleResponse), nil |
| 147 | } |
| 148 | |
| 149 | func (c *ChordClient) Append(ctx context.Context, req *protocol.PrefixRequest) (*protocol.PrefixResponse, error) { |
| 150 | args := c.Called(ctx, req) |
| 151 | r := args.Get(0) |
| 152 | e := args.Error(1) |
| 153 | if e != nil { |
| 154 | return nil, e |
| 155 | } |
| 156 | return r.(*protocol.PrefixResponse), nil |
| 157 | } |
| 158 | |
| 159 | func (c *ChordClient) List(ctx context.Context, req *protocol.PrefixRequest) (*protocol.PrefixResponse, error) { |
| 160 | args := c.Called(ctx, req) |
| 161 | r := args.Get(0) |
| 162 | e := args.Error(1) |
| 163 | if e != nil { |
| 164 | return nil, e |
| 165 | } |
| 166 | return r.(*protocol.PrefixResponse), nil |
| 167 | } |
| 168 | |
| 169 | func (c *ChordClient) Contains(ctx context.Context, req *protocol.PrefixRequest) (*protocol.PrefixResponse, error) { |
| 170 | args := c.Called(ctx, req) |
| 171 | r := args.Get(0) |
| 172 | e := args.Error(1) |
| 173 | if e != nil { |
| 174 | return nil, e |
| 175 | } |
| 176 | return r.(*protocol.PrefixResponse), nil |
| 177 | } |
| 178 | |
| 179 | func (c *ChordClient) Remove(ctx context.Context, req *protocol.PrefixRequest) (*protocol.PrefixResponse, error) { |
| 180 | args := c.Called(ctx, req) |
| 181 | r := args.Get(0) |
| 182 | e := args.Error(1) |
| 183 | if e != nil { |
| 184 | return nil, e |
| 185 | } |
| 186 | return r.(*protocol.PrefixResponse), nil |
| 187 | } |
| 188 | |
| 189 | func (c *ChordClient) Acquire(ctx context.Context, req *protocol.LeaseRequest) (*protocol.LeaseResponse, error) { |
| 190 | args := c.Called(ctx, req) |
| 191 | r := args.Get(0) |
| 192 | e := args.Error(1) |
| 193 | if e != nil { |
| 194 | return nil, e |
| 195 | } |
| 196 | return r.(*protocol.LeaseResponse), nil |
| 197 | } |
| 198 | |
| 199 | func (c *ChordClient) Renew(ctx context.Context, req *protocol.LeaseRequest) (*protocol.LeaseResponse, error) { |
| 200 | args := c.Called(ctx, req) |
| 201 | r := args.Get(0) |
| 202 | e := args.Error(1) |
| 203 | if e != nil { |
| 204 | return nil, e |
| 205 | } |
| 206 | return r.(*protocol.LeaseResponse), nil |
| 207 | } |
| 208 | |
| 209 | func (c *ChordClient) Release(ctx context.Context, req *protocol.LeaseRequest) (*protocol.LeaseResponse, error) { |
| 210 | args := c.Called(ctx, req) |
| 211 | r := args.Get(0) |
| 212 | e := args.Error(1) |
| 213 | if e != nil { |
| 214 | return nil, e |
| 215 | } |
| 216 | return r.(*protocol.LeaseResponse), nil |
| 217 | } |
| 218 | |
| 219 | func (c *ChordClient) Import(_ context.Context, _ *protocol.ImportRequest) (*protocol.ImportResponse, error) { |
| 220 | panic("not implemented") // TODO: Implement |
| 221 | } |
| 222 | |
| 223 | func (c *ChordClient) ListKeys(_ context.Context, _ *protocol.ListKeysRequest) (*protocol.ListKeysResponse, error) { |
| 224 | panic("not implemented") // TODO: Implement |
| 225 | } |
| 226 | |
| 227 | func (c *ChordClient) RatePer(interval time.Duration) float64 { |
| 228 | return 1.0 |
| 229 | } |
| 230 | |
| 231 | var _ rpc.ChordClient = (*ChordClient)(nil) |