environment

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment

type Environment struct {
	sync.Mutex

	Name string

	// Records the current state of the environment
	State State

	// List of all HTTP servers registered with our environment.
	Servers []*http.Server

	// Parent cancellable context
	Context context.Context
	Cancel  context.CancelFunc

	// Execution specific cancellable context
	ExecutionContext context.Context
	ExecutionCancel  context.CancelFunc

	Port    string
	Hasura  *hasura.Client
	Docker  *client.Client
	Config  nhost.Configuration
	Network string

	Watcher *watcher.Watcher
}

func (*Environment) CheckImages

func (e *Environment) CheckImages() error

Prepare func validates whether all required images exist, and downloads any one which doesn't.

func (*Environment) Cleanup

func (e *Environment) Cleanup()

func (*Environment) Execute

func (e *Environment) Execute() error

Explain what it does

func (*Environment) GetContainers

func (e *Environment) GetContainers() ([]types.Container, error)

returns the list of running containers whose names have specified prefix

func (*Environment) GetNetwork

func (e *Environment) GetNetwork() (string, error)

fetches ID of docker network by name

func (*Environment) HealthCheck

func (e *Environment) HealthCheck(ctx context.Context) error

Runs concurrent healthchecks on all Nhost services, which have a health check endpoint.

Also, supports process cancellation from contexts.

func (*Environment) Init

func (e *Environment) Init() error

func (*Environment) Prepare

func (e *Environment) Prepare() error

func (*Environment) PrepareNetwork

func (e *Environment) PrepareNetwork() error

If docker network exists -> fetches it's ID If it doesn't exist -> creates a new network

func (*Environment) PruneContainers

func (e *Environment) PruneContainers() error

prune unused containers

func (*Environment) PruneNetworks

func (e *Environment) PruneNetworks() error

prune unused networks

func (*Environment) RemoveNetwork

func (e *Environment) RemoveNetwork() error

removes a given network by ID

func (*Environment) Seed

func (e *Environment) Seed(path string) error

func (*Environment) Shutdown

func (e *Environment) Shutdown(purge bool, ctx context.Context) error

Stops, and additionally, removes all Nhost containers

func (*Environment) UpdateState

func (e *Environment) UpdateState(state State)

func (*Environment) WrapContainersAsServices

func (e *Environment) WrapContainersAsServices(containers []types.Container) error

Wraps a list of docker containers as *nhost.Services for respective environment.

type State

type State uint32

State represents current state of any structure

const (
	Unknown State = iota
	Initializing
	Intialized
	Executing
	Active
	ShuttingDown
	Inactive // keep it always last
)

State enumeration

Jump to

Keyboard shortcuts

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