Documentation
¶
Overview ¶
Package courier is the courier service as a library: Main runs it, with the providers a custom build compiles in.
func main() { courier.Main(courier.WithProvider("smsc", smsc.New())) }
The stock binary (cmd/courier) is Main with nothing added. A provider in another language runs as a plugin (package plugin) the configuration names by address.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrContractChanged = errors.New("changed its contract since courier started: restart courier to take it")
ErrContractChanged: the plugin now describes another kind or other schemas than courier declared at startup.
var ErrProviderName = errors.New("courier: provider name used twice")
ErrProviderName: a provider name is used twice.
Functions ¶
Types ¶
type Config ¶
type Config struct {
config.Backplane `json:"backplane"`
// Channels by name; each has exactly one provider.
Channels channels.Config `json:"channels"`
// Plugins by name: providers courier dials.
Plugins map[string]channels.Plugin `json:"plugins,omitempty"`
// Defaults: the channel of a kind (mail, push, a provider's) when a
// message names none; a kind with one channel needs no default.
Defaults map[string]string `json:"defaults,omitempty"`
// DryRun records deliveries without sending them; live.
DryRun config.Live[bool] `json:"dry_run" schemapb:"default=false;description=Record deliveries, send nothing"`
// MaxMessageBytes bounds a mail's bodies and attachments.
MaxMessageBytes int64 `json:"max_message_bytes" schemapb:"default=26214400;gte=4096"`
// MaxRecipients bounds a mail's to + cc + bcc.
MaxRecipients int64 `json:"max_recipients" schemapb:"default=100;gte=1;lte=1000"`
}
Config is the whole configuration: file (BACKPLANE_CONFIG_FILE) < env COURIER_* (BACKPLANE_* for the SDK block) < Consul KV for Live fields.
type Option ¶
type Option func(*options)
Option configures Main.
func WithProvider ¶
WithProvider compiles p in under name: channels use it as {provider: {name: <name>}}.
func WithTokenSource ¶
func WithTokenSource(ts oauth2.TokenSource) Option
WithTokenSource authorizes every FCM channel with ts instead of its credentials (tests, a sidecar issuing tokens).
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
courier
command
courier is a Backplane tool service: it delivers rendered messages — mail, push, and whatever a provider plugin adds — through the channels of an installation.
|
courier is a Backplane tool service: it delivers rendered messages — mail, push, and whatever a provider plugin adds — through the channels of an installation. |
|
examples
|
|
|
smsplugin
command
smsplugin is an example courier plugin: an SMS "gateway" that logs what it would send.
|
smsplugin is an example courier plugin: an SMS "gateway" that logs what it would send. |
|
internal
|
|
|
admin
Package admin is courier's internal API: the console module's channel list and check, served on the platform port behind the internal secret.
|
Package admin is courier's internal API: the console module's channel list and check, served on the platform port behind the internal secret. |
|
channels
Package channels holds the installation's channels: their configuration (exactly one provider each), the runtime of each (pool, rate, timeout) and which channel a kind uses by default.
|
Package channels holds the installation's channels: their configuration (exactly one provider each), the runtime of each (pool, rate, timeout) and which channel a kind uses by default. |
|
courier
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.
|
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. |
|
fcm
Package fcm is the built-in push provider: FCM HTTP v1 per channel (a Firebase project) with OAuth2 from a service account, and topic subscriptions through the Instance ID API.
|
Package fcm is the built-in push provider: FCM HTTP v1 per channel (a Firebase project) with OAuth2 from a service account, and topic subscriptions through the Instance ID API. |
|
fcm/fcmtest
Package fcmtest is a fake FCM endpoint for tests (HTTP v1 sends and Instance ID subscriptions): it records what it receives and answers by rules on the target.
|
Package fcmtest is a fake FCM endpoint for tests (HTTP v1 sends and Instance ID subscriptions): it records what it receives and answers by rules on the target. |
|
mail
Package mail is the service's domain: the message a caller hands to courier.SendMail, its checks and limits, address hashing and the MIME it becomes.
|
Package mail is the service's domain: the message a caller hands to courier.SendMail, its checks and limits, address hashing and the MIME it becomes. |
|
netguard
Package netguard keeps courier's posts to URLs products hand it (Web Push endpoints, webhooks) off the installation's own network.
|
Package netguard keeps courier's posts to URLs products hand it (Web Push endpoints, webhooks) off the installation's own network. |
|
push
Package push is the push domain: the message a caller hands to courier.SendPush, its checks, token hashing and the FCM HTTP v1 message it becomes.
|
Package push is the push domain: the message a caller hands to courier.SendPush, its checks, token hashing and the FCM HTTP v1 message it becomes. |
|
smtp
Package smtp is the built-in mail provider: one SMTP relay per channel, a connection per delivery, 5xx replies final.
|
Package smtp is the built-in mail provider: one SMTP relay per channel, a connection per delivery, 5xx replies final. |
|
smtp/smtptest
Package smtptest is an SMTP server for tests: it keeps what it receives and refuses the recipients it is told to.
|
Package smtptest is an SMTP server for tests: it keeps what it receives and refuses the recipients it is told to. |
|
ui
Package ui carries the console module: web/dist/plugin copied here by `make web` and embedded into the binary.
|
Package ui carries the console module: web/dist/plugin copied here by `make web` and embedded into the binary. |
|
webhook
Package webhook is the built-in webhook provider: a signed HTTP POST of JSON to a URL the product names on every call, signed per Standard Webhooks (webhook-id, webhook-timestamp, webhook-signature: HMAC-SHA256 with the secret the product holds for that receiver).
|
Package webhook is the built-in webhook provider: a signed HTTP POST of JSON to a URL the product names on every call, signed per Standard Webhooks (webhook-id, webhook-timestamp, webhook-signature: HMAC-SHA256 with the secret the product holds for that receiver). |
|
webpush
Package webpush is the built-in Web Push provider: the standard protocol every browser's push service speaks (RFC 8030), the payload encrypted to the subscription (RFC 8291) and the sender identified by its VAPID key (RFC 8292).
|
Package webpush is the built-in Web Push provider: the standard protocol every browser's push service speaks (RFC 8030), the payload encrypted to the subscription (RFC 8291) and the sender identified by its VAPID key (RFC 8292). |
|
Package plugin connects courier and a provider running as its own service over courier.plugin.v1.ProviderService.
|
Package plugin connects courier and a provider running as its own service over courier.plugin.v1.ProviderService. |
|
proto
|
|
|
Package provider is what a courier provider implements: one way to deliver messages courier does not know.
|
Package provider is what a courier provider implements: one way to deliver messages courier does not know. |