wukong

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

wukong

A lightweight, flexible, and powerful game server framework inspired by Sun Wukong —— nimble as a monkey, strong as a god, ready to scale with your game's journey.

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 返回携带 AppInfo 的新 Context

Types

type App

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

App 代表应用实例

func New

func New(opts ...Option) *App

New 创建应用实例

func (*App) Endpoint

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

Endpoint 返回服务端点

func (*App) ID

func (a *App) ID() string

ID 返回应用实例 ID

func (*App) Metadata

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

Metadata 返回服务元数据

func (*App) Name

func (a *App) Name() string

Name 返回服务名

func (*App) Run

func (a *App) Run() error

Run 运行应用生命周期

func (*App) Stop

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

Stop 优雅停止应用

func (*App) Version

func (a *App) Version() string

Version 返回应用版本

type AppInfo

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

func FromContext

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

FromContext 从 Context 中取出 AppInfo

type Option

type Option func(o *options)

Option 为应用选项

func AfterStart

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

AfterStart 添加启动后回调

func AfterStop

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

AfterStop 添加停止后回调

func BeforeStart

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

BeforeStart 添加启动前回调

func BeforeStop

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

BeforeStop 添加停止前回调

func Context

func Context(ctx context.Context) Option

Context 设置服务上下文

func Endpoint

func Endpoint(endpoints ...*url.URL) Option

Endpoint 设置服务端点

func ID

func ID(id string) Option

ID 设置服务 ID

func Logger

func Logger(logger log.Logger) Option

Logger 设置服务日志器

func Metadata

func Metadata(md map[string]string) Option

Metadata 设置服务元数据

func Name

func Name(name string) Option

Name 设置服务名

func Registry

func Registry(r registry.Registry) Option

Registry 设置服务注册中心

func RegistryTimeout

func RegistryTimeout(t time.Duration) Option

RegistryTimeout 设置注册超时

func Signal

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

Signal 设置退出信号

func StopTimeout

func StopTimeout(t time.Duration) Option

StopTimeout 设置停止超时

func Version

func Version(version string) Option

Version 设置服务版本

Directories

Path Synopsis
component
log
contrib
broker/nats module
locator/redis module
proto
Package proto 定义 protobuf 编解码器。
Package proto 定义 protobuf 编解码器。
xml
pkg
wos

Jump to

Keyboard shortcuts

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