owner_id
owner_id names this instance in the lease table; left out, each broker takes an id of its own, unique to that broker.
A lease store records which owner holds each shard, and grants an owner the leases it already holds.
So an instance that restarts under the same id takes its shards back at once, without waiting for its old leases to expire.
A stable name per instance, such as a pod name, gives that.
A fixed id must never be shared by two instances that run at the same time: both would hold the same shards, and each would read them.
The DynamoLeaseStore table shows the id in the lease_owner column of each row, which tells an operator which instance reads which shard.
Example
The dispatch service names each instance after its host.
- Macros
- Manual
/// `instance` names this instance in the lease table: the same name after a restart, a
/// different one on every other instance.
fn broker(config: &SdkConfig, table: &str, instance: &str) -> KinesisBroker {
let leases = Arc::new(DynamoLeaseStore::new(config, table));
KinesisBroker::from_config(config.clone())
.lease_store(leases)
.owner_id(instance)
}
/// `instance` names this instance in the lease table: the same name after a restart, a
/// different one on every other instance.
fn broker(config: &SdkConfig, table: &str, instance: &str) -> KinesisBroker {
let leases = Arc::new(DynamoLeaseStore::new(config, table));
KinesisBroker::from_config(config.clone())
.lease_store(leases)
.owner_id(instance)
}