service_commons.sse
Modules
Module service_commons.sse
Definitions
commons/service_commons.sse
Classes
service_commons.sse: Hub
In-process fan-out of events to open SSE streams. Events and streams are matched by target keys,
e.g. user:alice or role:Finance: a stream receives an event when they share a key.
Streams on other nodes see nothing; clients recover missed events through replay.
open
function open(string[] targets, StreamEvent[] backlog) returns stream<SseEvent, error?>Opens a stream for a set of target keys.
Parameters
- targets string[] - Keys the stream listens on
- backlog StreamEvent[] (default []) - Events to send first, e.g. those replayed after
Last-Event-ID
publish
function publish(StreamEvent event, string[] targets)Sends an event to every open stream that shares one of its target keys.
size
function size() returns intNumber of open streams.
Return Type
- int - The count
Records
service_commons.sse: HubConfig
Tuning for a hub's streams.
Fields
- pollInterval decimal(default 0.2) - How often an idle stream checks for events, in seconds
- heartbeatInterval decimal(default 15) - Comment sent on an idle stream to keep proxies from closing it, in seconds
- staleAfter decimal(default 60) - A stream not polled for this long is treated as disconnected, in seconds
- maxQueued int(default 1000) - Events buffered per stream; the oldest are dropped beyond this
service_commons.sse: StreamEvent
An event on a service's SSE stream.
Fields
- id string - Replay point, sent back by the client as
Last-Event-ID
- event string - SSE event name, e.g.
notification.created
- data json - Event payload
Import
import commons/service_commons.sse;Other versions
0.1.0
Metadata
Released date: 27 days ago
Version: 0.1.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.13.4
GraalVM compatible: Yes
Pull count
Total: 2
Current verison: 2
Weekly downloads
Keywords
commons
service
auth
jdbc
sse
webhook
Contributors