Documentation
¶
Overview ¶
Package ssefiber provides adapter-neutral SSE route helpers backed by the transport-neutral eventstream package. The package owns SSE framing, resume handling, retry directives, heartbeat control frames, stream-gap signaling, and route mounting concerns; it does not change the generic stream contract itself.
Mount supports streaming go-router backends. MountFiber retains the legacy Fiber v2 entry point. Hosts cancel owned stream contexts before shutdown; transport reader closure cancels subscriptions on client disconnect.
Index ¶
- func Handler(opts ...Option) router.HandlerFunc
- func Mount[T any](r router.Router[T], opts ...Option) error
- func MountFiber(r router.Router[*fiber.App], opts ...Option) error
- type Config
- type Option
- func WithAllowClientTuning(allow bool) Option
- func WithCursorQueryParam(name string) Option
- func WithHeartbeatBounds(min, max time.Duration) Option
- func WithHeartbeatInterval(interval time.Duration) Option
- func WithHeartbeatQueryParam(name string) Option
- func WithMiddlewares(middlewares ...router.MiddlewareFunc) Option
- func WithPath(path string) Option
- func WithRetryBounds(min, max time.Duration) Option
- func WithRetryInterval(interval time.Duration) Option
- func WithRetryQueryParam(name string) Option
- func WithScopeResolver(resolver ScopeResolver) Option
- func WithStream(stream eventstream.Stream) Option
- type ScopeResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(opts ...Option) router.HandlerFunc
Handler returns the public go-router handler surface for SSE.
Types ¶
type Config ¶
type Config struct {
Path string
Stream eventstream.Stream
ScopeResolver ScopeResolver
Middlewares []router.MiddlewareFunc
HeartbeatInterval time.Duration
RetryInterval time.Duration
CursorQueryParam string
HeartbeatQueryParam string
RetryQueryParam string
AllowClientTuning bool
MinHeartbeatInterval time.Duration
MaxHeartbeatInterval time.Duration
MinRetryInterval time.Duration
MaxRetryInterval time.Duration
}
Config defines the public SSE mount and handler surface.
type Option ¶
type Option func(*Config)
Option mutates SSE mount and handler configuration.
func WithAllowClientTuning ¶
WithAllowClientTuning enables opt-in query-param tuning for heartbeat/retry.
func WithCursorQueryParam ¶
WithCursorQueryParam overrides the fallback cursor query parameter name.
func WithHeartbeatBounds ¶
WithHeartbeatBounds overrides accepted heartbeat tuning limits.
func WithHeartbeatInterval ¶
WithHeartbeatInterval overrides the default heartbeat interval.
func WithHeartbeatQueryParam ¶
WithHeartbeatQueryParam overrides the heartbeat tuning query parameter name.
func WithMiddlewares ¶
func WithMiddlewares(middlewares ...router.MiddlewareFunc) Option
WithMiddlewares appends middleware only for the mounted SSE route.
func WithRetryBounds ¶
WithRetryBounds overrides accepted retry tuning limits.
func WithRetryInterval ¶
WithRetryInterval overrides the default retry interval.
func WithRetryQueryParam ¶
WithRetryQueryParam overrides the retry tuning query parameter name.
func WithScopeResolver ¶
func WithScopeResolver(resolver ScopeResolver) Option
WithScopeResolver configures request-to-scope resolution.
func WithStream ¶
func WithStream(stream eventstream.Stream) Option
WithStream configures the backing event stream.
type ScopeResolver ¶
type ScopeResolver func(router.Context) (eventstream.Scope, error)
ScopeResolver maps request state into an eventstream subscription scope.