supervisor

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Overview

Package supervisor contains entrypoint replacement for Neo4j docker image. Expose HTTP server which can be used to run migrations and start or stop Neo4j server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(cfg *config.Config) error

Start the HTTP Supervisor server, Neo4j DB and load initial data. Returns error when config is not valid.

Types

type Neo4jState

type Neo4jState string
const (
	Stopped  Neo4jState = "Stopped"
	Failed   Neo4jState = "Failed"
	Starting Neo4jState = "Starting"
	Updating Neo4jState = "Updating Data"
	Stopping Neo4jState = "Stopping"
	Running  Neo4jState = "Running"
)

type Neo4jWrapper

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

Neo4jWrapper wraps command and helper functions to operate with Neo4j server together with utilities.

func NewNeo4jWrapper

func NewNeo4jWrapper(ctx context.Context, cfg *config.Config, log *logrus.Entry) (*Neo4jWrapper, error)

NewNeo4jWrapper creates wrapper for handling Neo4j and utilities.

func (*Neo4jWrapper) AllStates

func (w *Neo4jWrapper) AllStates() map[string]any

AllStates returns the current states of main service and all utilities.

func (*Neo4jWrapper) ReadOnlySession added in v0.1.1

func (w *Neo4jWrapper) ReadOnlySession(ctx context.Context) neo4j.SessionWithContext

ReadOnlySession returns new Neo4j session for custom Cypher calls.

func (*Neo4jWrapper) RefreshData

func (w *Neo4jWrapper) RefreshData(
	targetVersion *migrator.TargetVersion,
	dryRun, clean bool,
	batchName migrator.Batch,
) error

RefreshData imports all data from schema import folder.

func (*Neo4jWrapper) Restart

func (w *Neo4jWrapper) Restart() error

Restart call Stop, Wait and Start.

func (*Neo4jWrapper) Start

func (w *Neo4jWrapper) Start() error

Start the main neo4j process.

func (*Neo4jWrapper) State

func (w *Neo4jWrapper) State() (Neo4jState, error)

State returns the current service state.

func (*Neo4jWrapper) Stop

func (w *Neo4jWrapper) Stop() error

Stop the main neo4j process, but does not wait. Use WaitAll() to wait process is exited. To stop all started processes use StopAll() and WaitAll() optionally.

func (*Neo4jWrapper) StopAll

func (w *Neo4jWrapper) StopAll() error

StopAll sends Interrupt signal for all processes and then stops main Neo4j process, but does not wait for exit.

func (*Neo4jWrapper) Wait

func (w *Neo4jWrapper) Wait() error

Wait waits until main process is exited. To wait for utilities use WaitAll.

func (*Neo4jWrapper) WaitAll

func (w *Neo4jWrapper) WaitAll() error

WaitAll waits until main process and all scripts exit.

func (*Neo4jWrapper) WaitForNeo4j

func (w *Neo4jWrapper) WaitForNeo4j() (err error)

WaitForNeo4j blocks execution until Neo4j is ready, or returns error if service is not starting. Also returns error after 5 minutes of trying to wait.

type TSCmd

type TSCmd struct {
	exec.Cmd
	// contains filtered or unexported fields
}

TSCmd is embedding os/exec.Cmd and adding WaitTS (wait thread safe) function.

func StartCmd

func StartCmd(log *logrus.Entry, stdin io.Reader, args ...string) (cmd *TSCmd, err error)

StartCmd starts command inside wrapper with thread-safe Wait method. First element of args array is taken as command, others are used as arguments of the command. Also stdout and stderr are redirected into log. Argument stdin is redirected into the command, if is set.

func (*TSCmd) WaitTS

func (c *TSCmd) WaitTS() error

WaitTS (Wait Thread Safe) will wait until command stops. This can be called multiple times with same result.

Original Wait() on original os/exec.Cmd when called multiple times can return different results, depends on which lifecycle of command the Wait() is called.

Jump to

Keyboard shortcuts

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