app

package module
v0.0.0-...-05642ee Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 13 Imported by: 0

README

App

A Go base app structure with lifecycle management, configuration loading, and event hooks built on top of Uber FX.

Installation

go get github.com/rumorsflow/app

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig[C any]() func(*BootEvent) error

func Options

func Options(options ...fx.Option) func(*BootEvent) error

func Restart

func Restart() error

Types

type App

type App interface {
	Name() string
	Version() string
	LoadConfig(outs ...any) error
	OnBoot() *hook.Hook[*BootEvent]
	Boot(ctx context.Context) error
	StartTimeout() time.Duration
	OnStart() *hook.Hook[*StartEvent]
	Start(ctx context.Context) error
	StopTimeout() time.Duration
	OnStop() *hook.Hook[*StopEvent]
	Stop(ctx context.Context) error
	Restart(ctx context.Context) error
	Run(ctx context.Context) error
}

type BaseApp

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

func NewBaseApp

func NewBaseApp(cfg Config) *BaseApp

func (*BaseApp) Boot

func (app *BaseApp) Boot(ctx context.Context) error

func (*BaseApp) LoadConfig

func (app *BaseApp) LoadConfig(outs ...any) error

func (*BaseApp) Name

func (app *BaseApp) Name() string

func (*BaseApp) OnBoot

func (app *BaseApp) OnBoot() *hook.Hook[*BootEvent]

func (*BaseApp) OnStart

func (app *BaseApp) OnStart() *hook.Hook[*StartEvent]

func (*BaseApp) OnStop

func (app *BaseApp) OnStop() *hook.Hook[*StopEvent]

func (*BaseApp) Restart

func (app *BaseApp) Restart(ctx context.Context) error

func (*BaseApp) Run

func (app *BaseApp) Run(ctx context.Context) error

func (*BaseApp) Start

func (app *BaseApp) Start(ctx context.Context) error

func (*BaseApp) StartTimeout

func (app *BaseApp) StartTimeout() time.Duration

func (*BaseApp) Stop

func (app *BaseApp) Stop(ctx context.Context) error

func (*BaseApp) StopTimeout

func (app *BaseApp) StopTimeout() time.Duration

func (*BaseApp) Version

func (app *BaseApp) Version() string

type BootEvent

type BootEvent struct {
	hook.Event
	App     App
	Ctx     context.Context
	Logger  fxevent.Logger
	Options []fx.Option
}

type Config

type Config struct {
	StartTimeout    time.Duration
	StopTimeout     time.Duration
	ConfigUnmarshal func(data []byte, out any) error
	ConfigRaw       []byte
	ConfigFiles     []string
	EnvPrefix       string
	Name            string
	Version         string
}

type StartEvent

type StartEvent struct {
	hook.Event
	App App
	Ctx context.Context
}

type StopEvent

type StopEvent struct {
	hook.Event
	App       App
	Ctx       context.Context
	IsRestart bool
}

Jump to

Keyboard shortcuts

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