v3lock.proto 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. syntax = "proto3";
  2. package v3lockpb;
  3. import "gogoproto/gogo.proto";
  4. import "etcd/etcdserver/etcdserverpb/rpc.proto";
  5. // for grpc-gateway
  6. import "google/api/annotations.proto";
  7. option (gogoproto.marshaler_all) = true;
  8. option (gogoproto.unmarshaler_all) = true;
  9. // The lock service exposes client-side locking facilities as a gRPC interface.
  10. service Lock {
  11. // Lock acquires a distributed shared lock on a given named lock.
  12. // On success, it will return a unique key that exists so long as the
  13. // lock is held by the caller. This key can be used in conjunction with
  14. // transactions to safely ensure updates to etcd only occur while holding
  15. // lock ownership. The lock is held until Unlock is called on the key or the
  16. // lease associate with the owner expires.
  17. rpc Lock(LockRequest) returns (LockResponse) {
  18. option (google.api.http) = {
  19. post: "/v3beta/lock/lock"
  20. body: "*"
  21. };
  22. }
  23. // Unlock takes a key returned by Lock and releases the hold on lock. The
  24. // next Lock caller waiting for the lock will then be woken up and given
  25. // ownership of the lock.
  26. rpc Unlock(UnlockRequest) returns (UnlockResponse) {
  27. option (google.api.http) = {
  28. post: "/v3beta/lock/unlock"
  29. body: "*"
  30. };
  31. }
  32. }
  33. message LockRequest {
  34. // name is the identifier for the distributed shared lock to be acquired.
  35. bytes name = 1;
  36. // lease is the ID of the lease that will be attached to ownership of the
  37. // lock. If the lease expires or is revoked and currently holds the lock,
  38. // the lock is automatically released. Calls to Lock with the same lease will
  39. // be treated as a single acquistion; locking twice with the same lease is a
  40. // no-op.
  41. int64 lease = 2;
  42. }
  43. message LockResponse {
  44. etcdserverpb.ResponseHeader header = 1;
  45. // key is a key that will exist on etcd for the duration that the Lock caller
  46. // owns the lock. Users should not modify this key or the lock may exhibit
  47. // undefined behavior.
  48. bytes key = 2;
  49. }
  50. message UnlockRequest {
  51. // key is the lock ownership key granted by Lock.
  52. bytes key = 1;
  53. }
  54. message UnlockResponse {
  55. etcdserverpb.ResponseHeader header = 1;
  56. }