v3election.proto 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. syntax = "proto3";
  2. package v3electionpb;
  3. import "gogoproto/gogo.proto";
  4. import "etcd/etcdserver/etcdserverpb/rpc.proto";
  5. import "etcd/mvcc/mvccpb/kv.proto";
  6. // for grpc-gateway
  7. import "google/api/annotations.proto";
  8. option (gogoproto.marshaler_all) = true;
  9. option (gogoproto.unmarshaler_all) = true;
  10. // The election service exposes client-side election facilities as a gRPC interface.
  11. service Election {
  12. // Campaign waits to acquire leadership in an election, returning a LeaderKey
  13. // representing the leadership if successful. The LeaderKey can then be used
  14. // to issue new values on the election, transactionally guard API requests on
  15. // leadership still being held, and resign from the election.
  16. rpc Campaign(CampaignRequest) returns (CampaignResponse) {
  17. option (google.api.http) = {
  18. post: "/v3alpha/election/campaign"
  19. body: "*"
  20. };
  21. }
  22. // Proclaim updates the leader's posted value with a new value.
  23. rpc Proclaim(ProclaimRequest) returns (ProclaimResponse) {
  24. option (google.api.http) = {
  25. post: "/v3alpha/election/proclaim"
  26. body: "*"
  27. };
  28. }
  29. // Leader returns the current election proclamation, if any.
  30. rpc Leader(LeaderRequest) returns (LeaderResponse) {
  31. option (google.api.http) = {
  32. post: "/v3alpha/election/leader"
  33. body: "*"
  34. };
  35. }
  36. // Observe streams election proclamations in-order as made by the election's
  37. // elected leaders.
  38. rpc Observe(LeaderRequest) returns (stream LeaderResponse) {
  39. option (google.api.http) = {
  40. post: "/v3alpha/election/observe"
  41. body: "*"
  42. };
  43. }
  44. // Resign releases election leadership so other campaigners may acquire
  45. // leadership on the election.
  46. rpc Resign(ResignRequest) returns (ResignResponse) {
  47. option (google.api.http) = {
  48. post: "/v3alpha/election/resign"
  49. body: "*"
  50. };
  51. }
  52. }
  53. message CampaignRequest {
  54. // name is the election's identifier for the campaign.
  55. bytes name = 1;
  56. // lease is the ID of the lease attached to leadership of the election. If the
  57. // lease expires or is revoked before resigning leadership, then the
  58. // leadership is transferred to the next campaigner, if any.
  59. int64 lease = 2;
  60. // value is the initial proclaimed value set when the campaigner wins the
  61. // election.
  62. bytes value = 3;
  63. }
  64. message CampaignResponse {
  65. etcdserverpb.ResponseHeader header = 1;
  66. // leader describes the resources used for holding leadereship of the election.
  67. LeaderKey leader = 2;
  68. }
  69. message LeaderKey {
  70. // name is the election identifier that correponds to the leadership key.
  71. bytes name = 1;
  72. // key is an opaque key representing the ownership of the election. If the key
  73. // is deleted, then leadership is lost.
  74. bytes key = 2;
  75. // rev is the creation revision of the key. It can be used to test for ownership
  76. // of an election during transactions by testing the key's creation revision
  77. // matches rev.
  78. int64 rev = 3;
  79. // lease is the lease ID of the election leader.
  80. int64 lease = 4;
  81. }
  82. message LeaderRequest {
  83. // name is the election identifier for the leadership information.
  84. bytes name = 1;
  85. }
  86. message LeaderResponse {
  87. etcdserverpb.ResponseHeader header = 1;
  88. // kv is the key-value pair representing the latest leader update.
  89. mvccpb.KeyValue kv = 2;
  90. }
  91. message ResignRequest {
  92. // leader is the leadership to relinquish by resignation.
  93. LeaderKey leader = 1;
  94. }
  95. message ResignResponse {
  96. etcdserverpb.ResponseHeader header = 1;
  97. }
  98. message ProclaimRequest {
  99. // leader is the leadership hold on the election.
  100. LeaderKey leader = 1;
  101. // value is an update meant to overwrite the leader's current value.
  102. bytes value = 2;
  103. }
  104. message ProclaimResponse {
  105. etcdserverpb.ResponseHeader header = 1;
  106. }