client

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Opts = new(struct {
		Dev         bool // 是否开发模式
		Port        int
		ServerID    int
		Channel     string
		Daemon      bool
		CfgFilepath string
	})
)

Functions

func NewContext

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

Types

type Event

type Event interface {
	Publish(ctx context.Context, msg interface{}) error
}

type IClient

type IClient interface {
	Name() string
	Init(...Option)
	Options() Options
	Run() error
	Stop() error
}

func FromContext

func FromContext(ctx context.Context) (IClient, bool)

type Option

type Option func(*Options)

func AfterStart

func AfterStart(fn func() error) Option

func AfterStop

func AfterStop(fn func() error) Option

func BeforeStart

func BeforeStart(fn func() error) Option

func BeforeStop

func BeforeStop(fn func() error) Option

func Context1

func Context1(ctx context.Context) Option

func HandleSignal

func HandleSignal(b bool) Option

type Options

type Options struct {
	Rds         *redis.Store
	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	Context context.Context
	Cancel  context.CancelFunc

	Signal bool
}

type Publisher

type Publisher = Event

Jump to

Keyboard shortcuts

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