hosting

package
v0.22.8 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ShutdownTimeout = time.Second * 10

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandService

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

CommandService is a Service that runs an external command.

func NewCommandService

func NewCommandService(name string, cmd *exec.Cmd, executor process.Executor, options CommandServiceRunOptions, log logr.Logger) *CommandService

func (*CommandService) Name

func (s *CommandService) Name() string

func (*CommandService) Run

func (s *CommandService) Run(ctx context.Context) error

type CommandServiceRunOptions

type CommandServiceRunOptions uint32
const (
	CommandServiceRunOptionShowStderr    CommandServiceRunOptions = 0x1
	CommandServiceRunOptionDontTerminate CommandServiceRunOptions = 0x2
)

type Host

type Host struct {
	// Slice of services to run. Started in order.
	Services []Service

	// The logger to be used by the host
	Logger logr.Logger

	// TimeoutFunc allows you to control the timeout behavior for testing
	TimeoutFunc func()
}

Host manages the lifetimes and starting of Services.

func (*Host) Run

func (host *Host) Run(ctx context.Context, lifecycleMsgs chan<- LifecycleMessage) error

Run launches all services and blocks until all services shut down or timeout occurs.

func (*Host) RunAsync

func (host *Host) RunAsync(ctx context.Context) (<-chan error, <-chan LifecycleMessage)

type LifecycleMessage

type LifecycleMessage struct {
	ServiceName string
	Err         error
}

LifecycleMessage is a message returned when a service terminates.

type Service

type Service interface {
	// Name returns the name of the service.
	Name() string

	// Run runs the service as a blocking operation.
	Run(ctx context.Context) error
}

Service is an abstraction for a long-running subsystem of some kind.

Jump to

Keyboard shortcuts

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