Documentation
¶
Overview ¶
Package deploy pushes a function to a hosted altengine functions instance.
The server does no build and resolves no imports: it stores exactly the one ES module it is given. So bundling happens HERE — esbuild flattens the entry file and everything it imports into a single module before upload. That keeps the runtime free of a package resolver, and means what you tested locally is byte-for-byte what runs.
Index ¶
- func Bundle(entry string, minify bool) (string, error)
- type Config
- func (c Config) Activate(fnName string, version int) error
- func (c Config) Delete(fnName string) error
- func (c Config) DeleteVersion(fnName string, version int) error
- func (c Config) Deploy(fnName, code string, grants map[string]string, schedules *[]string, ...) (*Result, error)
- func (c Config) List() (*Listing, error)
- func (c Config) Pull(fnName string, version int) (string, error)
- func (c Config) Versions(fnName string) ([]Version, int, error)
- type Listing
- type Result
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
BaseURL string // e.g. https://api.altengine.net
APIKey string
Instance string // the functions instance name, as shown in the console
}
Config is everything needed to reach an instance. Flags win over environment.
func (Config) Activate ¶
Activate points traffic at an already-deployed version. No upload — a rollback moves a pointer, so it is fast and cannot fail halfway.
func (Config) Delete ¶
Delete removes a function: it stops serving, its schedules stop, and every stored version goes.
func (Config) DeleteVersion ¶
DeleteVersion removes one stored version that is not being served.
func (Config) Deploy ¶
func (c Config) Deploy(fnName, code string, grants map[string]string, schedules *[]string, activate bool) (*Result, error)
Deploy uploads code as a new version of the named function.
grants is only sent when non-empty: an omitted grants map INHERITS what the function already has, so a plain redeploy of source never silently drops a function's access to its datastore.
type Listing ¶
type Listing struct {
Instance string `json:"instance"`
Host string `json:"host"`
Functions []struct {
Name string `json:"name"`
ActiveVersion int `json:"active_version"`
Grants map[string]string `json:"grants"`
Schedules []string `json:"schedules"`
CPUMs int `json:"cpu_ms"`
URL string `json:"url"`
} `json:"functions"`
}
Listing is what /v1/functions/:instance returns.
type Result ¶
type Result struct {
Name string `json:"name"`
Version int `json:"version"`
SizeBytes int `json:"size_bytes"`
Active bool `json:"active"`
}
Result is the server's answer to a successful deploy.
type Version ¶
type Version struct {
Version int `json:"version"`
SizeBytes int `json:"size_bytes"`
SHA256 string `json:"sha256"`
CreatedAt int64 `json:"created_at"`
// The address that runs this version, `{slug}--v{n}-fn`. Empty when the server has no
// tenant host configured.
URL string `json:"url"`
}
Version is one row of deploy history.