Documentation
¶
Overview ¶
Package cdn holds what every edge provider shares: the provider contract, the purge history and the per-step setup result, so callers never branch on which CDN sits in front of an app.
Index ¶
Constants ¶
const ( TriggerPublish = "publish" TriggerDeploy = "deploy" TriggerRollback = "rollback" )
Purge triggers, so the history says why the cache was cleared.
const ( StatusOK = "ok" StatusWarn = "warn" StatusFail = "fail" StatusSkipped = "skipped" )
Step statuses, the same words the doctor checks use.
const ( StepProvider = "provider" StepSSLMode = "ssl_mode" StepDNS01 = "acme_dns01" StepClientIP = "client_address" StepDNSPlan = "dns_plan" StepApply = "apply" StepVerify = "verify" )
Setup step ids, in run order.
const EnvPurgeHistory = "APP_CDN_PURGE_HISTORY"
EnvPurgeHistory caps the purge records kept per app.
const ProviderCloudflare = "cloudflare"
ProviderCloudflare is the name the Cloudflare adapter reports.
const ScopeHosts = "hosts"
ScopeHosts is a purge of every URL under the app's hostnames.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fake ¶
type Fake struct {
ID string
Mode string
PurgeErr error
ModeErr error
// contains filtered or unexported fields
}
Fake is an in-memory Provider for tests and for providers not yet wired.
func (*Fake) PurgeHosts ¶
PurgeHosts records the hosts and returns PurgeErr.
type History ¶
type History struct {
// contains filtered or unexported fields
}
History keeps the newest purge records per app in memory.
func DefaultHistory ¶
func DefaultHistory() *History
DefaultHistory is the process-wide history the API writes and reads.
func NewHistory ¶
NewHistory returns a history keeping keep records per app; keep <= 0 reads the environment.
func (*History) Add ¶
func (h *History) Add(app string, r PurgeRecord)
Add stores r for app, newest first.
type Provider ¶
type Provider interface {
// Name is the stable provider id shown in status and history.
Name() string
// PurgeHosts clears the edge cache for every URL under each host in zone.
PurgeHosts(ctx context.Context, zone string, hosts []string) error
// SSLMode reads how the edge talks to the origin: off, flexible, full or strict.
SSLMode(ctx context.Context, zone string) (string, error)
}
Provider is the edge operations Levelrail needs from a CDN.
type PurgeRecord ¶
type PurgeRecord struct {
At time.Time `json:"at"`
Trigger string `json:"trigger"`
Scope string `json:"scope"`
Provider string `json:"provider"`
Zones []string `json:"zones"`
Hosts int `json:"hosts"`
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
}
PurgeRecord is one edge purge attempt for an app.
type SetupResult ¶
type SetupResult struct {
App string `json:"app"`
Provider string `json:"provider"`
DryRun bool `json:"dry_run"`
Applied bool `json:"applied"`
Status string `json:"status"`
Steps []Step `json:"steps"`
}
SetupResult is the answer to a setup run, usable as a wizard's state.
func (*SetupResult) Summarize ¶
func (r *SetupResult) Summarize()
Summarize sets Status to the worst step status: fail, then warn, else ok.