bootstrap

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminConfig

type AdminConfig struct {
	Enabled     bool
	IP          string
	Port        int
	ServiceName string
	EnablePprof bool
}

func NewAdminConfig

func NewAdminConfig(serviceName string, serverType int, enabled, enablePprof bool, ip string, port int) AdminConfig

type AdminServer

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

func StartAdminServer

func StartAdminServer(cfg AdminConfig, state AdminState) (*AdminServer, error)

func (*AdminServer) Shutdown

func (s *AdminServer) Shutdown(ctx context.Context) error

type AdminState

type AdminState struct {
	IsAlive    func() bool
	IsReady    func() bool
	Info       func() InfoSnapshot
	Components func() []ComponentStatus
}

type BuildInfo added in v1.2.3

type BuildInfo struct {
	Path        string `json:"path,omitempty"`
	Version     string `json:"version,omitempty"`
	GoVersion   string `json:"go_version,omitempty"`
	GOOS        string `json:"go_os,omitempty"`
	GOARCH      string `json:"go_arch,omitempty"`
	VCSRevision string `json:"vcs_revision,omitempty"`
	VCSTime     string `json:"vcs_time,omitempty"`
	VCSDirty    string `json:"vcs_dirty,omitempty"`
}

type ComponentStatus added in v1.2.3

type ComponentStatus struct {
	Name      string `json:"name"`
	State     string `json:"state"`
	Ready     bool   `json:"ready"`
	Message   string `json:"message,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
}

type InfoSnapshot added in v1.2.3

type InfoSnapshot struct {
	Service      string    `json:"service"`
	Alive        bool      `json:"alive"`
	Ready        bool      `json:"ready"`
	Phase        string    `json:"phase,omitempty"`
	StartedAt    string    `json:"started_at,omitempty"`
	PhaseSince   string    `json:"phase_since,omitempty"`
	Uptime       string    `json:"uptime,omitempty"`
	LastReloadAt string    `json:"last_reload_at,omitempty"`
	LastError    string    `json:"last_error,omitempty"`
	Build        BuildInfo `json:"build"`
}

type LoggerConfig

type LoggerConfig struct {
	Dir   string
	Level string
	Name  string
}

type Options

type Options struct {
	ServiceName     string
	ShutdownTimeout time.Duration

	LoadConfig        func() error
	BuildInfo         func() BuildInfo
	LoggerConfig      func() LoggerConfig
	AdminConfig       func() AdminConfig
	ComponentStatuses func() []ComponentStatus
	InitDeps          func() error
	RegisterHandlers  func() error
	StartRuntime      func() error
	OnProc            func() bool
	OnTick            func(lastMs, nowMs int64)
	// OnShutdown runs before admin shutdown / OnExit and should perform
	// graceful, timeout-bound runtime stop work.
	OnShutdown func(ctx context.Context) error
	// OnExit runs after graceful shutdown attempts and is meant for final
	// best-effort cleanup/logging.
	OnExit func()
}

type ServiceApp

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

func NewServiceApp

func NewServiceApp(opts Options) *ServiceApp

func (*ServiceApp) OnExit

func (a *ServiceApp) OnExit()

func (*ServiceApp) OnInit

func (a *ServiceApp) OnInit() error

func (*ServiceApp) OnProc

func (a *ServiceApp) OnProc() bool

func (*ServiceApp) OnReload

func (a *ServiceApp) OnReload() error

func (*ServiceApp) OnTick

func (a *ServiceApp) OnTick(lastMs, nowMs int64)

Jump to

Keyboard shortcuts

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