types

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package types exports public types for lifecycle.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRestartPolicy = ServiceRestartPolicy{
	RestartOnFailure: true,
	RestartCount:     4,
	RestartDelay:     time.Millisecond * 100,
}

DefaultRestartPolicy is a default restart policy for services.

Functions

This section is empty.

Types

type ServiceConfig

type ServiceConfig struct {
	// StartupHook is a hook that is called when service is started.
	StartupHook StartupHook
	// ShutdownHook is a hook that is called when service is stopped.
	ShutdownHook ShutdownHook

	// Name of the service.
	Name string
	// RestartPolicy is a restart policy for service.
	RestartPolicy ServiceRestartPolicy
}

ServiceConfig represents lifecycle service configuration.

type ServiceRestartPolicy

type ServiceRestartPolicy struct {
	// RestartOnFailure indicates that service should be restarted on failure.
	RestartOnFailure bool
	// RestartDelay is a delay between restart attempts.
	RestartDelay time.Duration
	// RestartCount is a maximum number of restart attempts.
	RestartCount int
}

ServiceRestartPolicy represents rules for service restart on runtime errors.

type ServiceStatus

type ServiceStatus int

ServiceStatus represents current status of service.

const (
	ServiceStatusInit ServiceStatus = iota
	ServiceStatusStarting
	ServiceStatusRunning
	ServiceStatusStopping
	ServiceStatusStopped
	ServiceStatusError
)

All service statuses values.

func (ServiceStatus) String

func (i ServiceStatus) String() string

type ShutdownHook

type ShutdownHook func(context.Context) error

ShutdownHook is a hook that is called when service is stopped. This hook is called with specified shutdown context.

type StartupHook

type StartupHook func(context.Context, chan<- error) error

StartupHook is a hook that is called when service is started. This hook is called with specified startup context. Error chanel is provided to report health status of service. If error is sent to error channel service could be restarted depends on configuration.

Jump to

Keyboard shortcuts

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