claimChord method
Attempts to claim responsibility for dispatching the chord callback for
groupId. Returns true only for the first caller; subsequent callers
receive false once the chord has been claimed. When callbackTaskId or
dispatchedAt are provided, implementations SHOULD persist them with the
group metadata so other components can observe dispatch progress.
Implementation
@override
Future<bool> claimChord(
String groupId, {
String? callbackTaskId,
DateTime? dispatchedAt,
}) async {
final added = _claimedChords.add(groupId);
if (!added) {
return false;
}
final group = _groups[groupId];
if (group != null) {
group.meta['stem.chord.claimed'] = true;
if (callbackTaskId != null) {
group.meta[ChordMetadata.callbackTaskId] = callbackTaskId;
}
if (dispatchedAt != null) {
group.meta[ChordMetadata.dispatchedAt] = dispatchedAt.toIso8601String();
}
}
return true;
}