boot

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applicaiton added in v1.1.0

type Applicaiton interface {
	// Start starts the application. This is a blocking, not thread-safe call.
	// This method handles SIGTERM/SIGINT signals and automatically shutting down the app.
	// The provided user context can be used to signal application to stop gracefully.
	Run(ctx context.Context) error
}

Application represents an application that supports graceful boot/shutdown.

func NewApplicationForService added in v1.1.0

func NewApplicationForService(service Service, shutdownTimeout time.Duration) Applicaiton

NewApplicationForService creates a new Application from the given (uber) Service, that is usually constructed with Sequentially or Simultaneously (or combination). A commonly recommended shutdownTimeout range is 5-15 seconds.

type HttpServer added in v1.1.0

type HttpServer interface {
	Service
}

HttpServer is a Service wrapper for the standard http.Server.

func NewHttpServer added in v1.1.0

func NewHttpServer(server *http.Server) HttpServer

type Service

type Service interface {
	// Start() starts the service, returns nil if the service was already started.
	// The service is treated as started if the function returned no error.
	// Also, see the general rules for the Service interface.
	Start(context.Context) error

	// Stop() stops the service, returns nil if the service was already stopped.
	// After calling Stop(), the service is treated as stopped regardless of returned error.
	// Also, see the general rules for the Service interface.
	Stop(context.Context) error
}

Service interface defines the contract for any service managed by go-boot. General rules for Start/Stop functions: * Implementation must be thread-safe. * The context values passed to Start/Stop must not be kept and used ever after. * If the context is cancelled, Start/Stop must terminate immediately.

func Sequentially

func Sequentially(services ...Service) Service

Sequentially() creates a Service that delegates invocations to the given services in the sequential order. All the general rules defined boot.Service interface are applied.

func Simultaneously

func Simultaneously(services ...Service) Service

Simultaneously() creates a Service that delegates invocations to the given services simultaneously. All the general rules defined boot.Service interface are applied.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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