sequenceDiagram
participant Client as Dynamo Client
participant etcd as etcd Server
Client->>etcd: LeaseGrant(TTL=10s)
etcd-->>Client: Lease ID
Client->>etcd: Put(key, value, lease_id)
etcd-->>Client: OK
Note over Client,etcd: Key 绑定到 Lease
sequenceDiagram
participant Client as Dynamo Client
participant etcd as etcd Server
Client->>etcd: LeaseGrant(TTL=10s)
etcd-->>Client: Lease ID
loop 每 TTL/3 秒
Client->>etcd: LeaseKeepAlive(ID)
etcd-->>Client: TTL Refreshed
end
Note over Client: CancellationToken 触发
Client->>etcd: LeaseRevoke(ID)
Note over etcd: 删除所有绑定的 Key
graph LR
subgraph txn["etcd 事务"]
WHEN["when: version == 0 Key 不存在"]
THEN["then: PUT key value"]
ELSE["else: 返回错误"]
WHEN --> |满足| THEN
WHEN --> |不满足| ELSE
end
sequenceDiagram
participant Client as Dynamo Client
participant etcd as etcd Server
participant Cache as 本地缓存
Client->>etcd: GET /dynamo/components/* (with prefix)
etcd-->>Client: [Endpoint A, Endpoint B]
Client->>Cache: 初始化缓存
Client->>etcd: WATCH /dynamo/components/* (from revision N)
Note over etcd: 新 Endpoint 注册
etcd->>Client: PUT event (Endpoint C)
Client->>Cache: 添加 Endpoint C
Note over etcd: Endpoint 下线
etcd->>Client: DELETE event (Endpoint A)
Client->>Cache: 移除 Endpoint A