Versions in this module Expand all Collapse all v0 v0.1.2 Oct 23, 2026 v0.1.1 Oct 18, 2026 v0.1.0 Oct 18, 2026 Changes in this version + const AdvisoryHeadroom + const CloseCodeHeartbeatTimeout + const CodeNotAvailable + const DefaultDialTimeout + const DefaultHeartbeatInterval + const DefaultHistoryLimit + const DefaultMaxBackpressureReconnects + const DefaultMaxPublishSize + const DefaultPongTimeout + const DefaultQueueSize + const DefaultRecoveryDeadline + const DefaultRefreshLead + const DefaultRefreshMinInterval + const DefaultReplayFloor + const DefaultSSEIdleTimeout + const DefaultTokenSourceTimeout + const MaxHistoryLimit + const MaxReplayMessages + const MaxTokenSourceAttempts + const MinChannelParts + const RecoveryKindHistory + const RecoveryKindReconnectReplay + const RecoveryKindReplay + const SubscribeQueueDepth + var DefaultBackoff = BackoffConfig + var ErrAlreadyConnected = errors.New("sukko: already connected") + var ErrClosed = errors.New("sukko: client is closed") + var ErrConsumerTooSlow = errors.New("sukko: consumer too slow") + var ErrEditionRequired = errors.New("sukko: operation requires a higher edition") + var ErrEmptyToken = errors.New("sukko: a non-empty token is required") + var ErrHistoryInProgress = errors.New("sukko: a history request is already in flight") + var ErrHistoryLimitExceeded = errors.New("sukko: history limit exceeds the configured maximum") + var ErrInsecureTransport = errors.New("sukko: refusing to use a non-TLS URL") + var ErrInvalidChannel = errors.New("sukko: invalid channel") + var ErrInvalidPushOptions = errors.New("sukko: invalid push subscription options") + var ErrNotAvailable = errors.New("sukko: pos-anchored recovery is not available") + var ErrNotConnected = errors.New("sukko: not connected") + var ErrPayloadNotObject = errors.New("sukko: publish payload must marshal to a JSON object") + var ErrPayloadTooLarge = errors.New("sukko: publish payload exceeds the maximum size") + var ErrPublishRequiresJWT = errors.New("sukko: publishing requires a JWT, not an API key") + var ErrPushDisabled = errors.New("sukko: push is not enabled on this gateway") + var ErrPushUnavailable = errors.New("sukko: push service is temporarily unavailable") + var ErrSubscribeQueueFull = errors.New("sukko: subscribe queue is full") + var ErrTokenSourceFailed = errors.New("sukko: token source failed repeatedly") + var ErrUnsupportedByTransport = errors.New("sukko: operation not supported by this transport") + func BuildChannel(tenant, suffix string) (string, error) + func DataAs[T any](msg *Message) (T, error) + type AuthError struct + Code string + Message string + func (e *AuthError) Error() string + type AuthMode string + const AuthEscalation + const AuthRefresh + func (m AuthMode) String() string + type Authenticated struct + Exp int64 + Mode AuthMode + type BackoffConfig struct + Initial time.Duration + Jitter float64 + Max time.Duration + Multiplier float64 + type Capabilities struct + CanPublish bool + CanRefreshInPlace bool + CanSubscribeLive bool + type Channel struct + Suffix string + Tenant string + func ParseChannel(s string) (Channel, error) + func (c Channel) String() string + type Client struct + func NewClient(ctx context.Context, url string, opts ...Option) (*Client, error) + func (c *Client) Capabilities() Capabilities + func (c *Client) Close(ctx context.Context) error + func (c *Client) Connect(ctx context.Context) error + func (c *Client) Err() error + func (c *Client) Escalate(ctx context.Context, jwt string) error + func (c *Client) History(ctx context.Context, channel string, limit int) error + func (c *Client) Iter(ctx context.Context) iter.Seq[Event] + func (c *Client) Messages() <-chan Event + func (c *Client) PendingSubscriptions() []string + func (c *Client) Publish(ctx context.Context, channel string, data any) error + func (c *Client) PushSubscribe(ctx context.Context, opts PushSubscribeOptions) (int64, error) + func (c *Client) PushUnsubscribe(ctx context.Context, deviceID int64) error + func (c *Client) PushVAPIDKey(ctx context.Context) (string, error) + func (c *Client) RESTPublish(ctx context.Context, channel string, data any) (*PublishResult, error) + func (c *Client) RefreshToken(ctx context.Context) error + func (c *Client) State() ConnectionState + func (c *Client) Stats() Stats + func (c *Client) Subscribe(ctx context.Context, channels []string) error + func (c *Client) Subscriptions() []string + func (c *Client) Unsubscribe(ctx context.Context, channels []string) error + func (c *Client) UpdateToken(token string) error + type Clock interface + BlockUntilTimer func(purpose timerPurpose) + NewTicker func(d time.Duration, purpose timerPurpose) Ticker + NewTimer func(d time.Duration, purpose timerPurpose) Timer + Now func() time.Time + type CloseError struct + Code int + Direction closeDirection + Reason string + func (e *CloseError) Error() string + type Conn interface + Close func(code int, reason string) error + Read func(ctx context.Context) ([]byte, error) + Send func(ctx context.Context, frame []byte) error + type ConnectionState string + const StateClosed + const StateConnected + const StateConnecting + const StateDisconnected + const StateError + const StateReconnecting + func (s ConnectionState) String() string + type Edition string + const EditionEnterprise + const EditionPro + func (e Edition) String() string + type EditionRequiredError struct + Code string + RequiredEdition Edition + func (e *EditionRequiredError) Error() string + func (e *EditionRequiredError) Is(target error) bool + type Event interface + type Gap struct + Channel string + FromSeq int64 + LastPos string + TS int64 + ToSeq int64 + type HandshakeError struct + Code string + Message string + RetryAfter *time.Duration + Status int + func (e *HandshakeError) Error() string + type HistoryComplete struct + Channel string + Count int + Source HistorySource + Truncated bool + type HistoryError struct + Channel string + Code string + Message string + func (e *HistoryError) Error() string + type HistorySource string + const HistorySourceCache + const HistorySourceKafka + const HistorySourceMixed + func (s HistorySource) String() string + type InternalError struct + Op string + Stack string + Value string + func (e *InternalError) Error() string + type Message struct + Channel string + Data json.RawMessage + Mid string + Pos string + Seq int64 + Source MessageSource + TS int64 + type MessageSource string + const SourceHistory + const SourceLive + const SourceReplay + func (s MessageSource) String() string + type NotConnectedError struct + Op string + func (e *NotConnectedError) Error() string + func (e *NotConnectedError) Is(target error) bool + type Option func(*config) + func WithAPIKey(key string) Option + func WithBackoff(b BackoffConfig) Option + func WithClientID(id string) Option + func WithClock(clock Clock) Option + func WithDialTimeout(d time.Duration) Option + func WithHTTPClient(client *http.Client) Option + func WithHeartbeatInterval(d time.Duration) Option + func WithHistoryLimit(n int) Option + func WithInsecureTransport() Option + func WithLogger(logger *slog.Logger) Option + func WithMaxBackpressureReconnects(n int) Option + func WithMaxPublishSize(n int) Option + func WithNoAuth() Option + func WithPongTimeout(d time.Duration) Option + func WithQueryParamAuth() Option + func WithQueueSize(n int) Option + func WithRand(rand Rand) Option + func WithReconnect(enabled bool) Option + func WithRecoveryDeadline(d time.Duration) Option + func WithRefreshLead(d time.Duration) Option + func WithRefreshMinInterval(d time.Duration) Option + func WithReplayFloor(d time.Duration) Option + func WithSSEIdleTimeout(d time.Duration) Option + func WithToken(token string) Option + func WithTokenSource(src TokenSource) Option + func WithTokenSourceTimeout(d time.Duration) Option + func WithTransport(kind TransportKind) Option + type PayloadDecodeError struct + Cause error + Channel string + func (e *PayloadDecodeError) Error() string + func (e *PayloadDecodeError) Unwrap() error + type PossibleGap struct + Channels []string + type ProtocolError struct + Cause error + Code string + Message string + Type string + func (e *ProtocolError) Error() string + func (e *ProtocolError) Unwrap() error + type PublishAccepted struct + Channel string + Mid string + type PublishError struct + Code string + Message string + func (e *PublishError) Error() string + type PublishResult struct + Channel string + Mid string + type PushError struct + Code string + Message string + func (e *PushError) Error() string + type PushPlatform string + const PlatformAndroid + const PlatformIOS + const PlatformWeb + func (p PushPlatform) String() string + type PushSubscribeOptions struct + AuthSecret string + Channels []string + Endpoint string + P256dhKey string + Platform PushPlatform + Token string + type Rand interface + Float64 func() float64 + type RateLimitError struct + RetryAfter *time.Duration + func (e *RateLimitError) Error() string + type ReconnectError struct + Code string + Message string + func (e *ReconnectError) Error() string + func (e *ReconnectError) Is(target error) bool + type RecoveryInterruptedError struct + Channel string + Kind string + func (e *RecoveryInterruptedError) Error() string + type ReplayComplete struct + Channel string + MessagesReplayed int + Truncated bool + type ReplayError struct + Channel string + Code string + Message string + func (e *ReplayError) Error() string + func (e *ReplayError) Is(target error) bool + type Resumed struct + MessagesReplayed int + type StateChange struct + From ConnectionState + To ConnectionState + type Stats struct + BackpressureBlocks int64 + BackpressureReconnects int64 + Blocked time.Duration + Gaps int64 + MessagesReceived int64 + PossibleGaps int64 + Reconnects int64 + Replays int64 + UnknownEvents int64 + type SubscriptionResult struct + Count int + Granted []string + NotGranted []string + Requested []string + type Terminal struct + Err error + type Ticker interface + C func() <-chan time.Time + Stop func() + type Timer interface + C func() <-chan time.Time + Stop func() bool + type Token struct + Expiry time.Time + Value string + type TokenSource func(ctx context.Context) (Token, error) + type TokenSourceError struct + Attempt int + Cause error + func (e *TokenSourceError) Error() string + func (e *TokenSourceError) Unwrap() error + type Transport interface + Capabilities func() Capabilities + Open func(ctx context.Context) (Conn, error) + type TransportKind string + const TransportSSE + const TransportWebSocket + func (k TransportKind) String() string + type UnknownEvent struct + Raw json.RawMessage + Type string + type Unsubscribed struct + Channels []string + Count *int + Forced bool