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