snow

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NodeAddrInvalid = NodeAddr(-1)
	NodeAddrLocal   = NodeAddr(0)
)
View Source
var (
	ErrServiceNotExist      = fmt.Errorf("service not exist")
	ErrNodeMessageChanFull  = fmt.Errorf("note message chan full")
	ErrRequestTimeoutRemote = fmt.Errorf("session timeout from remote")
	ErrRequestTimeoutLocal  = fmt.Errorf("session timeout from local")
)
View Source
var EmptyContext = (node.IRpcContext)((*rpcContext)(nil))
View Source
var ErrRemoteDisconnected = fmt.Errorf("remote disconnected")
View Source
var NodeConfig = &NodeConfigStruct{
	CurNodeMap: map[string]bool{},
}

Functions

func AddNode

func AddNode(b host.IBuilder, registerFactory func() *NodeExOption)

func InitOptions

func InitOptions(opt *NodeBootOption)

func NewService

func NewService(name string) (int32, error)

func StartService

func StartService(saddr int32, arg interface{}) bool

func StopService

func StopService(saddr int32) bool

Types

type Node

type Node struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Node) Construct

func (ss *Node) Construct(host host.IHost, logger *logging.Logger[Node], nbOpt *option.Option[*NodeBootOption], nodeOpt *option.Option[*NodeExOption])

func (*Node) Start

func (ss *Node) Start(ctx context.Context, wg *sync2.TimeoutWaitGroup)

func (*Node) Stop

func (ss *Node) Stop(ctx context.Context, wg *sync2.TimeoutWaitGroup)

type NodeAddr

type NodeAddr int64

func NewNodeAddr

func NewNodeAddr(host string, port int) (NodeAddr, error)

func (NodeAddr) GetIPString

func (ss NodeAddr) GetIPString() string

func (NodeAddr) IsLocalhost

func (ss NodeAddr) IsLocalhost() bool

func (NodeAddr) String

func (ss NodeAddr) String() string

type NodeAddrUpdater

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

func NewNodeAddrUpdater

func NewNodeAddrUpdater(naddr NodeAddr, updateFunc func(chan<- *NodeAddr)) *NodeAddrUpdater

func (*NodeAddrUpdater) GetNodeAddr

func (ss *NodeAddrUpdater) GetNodeAddr() NodeAddr

func (*NodeAddrUpdater) Start

func (ss *NodeAddrUpdater) Start()

type NodeBootOption

type NodeBootOption struct {
	BootName string                        `koanf:"boot_name"` // 启动节点名
	Nodes    map[string]*nodeElementOption `koanf:"nodes"`     // 所有节点数据
}

type NodeConfigStruct

type NodeConfigStruct struct {
	Nodes       []*nodeInfo
	CurNode     []string
	CurNodeMap  map[string]bool
	CurNodeAddr NodeAddr
	CurNodePort int
}

type NodeExOption

type NodeExOption struct {
	ServiceRegisterInfos     []*ServiceRegisterInfo
	ClientHandlePreprocessor net2.IPreprocessor
	ServerHandlePreprocessor net2.IPreprocessor
}

type Service

type Service struct {
	MethodMap map[string]reflect.Value
	// contains filtered or unexported fields
}

func (*Service) After

func (ss *Service) After(delay time.Duration, f func()) node.ITimer

func (*Service) Construct

func (ss *Service) Construct(logger *logging.Logger[Service])

func (*Service) CreateProxy

func (ss *Service) CreateProxy(name string) node.IProxy

func (*Service) CreateProxyByNodeAddr

func (ss *Service) CreateProxyByNodeAddr(naddr node.INodeAddr, saddr int32) node.IProxy

func (*Service) CreateProxyByNodeKind

func (ss *Service) CreateProxyByNodeKind(naddr node.INodeAddr, name string) node.IProxy

func (*Service) CreateProxyByUpdaterAddr

func (ss *Service) CreateProxyByUpdaterAddr(naddrUpdater *NodeAddrUpdater, saddr int32) node.IProxy

func (*Service) CreateProxyByUpdaterKind

func (ss *Service) CreateProxyByUpdaterKind(naddrUpdater *NodeAddrUpdater, name string) node.IProxy

func (*Service) CreateProxyDefault

func (ss *Service) CreateProxyDefault() node.IProxy

func (*Service) Debugf

func (ss *Service) Debugf(format string, args ...any)

func (*Service) EnableRPC

func (ss *Service) EnableRPC()

func (*Service) Entry

func (ss *Service) Entry(ctx node.IRpcContext, funcName string, argGetter func(ft reflect.Type) ([]reflect.Value, error)) func()

func (*Service) Errorf

func (ss *Service) Errorf(format string, args ...any)

func (*Service) Fatalf

func (ss *Service) Fatalf(format string, args ...any)

func (*Service) Fork

func (ss *Service) Fork(tag string, f func())

func (*Service) GetAddr

func (ss *Service) GetAddr() int32

func (*Service) GetKind

func (ss *Service) GetKind() int32

func (*Service) GetLoad

func (ss *Service) GetLoad() float64

func (*Service) GetMillisecond

func (ss *Service) GetMillisecond() int64

func (*Service) GetName

func (ss *Service) GetName() string

func (*Service) GetSecond

func (ss *Service) GetSecond() int64

func (*Service) GetTime

func (ss *Service) GetTime() time.Time

func (*Service) Infof

func (ss *Service) Infof(format string, args ...any)

func (*Service) NewService

func (ss *Service) NewService(name string) (int32, error)

func (*Service) RpcReload

func (ss *Service) RpcReload(ctx node.IRpcContext)

func (*Service) RpcStatus

func (ss *Service) RpcStatus(ctx node.IRpcContext)

func (*Service) SetAllowedRPC

func (ss *Service) SetAllowedRPC(names []string)

func (*Service) Start

func (ss *Service) Start(_ interface{})

func (*Service) Stop

func (ss *Service) Stop(_ *sync.WaitGroup)

func (*Service) Tick

func (ss *Service) Tick(interval, delay time.Duration, f func()) node.ITimer

func (*Service) TickAfter

func (ss *Service) TickAfter(interval time.Duration, f func(func())) node.ITimer

func (*Service) TickDelayRandom

func (ss *Service) TickDelayRandom(interval time.Duration, f func()) node.ITimer

func (*Service) Tracef

func (ss *Service) Tracef(format string, args ...any)

func (*Service) Warnf

func (ss *Service) Warnf(format string, args ...any)

type ServiceRegisterInfo

type ServiceRegisterInfo struct {
	Kind int32
	Name string
	Type any
}

type TagFunc

type TagFunc struct {
	Tag string
	F   func()
}

Jump to

Keyboard shortcuts

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