sse

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL string, tokenSource oauth2.TokenSource, sessionID string, apiKey string, logger *slog.Logger) *Client

func (*Client) Ack

func (c *Client) Ack(ctx context.Context, traceIDs []string) error

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, handler NotificationHandler) error

Connect establishes an SSE connection and calls the handler for each notification. It automatically reconnects with exponential backoff on disconnection. Returns when the context is cancelled.

func (*Client) SetAPIKey

func (c *Client) SetAPIKey(apiKey string)

type Event

type Event struct {
	Type string
	Data []byte
}

type NotificationHandler

type NotificationHandler func(notification storage.Notification)

type PollClient

type PollClient struct {
	// contains filtered or unexported fields
}

func NewPollClient

func NewPollClient(baseURL string, tokenSource oauth2.TokenSource, sessionID string, apiKey string) *PollClient

func (*PollClient) Ack

func (c *PollClient) Ack(ctx context.Context, traceIDs []string) error

func (*PollClient) Poll

func (c *PollClient) Poll(ctx context.Context, cursor int64, limit int32) (*PollResponse, error)

Poll fetches unacknowledged notifications using cursor-based pagination. Pass cursor=0 for the first page. Returns notifications with id > cursor.

func (*PollClient) PollAll

func (c *PollClient) PollAll(ctx context.Context, ch chan<- storage.Notification) (int, error)

PollAll fetches all unacknowledged notifications by paginating until exhausted. Sends notifications to the provided channel as they are fetched. Returns total count fetched, or error. Closes channel when done or on error.

func (*PollClient) SetAPIKey

func (c *PollClient) SetAPIKey(apiKey string)

type PollResponse

type PollResponse struct {
	Notifications []storage.Notification `json:"notifications"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL