transportx

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 9 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.

func Run added in v0.1.18

func Run(ctx context.Context, appInfo AppInfo, logger *slog.Logger, options ...RunOption) error

Types

type AppInfo

type AppInfo interface {
	ID() string
	Name() string
	Version() string
	Metadata() map[string]string
}

func FromContext

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

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

func NewAppInfo added in v0.1.18

func NewAppInfo(id, name, version string, metadata map[string]string) AppInfo

type RunOption added in v0.1.18

type RunOption func(*runner)

func AfterStart

func AfterStart(fn ...func(ctx context.Context) error) RunOption

func AfterStop

func AfterStop(fn ...func(ctx context.Context) error) RunOption

func BeforeStart

func BeforeStart(fn ...func(ctx context.Context) error) RunOption

func BeforeStop

func BeforeStop(fn ...func(ctx context.Context) error) RunOption

func WithServers added in v0.1.18

func WithServers(server ...Server) RunOption

func WithSignal

func WithSignal(signal ...os.Signal) RunOption

func WithStopTimeout

func WithStopTimeout(stopTimeout time.Duration) RunOption

type Server

type Server interface {
	Start(context.Context) error
	Stop(context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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