Record Class CoordinationKey
java.lang.Object
java.lang.Record
io.krabka.streams.coordination.CoordinationKey
- Record Components:
kind- the record the key namesrole- the role the record belongs tomember- the member for a registration key, and empty for a lease key
The decoded key of one record of
CoordinationCodec.TOPIC.
The key is the compaction key, so the topic keeps the last record of every role and every member. The key also carries the record kind, so one topic holds both kinds and a reader picks the value layout from the key it already read.
The member is present for RecordKind.REGISTRATION and absent for
RecordKind.LEASE. A lease belongs to the role and not to one member, and the
frozen layout writes the empty string in that position.
registration(Role, MemberId) and lease(Role) build a key that keeps
this rule.
Example
CoordinationKey mine = CoordinationKey.registration(Role.of("controller"), me);
CoordinationKey theirs = CoordinationKey.lease(Role.of("controller"));
byte[] bytes = CoordinationCodec.encodeKey(theirs);
-
Constructor Summary
ConstructorsConstructorDescriptionCoordinationKey(RecordKind kind, Role role, Optional<MemberId> member) Rejects a null component and a key whose member does not match its kind. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.kind()Returns the value of thekindrecord component.static CoordinationKeyBuilds the key of the lease of a role.member()Returns the value of thememberrecord component.static CoordinationKeyregistration(Role role, MemberId member) Builds the key of the registration of one member of a role.role()Returns the value of therolerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CoordinationKey
Rejects a null component and a key whose member does not match its kind.- Parameters:
kind- the record the key namesrole- the role the record belongs tomember- the member for a registration key, and empty for a lease key
-
-
Method Details
-
registration
Builds the key of the registration of one member of a role.- Parameters:
role- the role the member competes formember- the member that registers- Returns:
- the registration key of that member
-
lease
Builds the key of the lease of a role.- Parameters:
role- the role the lease belongs to- Returns:
- the lease key of that role, which carries no member
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
kind
-
role
-
member
-