push

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"vef:push",
	fx.Provide(
		NewHub,
		fx.Annotate(
			NewRelay,
			fx.ParamTags(``, ``, ``, ``, `optional:"true"`),
		),
		newNotifier,
		fx.Annotate(
			NewMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			newRevocationListener,
			fx.ResultTags(`group:"vef:security:session_revocation_listeners"`),
		),
	),
	fx.Invoke(registerLifecycle),
)

Functions

func NewMiddleware

func NewMiddleware(params MiddlewareParams) app.Middleware

NewMiddleware creates the push endpoint middleware. Returns nil while the endpoint is disabled.

Types

type Hub

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

Hub is the per-node connection registry and the push.Notifier implementation: it indexes live connections by user and fans each message out to the selected recipients through their writer queues.

func NewHub

func NewHub(cfg *config.PushConfig) *Hub

func (*Hub) Push

func (h *Hub) Push(_ context.Context, message push.Message, targets ...push.Target) error

Push implements push.Notifier for single-node deployments (the relay wraps deliver with cross-node publishing).

func (*Hub) Shutdown

func (h *Hub) Shutdown()

Shutdown refuses new registrations and closes every live connection with a going-away frame. Connection goroutines unregister themselves as their sockets wind down.

type Middleware

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

Middleware mounts the push WebSocket endpoint: an app.Middleware registering a real route (MCP precedent) that authenticates the handshake with the configured token mechanism before upgrading.

func (*Middleware) Apply

func (m *Middleware) Apply(router fiber.Router)

func (*Middleware) Name

func (*Middleware) Name() string

func (*Middleware) Order

func (*Middleware) Order() int

Order places the endpoint after the API engine and before the SPA fallback, alongside the integration inbound gateway and MCP.

type MiddlewareParams

type MiddlewareParams struct {
	fx.In

	Hub      *Hub
	Auth     security.AuthManager
	Store    security.SessionStore
	Config   *config.PushConfig
	Security *config.SecurityConfig
}

MiddlewareParams contains dependencies for creating the middleware.

type Relay

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

func NewRelay

func NewRelay(hub *Hub, cfg *config.PushConfig, appCfg *config.AppConfig, redisCfg *config.RedisConfig, client *redis.Client) (*Relay, error)

NewRelay builds the cross-node relay; nil when the endpoint is disabled or no Redis client is available (single-node deployments push through the hub directly). An active relay fails fast without an application name: the channel namespace is what keeps co-tenant applications apart, so an unnamed application must not come up silently sharing a channel.

func (*Relay) KickSessions

func (r *Relay) KickSessions(sessionIDs []string)

KickSessions closes the sessions' connections on every node. The publish is handed to the relay's bounded worker: kicks arrive through revocation call paths (logout, concurrent-login eviction) whose listener contract forbids blocking on Redis health, and a goroutine per kick would grow without bound under a Redis outage. A full queue drops the frame — the remote nodes' periodic sweep remains the net.

func (*Relay) Push

func (r *Relay) Push(ctx context.Context, message push.Message, targets ...push.Target) error

Push implements push.Notifier.

Jump to

Keyboard shortcuts

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