sse

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricActiveConnections = "active_connections"
	MetricEventsSent        = "events_sent_total"
	MetricConnectionErrors  = "connection_errors_total"
	MetricEventLatency      = "event_delivery_latency_seconds"
	MetricKeepalivesSent    = "keepalives_sent_total"

	LabelEventType = "event_type"
	LabelErrorType = "error_type"

	ErrorTypeBufferFull   = "buffer_full"
	ErrorTypeNoConnection = "no_connection"
	ErrorTypeWriteFailure = "write_failure"
	ErrorTypeMarshalError = "marshal_error"
)

Metric constants

Variables

View Source
var Module = fx.Module(
	"sse",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("sse")
	}),
	fx.Provide(
		newMetrics,
		fx.Private,
	),
	fx.Provide(
		NewService,
	),
	fx.Invoke(func(lc fx.Lifecycle, svc *Service) {
		lc.Append(fx.Hook{
			OnStop: func(ctx context.Context) error {
				return svc.Close(ctx)
			},
		})
	}),
)

Functions

func WithKeepAlivePeriod

func WithKeepAlivePeriod(d time.Duration) configOption

Types

type Config

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

func NewConfig

func NewConfig(opts ...configOption) Config

func (*Config) KeepAlivePeriod

func (c *Config) KeepAlivePeriod() time.Duration

type Event

type Event struct {
	Type smsgateway.PushEventType `json:"event"`
	Data map[string]string        `json:"data"`
}

type Service

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

func NewService

func NewService(config Config, logger *zap.Logger, metrics *metrics) *Service

func (*Service) Close

func (s *Service) Close(_ context.Context) error

func (*Service) Handler

func (s *Service) Handler(deviceID string, c *fiber.Ctx) error

func (*Service) Send

func (s *Service) Send(deviceID string, event Event) error

Jump to

Keyboard shortcuts

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