Browse Source

*: update api proto

Xiang Li 10 years ago
parent
commit
1a0201a31a
3 changed files with 38 additions and 15 deletions
  1. 17 15
      Documentation/rfc/v3api.proto
  2. 18 0
      etcdserver/etcdserverpb/rpc.proto
  3. 3 0
      storage/storagepb/kv.proto

+ 17 - 15
Documentation/rfc/v3api.proto

@@ -17,12 +17,23 @@ service KV {
   // Txn processes all the requests in one transaction.
   // A txn request increases the revision of the store,
   // and generates events with the same revision in the event history.
+  // It is not allowed to modify the same key several times within one txn.
   rpc Txn(TxnRequest) returns (TxnResponse) {}
 
   // Compact compacts the event history in etcd. User should compact the
   // event history periodically, or it will grow infinitely.
   rpc Compact(CompactionRequest) returns (CompactionResponse) {}
+}
+
+service watch {
+  // Watch watches the events happening or happened. Both input and output
+  // are stream. One watch rpc can watch for multiple keys or prefixs and
+  // get a stream of events. The whole events history can be watched unless
+  // compacted.
+  rpc Watch(stream WatchRequest) returns (stream WatchResponse) {}
+}
 
+service Lease {
   // LeaseCreate creates a lease. A lease has a TTL. The lease will expire if the
   // server does not receive a keepAlive within TTL from the lease holder.
   // All keys attached to the lease will be expired and deleted if the lease expires.
@@ -32,24 +43,11 @@ service KV {
   // LeaseRevoke revokes a lease. All the key attached to the lease will be expired and deleted.
   rpc LeaseRevoke(LeaseRevokeRequest) returns (LeaseRevokeResponse) {}
 
-  // LeaseAttach attaches keys with a lease.
-  rpc LeaseAttach(LeaseAttachRequest) returns (LeaseAttachResponse) {}
-
-  // LeaseTxn likes Txn. It has two addition success and failure LeaseAttachRequest list.
-  // If the Txn is successful, then the success list will be executed. Or the failure list
-  // will be executed.
-  rpc LeaseTxn(LeaseTxnRequest) returns (LeaseTxnResponse) {}
-
   // KeepAlive keeps the lease alive.
   rpc LeaseKeepAlive(stream LeaseKeepAliveRequest) returns (stream LeaseKeepAliveResponse) {}
-}
 
-service watch {
-  // Watch watches the events happening or happened. Both input and output
-  // are stream. One watch rpc can watch for multiple keys or prefixs and
-  // get a stream of events. The whole events history can be watched unless
-  // compacted.
-  rpc Watch(stream WatchRequest) returns (stream WatchResponse) {}
+  // TODO(xiangli) List all existing Leases?
+  // TODO(xiangli) Get details information (expirations, leased keys, etc.) of a lease?
 }
 
 message ResponseHeader {
@@ -87,6 +85,7 @@ message RangeResponse {
 message PutRequest {
   bytes key = 1;
   bytes value = 2;
+  int64 lease = 3;
 }
 
 message PutResponse {
@@ -190,6 +189,9 @@ message KeyValue {
   // increases its version.
   int64 version = 4;
   bytes value = 5;
+  // lease is the ID of the lease that attached to key.
+  // When the attached lease expires, the key will be deleted.
+  int64 lease = 6;
 }
 
 message WatchRequest {

+ 18 - 0
etcdserver/etcdserverpb/rpc.proto

@@ -24,6 +24,7 @@ service KV {
   // Txn processes all the requests in one transaction.
   // A txn request increases the revision of the store,
   // and generates events with the same revision in the event history.
+  // It is not allowed to modify the same key several times within one txn.
   rpc Txn(TxnRequest) returns (TxnResponse) {}
 
   // Compact compacts the event history in etcd. User should compact the
@@ -39,6 +40,23 @@ service watch {
   rpc Watch(stream WatchRequest) returns (stream WatchResponse) {}
 }
 
+service Lease {
+  // LeaseCreate creates a lease. A lease has a TTL. The lease will expire if the
+  // server does not receive a keepAlive within TTL from the lease holder.
+  // All keys attached to the lease will be expired and deleted if the lease expires.
+  // The key expiration generates an event in event history.
+  rpc LeaseCreate(LeaseCreateRequest) returns (LeaseCreateResponse) {}
+
+  // LeaseRevoke revokes a lease. All the key attached to the lease will be expired and deleted.
+  rpc LeaseRevoke(LeaseRevokeRequest) returns (LeaseRevokeResponse) {}
+
+  // KeepAlive keeps the lease alive.
+  rpc LeaseKeepAlive(stream LeaseKeepAliveRequest) returns (stream LeaseKeepAliveResponse) {}
+
+  // TODO(xiangli) List all existing Leases?
+  // TODO(xiangli) Get details information (expirations, leased keys, etc.) of a lease?
+}
+
 message ResponseHeader {
   uint64 cluster_id = 1;
   uint64 member_id = 2;

+ 3 - 0
storage/storagepb/kv.proto

@@ -19,6 +19,9 @@ message KeyValue {
   // increases its version.
   int64 version = 4;
   bytes value = 5;
+  // lease is the ID of the lease that attached to key.
+  // When the attached lease expires, the key will be deleted.
+  int64 lease = 6;
 }
 
 message Event {