Documentation
¶
Overview ¶
Package app runs a native executable built on the Wippy runtime.
An executable declares the packs it ships, the application command it starts and the state it owns. Its arguments are:
<exe> [--state DIR] run <app args...> ordinary start <exe> [--state DIR] update <hub args...> move the deployment forward <exe> [--state DIR] recover <app args...> boot the shipped packs afresh <exe> [--state DIR] wippy <cli args...> the Wippy CLI on the deployment
run, update, recover and wippy are reserved as the first argument by design. A bare invocation, or one whose first word is none of the four, selects run and passes every argument to the application. --state DIR or --state=DIR is the only argument the runner reads and it precedes the verb; everything after the verb belongs to the verb, including an argument shaped like a flag. Owned reports whether a state directory has an owner right now.
Package app hosts native applications built on the Wippy runtime.
Index ¶
- Variables
- func Main(e Executable)
- func NewApplicationStateError(operation, target string, cause error) apierror.Error
- func NewArtifactCacheError(detail, subject string, cause error) apierror.Error
- func NewBundledPackError(module, detail string, cause error) apierror.Error
- func NewCurrentDeploymentError(detail, path string, cause error) apierror.Error
- func NewDataEnvironmentBindingError(name, path string) apierror.Error
- func NewDeploymentApplicationError(root string) apierror.Error
- func NewDuplicateBundledModuleError(module string) apierror.Error
- func NewExistingDeploymentLockError(cause error) apierror.Error
- func NewInvalidApplicationNameError(name string) apierror.Error
- func NewMissingApplicationCommandError() apierror.Error
- func NewMissingBundledApplicationError(root string) apierror.Error
- func NewMissingStateDirectoryError() apierror.Error
- func NewModuleArtifactError(detail, module, version string, cause error) apierror.Error
- func NewOwnedStateError(cause error) apierror.Error
- func NewRetainedDeploymentError(detail, path string, cause error) apierror.Error
- func NewUpdateError(stage string, cause error) apierror.Error
- func NewUpdatedModuleError(detail, module string, cause error) apierror.Error
- func Owned(state string) (bool, error)
- func Run(ctx context.Context, e Executable, args []string) error
- type Bundle
- type Executable
- type Host
- type Launch
- type Op
- type Pack
- type Plan
Constants ¶
This section is empty.
Variables ¶
var ErrOwned apierror.Error = apierror.New(apierror.Conflict, "application state is owned")
ErrOwned means another invocation owns the selected application state. It says nothing about the owner's identity, readiness or ability to accept clients. Every owned-state failure matches it with errors.Is.
Functions ¶
func Main ¶
func Main(e Executable)
Main runs the executable with the process arguments under a context that ends on os.Interrupt or SIGTERM, reports a failure on stderr and exits 1.
func NewApplicationStateError ¶
NewApplicationStateError reports an operation on the application state directory that could not be completed.
func NewArtifactCacheError ¶
NewArtifactCacheError reports content that could not be placed in the application artifact cache.
func NewBundledPackError ¶
NewBundledPackError reports a shipped pack that does not carry the identity or the content the bundle declares for it. Detail names the part of the pack the executable and the bundle disagree about.
func NewCurrentDeploymentError ¶
NewCurrentDeploymentError reports a current record that does not name a deployment this state holds.
func NewDataEnvironmentBindingError ¶
NewDataEnvironmentBindingError reports a data environment entry whose name or relative path cannot bind to a path inside the state directory.
func NewDeploymentApplicationError ¶
NewDeploymentApplicationError reports a deployment that selects an application other than the one the executable ships.
func NewDuplicateBundledModuleError ¶
NewDuplicateBundledModuleError reports a module a bundle ships twice, which leaves the version the deployment selects undecided.
func NewExistingDeploymentLockError ¶
NewExistingDeploymentLockError reports a deployment directory whose lock file the executable cannot read.
func NewInvalidApplicationNameError ¶
NewInvalidApplicationNameError reports an executable whose application name cannot address a state directory.
func NewMissingApplicationCommandError ¶
NewMissingApplicationCommandError reports an executable that names no default application command.
func NewMissingBundledApplicationError ¶
NewMissingBundledApplicationError reports a bundle whose packs do not include the application it selects as its root.
func NewMissingStateDirectoryError ¶
NewMissingStateDirectoryError reports a --state flag that names no directory.
func NewModuleArtifactError ¶
NewModuleArtifactError reports a module record whose name, version or digest does not identify the artifact it pins.
func NewOwnedStateError ¶
NewOwnedStateError reports that another invocation holds the application state directory, carrying the lock attempt that observed it.
func NewRetainedDeploymentError ¶
NewRetainedDeploymentError reports a retained deployment that does not hold the immutable shape the artifact cache reads it as.
func NewUpdateError ¶
NewUpdateError reports an update stage that failed. The active deployment stays the one the state already selects.
func NewUpdatedModuleError ¶
NewUpdatedModuleError reports a module the update candidate selects whose artifact is missing or does not carry the content the lock pins.
func Owned ¶
Owned reports whether an invocation holds the state lock at the moment of the call. It is a snapshot: it opens the lock file only when that file already exists, releases the lock immediately and creates nothing, so it leaves an absent state absent. A host uses it to describe the state it is about to select; ErrOwned from Run is the authoritative answer.
Types ¶
type Bundle ¶
Bundle is the complete offline deployment shipped by an executable. Root selects the application; other packs are its locked dependencies.
func (Bundle) ID ¶
ID is the identity of the exact content an executable ships. It names the deployment directory the bundle seeds, so two executables carrying different packs seed and keep separate deployments in one state directory.
func (Bundle) Seed ¶
Seed installs an initial Wippy deployment in directory and returns its lock path. An existing deployment must select the same application and is never replaced, including when its version differs from the embedded pack. Directory contains deployment files. Store application databases separately.
type Executable ¶
type Executable struct {
Data map[string]string
Host Host
Name string
Command string
Bundle Bundle
Components []boot.Component
}
Executable is the complete declaration of a native Wippy application.
Name addresses the default state directory, ^[a-z][a-z0-9_-]*$
Command the application command an ordinary start runs
Bundle the packs the executable ships, immutable
Data application-owned environment variables bound to paths inside
the state directory; a variable the environment already carries
is a user override and keeps its value
Components the native components the host adds to the runtime
Host decides what an invocation does, optional
The declaration order below follows the memory layout the runtime pins.
type Launch ¶
Launch describes one invocation to the host. State is already resolved and absolute, and Explicit reports that --state selected it. Owned answers whether a state has an owner, including a state the host selects itself.
type Pack ¶
Pack is an exact published artifact, including its Hub identity. Digest is the SHA-256 of Data, with a sha256: prefix.
type Plan ¶
type Plan struct {
Run func(context.Context) error
Prepare func(context.Context) (boot.Config, func() error, error)
DefaultState string
Command string
Args []string
}
Plan is the host's decision for one launch. A non-empty DefaultState replaces the executable's default state when the invocation did not explicitly name one with --state. Command or Args replace the values the grammar selected. Run hands the whole launch to the host. Prepare opens host resources under the state lock and returns the configuration they need together with the close that releases them.