Interface of leader election client talking to etcd.
| 29 | * Interface of leader election client talking to etcd. |
| 30 | */ |
| 31 | public interface Election extends CloseableClient { |
| 32 | /** |
| 33 | * Campaign waits to acquire leadership in an election, returning a leader key |
| 34 | * representing the leadership if successful. The leader key can then be used |
| 35 | * to issue new values on the election, transactionally guard API requests on |
| 36 | * leadership still being held, and resign from the election. |
| 37 | * |
| 38 | * @param electionName election name |
| 39 | * @param leaseId lease identifier |
| 40 | * @param proposal proposal |
| 41 | * @return the response |
| 42 | */ |
| 43 | CompletableFuture<CampaignResponse> campaign(ByteSequence electionName, long leaseId, ByteSequence proposal); |
| 44 | |
| 45 | /** |
| 46 | * Proclaim updates the leader's posted value with a new value. Only active |
| 47 | * leader can change the value. |
| 48 | * |
| 49 | * @param leaderKey leader key |
| 50 | * @param proposal new proposal |
| 51 | * @return the response |
| 52 | */ |
| 53 | CompletableFuture<ProclaimResponse> proclaim(LeaderKey leaderKey, ByteSequence proposal); |
| 54 | |
| 55 | /** |
| 56 | * Returns the current election proclamation, if any. |
| 57 | * |
| 58 | * @param electionName election name |
| 59 | * @return the response |
| 60 | */ |
| 61 | CompletableFuture<LeaderResponse> leader(ByteSequence electionName); |
| 62 | |
| 63 | /** |
| 64 | * Listens to election proclamations in-order as made by the election's |
| 65 | * elected leaders. |
| 66 | * |
| 67 | * @param electionName election name |
| 68 | * @param listener listener |
| 69 | */ |
| 70 | void observe(ByteSequence electionName, Listener listener); |
| 71 | |
| 72 | /** |
| 73 | * Resign releases election leadership so other campaigners may acquire |
| 74 | * leadership on the election. |
| 75 | * |
| 76 | * @param leaderKey leader key |
| 77 | * @return the response |
| 78 | */ |
| 79 | CompletableFuture<ResignResponse> resign(LeaderKey leaderKey); |
| 80 | |
| 81 | /** |
| 82 | * Interface of leadership notification listener. |
| 83 | */ |
| 84 | interface Listener { |
| 85 | /** |
| 86 | * Invoked on new leader elected. |
| 87 | * |
| 88 | * @param response the response. |
no outgoing calls
no test coverage detected