nami

package module
v0.0.0-...-037b315 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 12 Imported by: 0

README

nami

Lightweight game framework with golang. Part of the design refers to kratos and go-zero.

Star History

Star History Chart

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContext

func GetContext() context.Context

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
}

func GetApp

func GetApp() *App

func New

func New(opts ...Option) (a *App, err error)

func (*App) Context

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

func (*App) Endpoint

func (a *App) Endpoint() []string

func (*App) ID

func (a *App) ID() string

func (*App) Metadata

func (a *App) Metadata() map[string]string

Metadata returns service metadata.

func (*App) Name

func (a *App) Name() string

func (*App) Run

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

func (*App) Server

func (a *App) Server(name string) transport.Server

Server 返回

func (*App) Stop

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

func (*App) Version

func (a *App) Version() string

Version returns app version.

type AppInfo

type AppInfo interface {
	ID() string
	Name() string
	Version() string
	Metadata() map[string]string
	Endpoint() []string
	Server(name string) transport.Server
}

func FromContext

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

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

func GetInfo

func GetInfo() AppInfo

type Option

type Option func(*options)

func AfterStart

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

func AfterStop

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

func BeforeStart

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

func Context

func Context(ctx context.Context) Option

func ID

func ID(id string) Option

func MetaData

func MetaData(metadata map[string]string) Option

func Name

func Name(name string) Option

func Registrar

func Registrar(registrar registry.Registrar) Option

func Servers

func Servers(srv ...transport.Server) Option

func SigFunc

func SigFunc(fn func(os.Signal) bool) Option

func Version

func Version(version string) Option

Version with service version.

Jump to

Keyboard shortcuts

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