feat(client): streamEvents() wraps server-streaming audit log
Some checks failed
Security / Security check (push) Failing after 2s
Some checks failed
Security / Security check (push) Failing after 2s
Adds `HubClient.streamEvents(backfill:, types:)` returning a `Stream<LoggedEvent>` that fronts the new `HubAdmin/StreamEvents` RPC. Each event arrives the instant the hub appends it; cancel the subscription to close the RPC. `backfill` defaults to 50 historical events (oldest-last for chronological reception). `RESOURCE_EXHAUSTED` from the server means the receiver fell behind — reconnect with a fresh backfill to resync. Bindings regenerated from fai_platform/proto. dart analyze + dart test green (4 tests). Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
parent
549f9df5c6
commit
c90a88481c
4 changed files with 116 additions and 0 deletions
|
|
@ -158,6 +158,25 @@ class HubClient {
|
|||
return r.events;
|
||||
}
|
||||
|
||||
/// Server-streaming audit-log subscription. The hub first
|
||||
/// replays up to [backfill] historical events (oldest-last so
|
||||
/// the receiver sees them in chronological order), then keeps
|
||||
/// the stream open and forwards every newly-appended event as
|
||||
/// soon as it lands.
|
||||
///
|
||||
/// Cancel the returned [Stream]'s subscription to close the
|
||||
/// RPC. If the server reports `RESOURCE_EXHAUSTED` ("stream
|
||||
/// lagged"), reconnect with backfill to resync.
|
||||
Stream<LoggedEvent> streamEvents({
|
||||
int backfill = 50,
|
||||
List<String> types = const [],
|
||||
}) {
|
||||
final req = pb.StreamEventsRequest()
|
||||
..backfill = backfill
|
||||
..eventTypes.addAll(types);
|
||||
return _admin.streamEvents(req);
|
||||
}
|
||||
|
||||
/// Pending approvals filtered by status. Defaults to all.
|
||||
Future<List<PendingApprovalEntry>> listApprovals({
|
||||
List<String> statuses = const [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue