courier

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package courier is the service's work: an activity per kind of delivery — SendMail, SendPush (with Subscribe and Unsubscribe for FCM topics), SendWebPush (with WebPushKey for the browsers) and Send<Kind> for every extension provider — each delivering at once through the channel the message names or the kind's default. It keeps nothing: a temporary failure goes back to the caller, whose retry policy decides; a final one is NonRetryable and, when the provider refused it, the event courier.Refused; a provider's Retry-After becomes activity.RetryAfter. Every outcome is an audit record.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyTokens = errors.New("courier: at most 1000 tokens per call")
	ErrTopicRequest  = errors.New("courier: a topic and tokens are required")
	// ErrDuplicateKind: two providers in use deliver the same kind.
	ErrDuplicateKind = errors.New("courier: two providers of one kind")
)

Errors of a subscription call; final.

Functions

func ActivityName

func ActivityName(kind string) string

ActivityName of an extension kind: Send<Kind> in CamelCase.

Types

type Courier

type Courier struct {
	deps.Component
	// contains filtered or unexported fields
}

Courier is the component.

func New

func New(
	parent deps.Scope, chs *channels.Channels, set Settings, extensions map[string]*channels.Extension,
) (*Courier, error)

New declares the activities under parent: the built-in ones, and Send<Kind> for every extension kind among the channels.

func (*Courier) Refused added in v0.0.13

func (c *Courier) Refused() event.Ref[*couriereventsv1.Refused]

Refused is the event of a provider's final refusal.

func (*Courier) SendMail

func (c *Courier) SendMail(ctx context.Context, msg mail.Message) (MailResult, error)

SendMail is the courier.SendMail activity.

func (*Courier) SendPush

func (c *Courier) SendPush(ctx context.Context, msg push.Message) (PushResult, error)

SendPush is the courier.SendPush activity.

func (*Courier) SendWebPush added in v0.0.7

func (c *Courier) SendWebPush(ctx context.Context, msg webpush.Message) (WebPushResult, error)

SendWebPush is the courier.SendWebPush activity.

func (*Courier) Subscribe

func (c *Courier) Subscribe(ctx context.Context, req TopicRequest) (TopicResult, error)

Subscribe is the courier.Subscribe activity.

func (*Courier) Unsubscribe

func (c *Courier) Unsubscribe(ctx context.Context, req TopicRequest) (TopicResult, error)

Unsubscribe is the courier.Unsubscribe activity.

func (*Courier) WebPushKey added in v0.0.7

WebPushKey is the courier.WebPushKey activity.

type MailResult

type MailResult struct {
	Channel   string `json:"channel"`
	MessageID string `json:"message_id"        schemapb:"description=The Message-ID header of the mail"`
	DryRun    bool   `json:"dry_run,omitempty"`
}

MailResult is SendMail's answer.

type PushResult

type PushResult struct {
	Channel string `json:"channel"`
	Name    string `json:"name"              schemapb:"description=FCM's message name"`
	DryRun  bool   `json:"dry_run,omitempty"`
}

PushResult is SendPush's answer.

type Settings

type Settings struct {
	Limits mail.Limits
	// Live: accept and record, deliver nothing.
	DryRun config.Live[bool]
}

Settings of the courier.

type TopicRequest

type TopicRequest struct {
	Channel string   `json:"channel,omitempty" schemapb:"description=Push channel, else the default"`
	Topic   string   `json:"topic"`
	Tokens  []string `json:"tokens"            schemapb:"description=Device tokens, at most 1000"`
}

TopicRequest changes a topic's subscriptions.

type TopicResult

type TopicResult struct {
	Channel string            `json:"channel"`
	Results []fcm.TokenResult `json:"results"`
}

TopicResult is every token's outcome.

type WebPushKeyRequest added in v0.0.7

type WebPushKeyRequest struct {
	Channel string `json:"channel,omitempty" schemapb:"description=Web Push channel, else the default"`
}

WebPushKeyRequest names a Web Push channel.

type WebPushKeyResult added in v0.0.7

type WebPushKeyResult struct {
	Channel string `json:"channel"`
	// PublicKey is the applicationServerKey of PushManager.subscribe();
	// empty for a log channel.
	PublicKey string `json:"public_key" schemapb:"description=applicationServerKey of PushManager.subscribe()"`
}

WebPushKeyResult is the key browsers subscribe with.

type WebPushResult added in v0.0.7

type WebPushResult struct {
	Channel string `json:"channel"`
	ID      string `json:"id"                schemapb:"description=The push service's id of the message (its Location)"`
	DryRun  bool   `json:"dry_run,omitempty"`
}

WebPushResult is SendWebPush's answer.

Jump to

Keyboard shortcuts

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