Skip to content

Commit

Permalink
Merge pull request #19319 from fuweid/fix-19292
Browse files Browse the repository at this point in the history
*: introduce (*Op) Limit() interface for robustness
  • Loading branch information
serathius authored Feb 3, 2025
2 parents b197332 + 136dfbe commit de82ea2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions client/v3/op.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (op Op) RangeBytes() []byte { return op.end }
// Rev returns the requested revision, if any.
func (op Op) Rev() int64 { return op.rev }

// Limit returns limit of the result, if any.
func (op Op) Limit() int64 { return op.limit }

// IsPut returns true iff the operation is a Put.
func (op Op) IsPut() bool { return op.t == tPut }

Expand Down
4 changes: 2 additions & 2 deletions tests/robustness/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func (c *RecordingClient) Do(ctx context.Context, op clientv3.Op) (clientv3.OpRe
}

func (c *RecordingClient) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) {
revision := clientv3.OpGet(key, opts...).Rev()
return c.Range(ctx, key, "", revision, 0)
op := clientv3.OpGet(key, opts...)
return c.Range(ctx, key, string(op.RangeBytes()), op.Rev(), op.Limit())
}

func (c *RecordingClient) Range(ctx context.Context, start, end string, revision, limit int64) (*clientv3.GetResponse, error) {
Expand Down

0 comments on commit de82ea2

Please sign in to comment.