kratos

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, s AppInfo) context.Context

NewContext returns a new Context that carries value.

Types

type App

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

App is an application components lifecycle manager.

func New

func New(opts ...Option) *App

New create an application lifecycle manager.

func (*App) ID

func (a *App) ID() string

ID returns app instance id.

func (*App) Name

func (a *App) Name() string

Name returns service name.

func (*App) Run

func (a *App) Run() error

func (*App) Stop

func (a *App) Stop() (err error)

Stop gracefully stops the application.

func (*App) Version

func (a *App) Version() string

Version returns service version.

type AppInfo

type AppInfo interface {
	ID() string
	Name() string
	Version() string
}

AppInfo is application context value.

func FromContext

func FromContext(ctx context.Context) (s AppInfo, ok bool)

FromContext returns the Transport value stored in ctx, if any.

type Option

type Option func(o *options)

Option is an application option.

func AfterStart

func AfterStart(fn func(context.Context) error) Option

AfterStart run funcs after tavern starts

func AfterStop

func AfterStop(fn func(context.Context) error) Option

AfterStop run funcs after tavern stops

func BeforeStart

func BeforeStart(fn func(context.Context) error) Option

BeforeStart run funcs before tavern starts

func BeforeStop

func BeforeStop(fn func(context.Context) error) Option

BeforeStop run funcs before tavern stops

func ID

func ID(id string) Option

ID with service id.

func Logger

func Logger(logger log.Logger) Option

Logger with service logger.

func Name

func Name(name string) Option

Name with service name.

func Server

func Server(svs ...transport.Server) Option

Server with transport servers.

func Signal

func Signal(sigs ...os.Signal) Option

Signal with exit signals.

func StopTimeout

func StopTimeout(t time.Duration) Option

StopTimeout with app stop timeout.

func Version

func Version(version string) Option

Version with a service version

Jump to

Keyboard shortcuts

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