host

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package host provides Runa host primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	Check(ctx context.Context) Health
}

Checker can report host health.

type Drainer

type Drainer interface {
	Drain(ctx context.Context) error
}

Drainer can stop accepting new work before shutdown.

type HTTPConfig

type HTTPConfig struct {
	Name            string
	Addr            string
	Handler         http.Handler
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	IdleTimeout     time.Duration
	ShutdownTimeout time.Duration
}

HTTPConfig configures an HTTP host unit.

type HTTPServer

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

HTTPServer is a net/http based host unit.

func NewHTTP

func NewHTTP(config HTTPConfig) *HTTPServer

NewHTTP creates an HTTP host unit.

func (*HTTPServer) Addr

func (server *HTTPServer) Addr() string

Addr returns the listening address.

func (*HTTPServer) Check

func (server *HTTPServer) Check(context.Context) Health

Check returns HTTP host health.

func (*HTTPServer) Drain

func (server *HTTPServer) Drain(context.Context) error

Drain marks the HTTP server as draining.

func (*HTTPServer) Error

func (server *HTTPServer) Error() error

Error returns the last server error.

func (*HTTPServer) Name

func (server *HTTPServer) Name() string

Name returns the host name.

func (*HTTPServer) Start

func (server *HTTPServer) Start(ctx context.Context) error

Start starts the HTTP server.

func (*HTTPServer) Status

func (server *HTTPServer) Status() Status

Status returns the current HTTP host status.

func (*HTTPServer) Stop

func (server *HTTPServer) Stop(ctx context.Context) error

Stop gracefully shuts down the HTTP server.

type Health

type Health struct {
	Status  Status
	Message string
	Details map[string]any
}

Health describes the health state of a host unit.

type Info

type Info struct {
	Name   string
	Addr   string
	Status Status
}

Info is a host unit snapshot.

type Manager

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

Manager registers and controls host units.

func NewManager

func NewManager() *Manager

NewManager creates a host manager.

func (*Manager) Info

func (manager *Manager) Info() []Info

Info returns all host snapshots in registration order.

func (*Manager) Register

func (manager *Manager) Register(units ...Unit) error

Register adds or replaces host units. Re-registering the same name keeps its original order.

func (*Manager) Start

func (manager *Manager) Start(ctx context.Context, names ...string) error

Start starts selected host units. When names is empty, all registered units are started.

func (*Manager) Status

func (manager *Manager) Status(name string) Status

Status returns a host unit status by name.

func (*Manager) Stop

func (manager *Manager) Stop(ctx context.Context) error

Stop drains and stops started host units in reverse start order.

type Status

type Status string

Status is the runtime state of a host unit.

const (
	Created   Status = "created"
	Starting  Status = "starting"
	Running   Status = "running"
	Draining  Status = "draining"
	Stopping  Status = "stopping"
	Stopped   Status = "stopped"
	Failed    Status = "failed"
	Unhealthy Status = "unhealthy"
)

type Unit

type Unit interface {
	Name() string
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	Status() Status
}

Unit is a long-running application runtime unit.

Jump to

Keyboard shortcuts

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