application

package
v0.2.23 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AppModeProd = "prod"
	AppModeGrey = "grey"
	AppModeTest = "test"
	AppModeDev  = "dev"

	DefaultEnvPrefix = "neptune"
)

Functions

func BindFlags

func BindFlags(ctx context.Context, groupName string, set *pflag.FlagSet, v *viper.Viper)

BindFlags Bind each cobra flag to its associated viper configuration (config file and environment variable)

Types

type App

type App struct {
	Mode      string //app run mode,default is [prod]
	LogLevel  string //slog level,default is info,[trace|debug|notice|info|warn|error|fatal]
	EnvPrefix string //app global env prefix,default is neptune
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context) *App

func (*App) Cancel

func (app *App) Cancel(msg string, args ...any)

func (*App) Hook

func (app *App) Hook(hooks ...HookFunc)

func (*App) Run

func (app *App) Run() error

func (*App) Use

func (app *App) Use(plugins ...Plugin)

Use Plugins running after server startup

type AppMode

type AppMode string

type HookFunc

type HookFunc func(ctx context.Context) error

type Plugin

type Plugin interface {
	Name() string
	Flags() *pflag.FlagSet
	ConfigOptions() *PluginConfigOptions
	Config(ctx context.Context, config []byte) error
	Init(ctx context.Context) error
	Run(ctx context.Context) error
}

func NewPluginConfig

func NewPluginConfig(name string, opts *PluginConfigOptions) Plugin

type PluginConfigOptions

type PluginConfigOptions struct {
	ConfigFile string
	ConfigName string
	ConfigType string
	EnvPrefix  string
}

Jump to

Keyboard shortcuts

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