events

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricEnqueuedTotal = "enqueued_total"
	MetricSentTotal     = "sent_total"
	MetricFailedTotal   = "failed_total"

	LabelEvent        = "event"
	LabelDeliveryType = "delivery_type"
	LabelReason       = "reason"

	DeliveryTypePush    = "push"
	DeliveryTypeSSE     = "sse"
	DeliveryTypeUnknown = "unknown"

	FailureReasonSerializationError = "serialization_error"
	FailureReasonPublishError       = "publish_error"
	FailureReasonProviderFailed     = "provider_failed"

	EventTypeUnknown = "unknown"
)

Metric constants

Variables

View Source
var Module = fx.Module(
	"events",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("events")
	}),
	fx.Provide(newMetrics, fx.Private),
	fx.Provide(NewService),
	fx.Invoke(func(lc fx.Lifecycle, svc *Service, logger *zap.Logger, sh fx.Shutdowner) {
		ctx, cancel := context.WithCancel(context.Background())
		lc.Append(fx.Hook{
			OnStart: func(_ context.Context) error {
				go func() {
					if err := svc.Run(ctx); err != nil {
						logger.Error("Error running events service", zap.Error(err))
						if err := sh.Shutdown(fx.ExitCode(1)); err != nil {
							logger.Error("Failed to shutdown", zap.Error(err))
						}
					}
				}()
				return nil
			},
			OnStop: func(_ context.Context) error {
				cancel()
				return nil
			},
		})
	}),
)

Functions

This section is empty.

Types

type Event

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

func NewEvent

func NewEvent(eventType smsgateway.PushEventType, data map[string]string) Event

func NewMessageEnqueuedEvent

func NewMessageEnqueuedEvent() Event

func NewMessagesExportRequestedEvent

func NewMessagesExportRequestedEvent(since, until time.Time) Event

func NewSettingsUpdatedEvent

func NewSettingsUpdatedEvent() Event

func NewWebhooksUpdatedEvent

func NewWebhooksUpdatedEvent() Event

type Service

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

func NewService

func NewService(devicesSvc *devices.Service, sseSvc *sse.Service, pushSvc *push.Service, pubsub pubsub.PubSub, metrics *metrics, logger *zap.Logger) *Service

func (*Service) Notify

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

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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