Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
Actor is responsible for connecting to an SSE endpoint, reading and parsing incoming events, and invoking a handler function for each event.
func NewActor ¶
func NewActor(name string, url string, onEvent func(Event), opts ...ActorOption) *Actor
NewActor creates a new Actor with the specified URL, event handler, and optional configuration options.
func (*Actor) LastEventID ¶
LastEventID returns the ID of the last successfully received event.
type ActorOption ¶
type ActorOption func(*Actor)
ActorOption defines a function type for configuring an Actor.
func WithHTTPClient ¶
func WithHTTPClient(c *http.Client) ActorOption
WithHTTPClient allows the caller to provide a custom http.Client for making requests to the SSE endpoint.
func WithLastEventID ¶
func WithLastEventID(id string) ActorOption
WithLastEventID sets the initial Last-Event-ID to be used when connecting.
func WithOnConnect ¶
func WithOnConnect(handler func(url string, lastID string)) ActorOption
WithOnConnect allows the caller to provide a callback function that will be invoked when the Actor successfully connects to the SSE endpoint.
func WithOnError ¶
func WithOnError(handler func(error)) ActorOption
WithOnError allows the caller to provide a callback function that will be invoked whenever an error occurs during the Actor's operation.
func WithTimeout ¶
func WithTimeout(d time.Duration) ActorOption
WithTimeout sets the duration after which the SSE connection will be considered timed out if no events are received.