provider

package
v0.0.16 Latest Latest
Warning

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

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

Documentation

Overview

Package provider is what a courier provider implements: one way to deliver messages courier does not know. A Go provider is compiled into a custom courier binary (courier.Main(courier.WithProvider(p))); one in any language runs as a plugin serving courier.plugin.v1.ProviderService (package plugin serves a Go Provider that way).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Name string
	// Settings as JSON, valid against Descriptor.Settings.
	Settings []byte
}

Channel is one configured channel of the provider's kind.

type Delivery

type Delivery struct {
	Channel Channel
	// Message as JSON, valid against Descriptor.Message.
	Message []byte
	// IdempotencyKey is the same for every attempt of one delivery.
	IdempotencyKey string
	// Attempt is 1 for the first.
	Attempt int
}

Delivery is one message to send.

type Descriptor

type Descriptor struct {
	// Kind: [a-z][a-z0-9_]*; the activity is Send<Kind> (SendSmsc).
	Kind        string
	Description string
	// Settings of a channel; fields marked secret are masked by courier.
	Settings *sp.Schema
	// Message: the activity's input (courier adds an optional channel).
	Message *sp.Schema
	// Result: the activity's output; nil: {id}.
	Result *sp.Schema
}

Descriptor is what a provider delivers and the shapes it takes.

type Error

type Error struct {
	Message    string
	Code       string
	Permanent  bool
	RetryAfter time.Duration
}

Error is why a delivery or a check failed: final or not, and how long to wait before retrying when the provider said so. Any other error is retried by the binding's policy.

func Later

func Later(code, message string, after time.Duration) *Error

Later is a failure to retry no sooner than after.

func Permanent

func Permanent(code, message string) *Error

Permanent is a final failure.

func (*Error) Error

func (e *Error) Error() string

type Provider

type Provider interface {
	Describe(ctx context.Context) (Descriptor, error)
	// Check a channel against the provider without delivering.
	Check(ctx context.Context, ch Channel) error
	// Send one message; the result is JSON (valid against
	// Descriptor.Result); a failure should be an *Error.
	Send(ctx context.Context, d Delivery) ([]byte, error)
}

Provider delivers messages of one kind.

Jump to

Keyboard shortcuts

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