Campaign方法

Campaign 方法用于参加选举以期获得领导地位:

// Campaign 等待获得选举的领导地位,如果成功返回 LeaderKey 代表领导地位。
// 然后 LeaderKey 可以用来在选举时发起新的值,在依然持有领导地位时事务性的守护 API 请求,
// 还有从选举中辞职。
rpc Campaign(CampaignRequest) returns (CampaignResponse) {}

消息定义

请求的消息体是 CampaignRequest

message CampaignRequest {
  // name 是选举的标识符,用来参加竞选
  bytes name = 1;
  // lease is the ID of the lease attached to leadership of the election. If the
  // lease expires or is revoked before resigning leadership, then the
  // leadership is transferred to the next campaigner, if any.
  // lease 是附加到选举领导地位的租约的ID。如果租约过期或者在放弃领导地位之前取消,
  // 则领导地位转移到下一个竞选者,如果有。
  int64 lease = 2;
  // value 是竞选者赢得选举时设置的初始化公告值。
  bytes value = 3;
}

应答的消息体是 CampaignResponse

LeaderKey 消息体的内容:

Last updated