Help us shape the future of Go! Take the 2026 Go Developer Survey

worker

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package worker uploads the generated Worker that serves a domain's MTA-STS policy, and binds it to mta-sts.<domain>.

Index

Constants

View Source
const CompatibilityDate = "2025-01-01"

CompatibilityDate pins the Workers runtime behaviour for the generated script. It is a constant so that redeploying an unchanged policy produces byte-identical source and therefore no diff.

Variables

This section is empty.

Functions

func PolicyScript

func PolicyScript(policy string) string

PolicyScript renders an ES module Worker serving the policy at the well-known path and 404ing everything else.

func ScriptName

func ScriptName(domain string) (string, error)

ScriptName is the Worker script name for a domain. Dots are not allowed in a script name, so they become hyphens; that alone is not injective (my.site.com and my-site.com would collide), so a hash of the original domain is appended. It also validates the result against Cloudflare's constraints, since the caller cannot recover from a rejected name any other way.

Types

type Deployer

type Deployer struct {
	// contains filtered or unexported fields
}

func New

func New(api *cfapi.Client, accountID string) *Deployer

func (*Deployer) AttachDomain

func (d *Deployer) AttachDomain(ctx context.Context, hostname, zoneID, scriptName string) error

AttachDomain binds hostname to a script. Cloudflare provisions the DNS record and the certificate, which is why mailctl publishes no record for this name.

func (*Deployer) DomainAttached

func (d *Deployer) DomainAttached(ctx context.Context, hostname, zoneID, service string) (bool, error)

DomainAttached reports whether a custom domain is already bound to the given Worker service. Matching on hostname and zone alone would report a hostname bound to a different Worker as attached, and mailctl would never rebind it to the one it actually manages.

func (*Deployer) ScriptMatches

func (d *Deployer) ScriptMatches(ctx context.Context, name, source string) (bool, error)

ScriptMatches reports whether the deployed script is byte-identical to source. A script that does not exist reports false, not an error.

func (*Deployer) Upload

func (d *Deployer) Upload(ctx context.Context, name, source string) error

Upload replaces the script. The upload is a multipart form with a JSON metadata part naming the entry module, plus the module itself.

Jump to

Keyboard shortcuts

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