bunapp

package
v0.0.0-...-00594a0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: BSD-2-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithApp

func ContextWithApp(ctx context.Context, app *App) context.Context

func FS

func FS() fs.FS

func OnStart

func OnStart(name string, fn HookFunc)

func WaitExitSignal

func WaitExitSignal() os.Signal

Types

type App

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

func AppFromContext

func AppFromContext(ctx context.Context) *App

func New

func New(ctx context.Context, cfg *AppConfig) *App

func Start

func Start(ctx context.Context, service, envName string) (context.Context, *App, error)

func StartCLI

func StartCLI(c *cli.Context) (context.Context, *App, error)

func StartConfig

func StartConfig(ctx context.Context, cfg *AppConfig) (context.Context, *App, error)

func (*App) APIRouter

func (app *App) APIRouter() *bunrouter.Group

func (*App) Config

func (app *App) Config() *AppConfig

func (*App) Context

func (app *App) Context() context.Context

func (*App) DB

func (app *App) DB() *bun.DB

func (*App) IsDebug

func (app *App) IsDebug() bool

func (*App) OnAfterStop

func (app *App) OnAfterStop(name string, fn HookFunc)

func (*App) OnStop

func (app *App) OnStop(name string, fn HookFunc)

func (*App) Router

func (app *App) Router() *bunrouter.Router

func (*App) Running

func (app *App) Running() bool

func (*App) Stop

func (app *App) Stop()

func (*App) Stopping

func (app *App) Stopping() bool

type AppConfig

type AppConfig struct {
	Service string
	Env     string

	Debug     bool   `yaml:"debug"`
	SecretKey string `yaml:"secret_key"`

	DB struct {
		DSN string `yaml:"dsn"`
	} `yaml:"db"`
}

func ReadConfig

func ReadConfig(fsys fs.FS, service, env string) (*AppConfig, error)

type HookFunc

type HookFunc func(ctx context.Context, app *App) error

Jump to

Keyboard shortcuts

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