notifier

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ConsumerGroup = "notifier"

ConsumerGroup is the Kafka consumer group the notifier joins. All notifier replicas share it, so the broker splits partitions among them.

View Source
const ServiceName = "notifier service"

Variables

View Source
var (
	NotificationsEndPnt = "/v1/notifications"
)

Functions

This section is empty.

Types

type Service

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

Service consumes order events and (eventually) dispatches notifications. It is a background consumer with health/status HTTP endpoints and no domain REST API — the mirror image of the orders relay: relay drains outbox → broker; notifier consumes broker → processes → marks delivered.

func NewService

func NewService(authn auth.Authenticator,
	store store,
	consumer messaging.Consumer,
	sink Sink,
) *Service

NewService constructs the notifier. The listening port is the httpserver's concern, not the service's.

func (*Service) Notifications

func (h *Service) Notifications() httprouter.Handle

Notifications godoc @Summary List notifications @Description List the notifications derived from the outbox, newest events first. @Tags notifications @Produce json @Param undelivered query bool false "Only return notifications not yet delivered" @Success 200 {array} model.Notification @Failure 401 {object} errors.JSONError @Failure 500 {object} errors.JSONError @Security XAuthPassword @Router /v1/notifications [get]

func (*Service) RegisterHandlers

func (h *Service) RegisterHandlers() *httprouter.Router

RegisterHandlers exposes liveness/readiness and the notifications view. The notifier has no write API; its work happens in the consume loop (see Start). The probe mechanism is shared via httpserver; the notifier supplies its checks.

func (*Service) Start

func (h *Service) Start(startCtx context.Context) error

Start pings the broker, then launches the consume loop. Teardown is via context cancellation (worker.Runner): Poll blocks until events arrive, so only cancelling its context can interrupt it promptly.

func (*Service) Stop

func (h *Service) Stop() error

Stop cancels the consume loop and waits for it to exit. Idempotent.

type Sink

type Sink interface {
	Write(ctx context.Context, n *model.Notification) error
}

Sink writes notifications to an output.

func NewSink

func NewSink(filePath string) (Sink, error)

NewSink returns a terminal sink, tee'd to a JSON-lines file when filePath is non-empty.

Jump to

Keyboard shortcuts

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