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), SendWebhook (signed posts to receivers the product names) 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 ¶
- Variables
- func ActivityName(kind string) string
- type Courier
- func (c *Courier) Refused() event.Ref[*couriereventsv1.Refused]
- func (c *Courier) SendMail(ctx context.Context, msg mail.Message) (MailResult, error)
- func (c *Courier) SendPush(ctx context.Context, msg push.Message) (PushResult, error)
- func (c *Courier) SendWebPush(ctx context.Context, msg webpush.Message) (WebPushResult, error)
- func (c *Courier) SendWebhook(ctx context.Context, msg webhook.Message) (WebhookResult, error)
- func (c *Courier) Subscribe(ctx context.Context, req TopicRequest) (TopicResult, error)
- func (c *Courier) Unsubscribe(ctx context.Context, req TopicRequest) (TopicResult, error)
- func (c *Courier) WebPushKey(_ context.Context, req WebPushKeyRequest) (WebPushKeyResult, error)
- type MailResult
- type PushResult
- type Settings
- type TopicRequest
- type TopicResult
- type WebPushKeyRequest
- type WebPushKeyResult
- type WebPushResult
- type WebhookResult
Constants ¶
This section is empty.
Variables ¶
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 ¶
ActivityName of an extension kind: Send<Kind> in CamelCase.
Types ¶
type Courier ¶
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) SendWebPush ¶ added in v0.0.7
SendWebPush is the courier.SendWebPush activity.
func (*Courier) SendWebhook ¶ added in v0.0.18
SendWebhook is the courier.SendWebhook 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
func (c *Courier) WebPushKey(_ context.Context, req WebPushKeyRequest) (WebPushKeyResult, error)
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.
type WebhookResult ¶ added in v0.0.18
type WebhookResult struct {
Channel string `json:"channel"`
ID string `json:"id" schemapb:"description=The webhook-id the receiver got"`
DryRun bool `json:"dry_run,omitempty"`
}
WebhookResult is SendWebhook's answer.