node

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_NAME_PATTERN = "^[a-z][a-z0-9-]*$"
)

Variables

View Source
var (
	ErrInvalidAppName                 = errors.New("invalid application name")
	ErrAppAlreadyDeployed             = errors.New("application is already deployed")
	ErrAppAlreadyBeingDeployed        = errors.New("application is already being deployed")
	ErrAppStillStopping               = errors.New("application is still stopping")
	ErrFailedAppModulePreparation     = errors.New("failed to prepare application module")
	ErrFailedToDeployApplication      = errors.New("failed to deploy application")
	ErrDeploymentIsBeingPerformed     = errors.New("deployment is being performed")
	ErrDeploymentAlreadyBeenPerformed = errors.New("deployment has already been performed")

	APPLICATION_STATUS_NAMES = map[ApplicationStatus]string{
		UndeployedApp:         "undeployed",
		DeployingApp:          "deploying",
		DeployedApp:           "deployed",
		GracefullyStoppingApp: "gracefully-stopping",
		GracefullyStoppedApp:  "gracefully-stopped",
		ErroneouslyStoppedApp: "erroneously-stopped",
		FailedToPrepareApp:    "failed-to-prepare",
	}
)

Functions

func IsAgentSet

func IsAgentSet() bool

func SetAgent

func SetAgent(a Agent)

Types

type Agent

type Agent interface {
	GetOrCreateApplication(name ApplicationName) (Application, error)
	GetApplication(name ApplicationName) (Application, bool)
}

Node agent, the implementation can be executed in-process or in another process on the same machine.

func GetAgent

func GetAgent() Agent

type Application

type Application interface {
	Status() ApplicationStatus
	TimedStatus() TimedApplicationStatus

	PrepareDeployment(ApplicationDeploymentParams) (ApplicationDeployment, error)

	//Stop gracefully stops the application.
	Stop()

	//UnsafelyStop unsafely stops the application.
	UnsafelyStop()
}

type ApplicationDeployment

type ApplicationDeployment interface {
	Perform() error
	Status() DeploymentStatus
}

An application deployment is a stateful representation of a deployment

type ApplicationDeploymentParams

type ApplicationDeploymentParams struct {
	AppMod  *core.Module
	BaseImg core.Image
	Project core.Project //temporary solution

	UpdateRunningApp bool
}

type ApplicationName

type ApplicationName string

func ApplicationNameFrom

func ApplicationNameFrom(s string) (ApplicationName, error)

type ApplicationStatus

type ApplicationStatus int
const (
	UndeployedApp ApplicationStatus = iota + 1
	DeployingApp
	DeployedApp
	GracefullyStoppingApp
	GracefullyStoppedApp
	ErroneouslyStoppedApp //execution error or error during stop
	FailedToPrepareApp
)

func (ApplicationStatus) String

func (s ApplicationStatus) String() string

type DeploymentStatus

type DeploymentStatus int
const (
	NotStartedDeployment DeploymentStatus = iota //default
	ActiveDeployment
	FailedDeployment
	SuccessfulDeployment
)

type TimedApplicationStatus

type TimedApplicationStatus struct {
	Status     ApplicationStatus
	ChangeTime time.Time
}

Jump to

Keyboard shortcuts

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