interfaces

package
v0.0.0-...-3ced3f3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppContext

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

func (*AppContext) App

func (b *AppContext) App() IApplication

func (*AppContext) Set

func (b *AppContext) Set(ctx IApplication)

type BaseComponent

type BaseComponent struct {
	AppContext
}

BaseComponent

func (*BaseComponent) AfterInit

func (*BaseComponent) AfterInit()

func (*BaseComponent) BeforeStop

func (*BaseComponent) BeforeStop()

func (*BaseComponent) Init

func (*BaseComponent) Init()

func (*BaseComponent) Name

func (*BaseComponent) Name() string

func (*BaseComponent) Stop

func (*BaseComponent) Stop()

type FrontendId

type FrontendId = string

type IAppContext

type IAppContext interface {
	Set(ctx IApplication)
	App() IApplication
}

type IApplication

type IApplication interface {
	//NodeId current nodeId
	NodeId() string

	//NodeType current nodeType
	NodeType() string

	//ThisNode current node info
	ThisNode() INode

	//Register load component
	Register(components ...IComponent)

	//Find get component
	Find(name string) IComponent

	//Remove remove a component
	Remove(name string) IComponent

	//All all components
	All() []IComponent

	//PostEvent
	PostEvent(e IEvent)

	//OnShutdown  execute this func before the application shutdown
	OnShutdown(shutdownFunc ...func())

	//Startup
	Startup(startupFunc ...func())
}

type IComponent

type IComponent interface {
	IAppContext

	//Name unique components name
	Name() string

	Init()

	AfterInit()

	BeforeStop()

	Stop()
}

IComponent

type IConnectListener

type IConnectListener func(conn net.Conn)

type IConnector

type IConnector interface {
	Start()

	OnConnect(listener IConnectListener)

	Stop()
}

type IEvent

type IEvent interface {
	// event name
	EventName() string
}

type IHandler

type IHandler interface {
	IAppContext

	Name() string

	SetName(name string)

	PreInit()

	Init()
}

type INetworkEntity

type INetworkEntity interface {
	Push(route string, data interface{}) error
	RPC(route string, data interface{}) error
	LastMid() uint64
	Response(data interface{}) error
	ResponseMid(mid uint64, data interface{}) error
	Close() error
	RemoteAddr() net.Addr
}

type INode

type INode interface {
	NodeId() string
	Address() string
	RpcAddress() string
	Settings() json.Any
	IsDisabled() bool
}

type IRoute

type IRoute interface {
	NodeType() string
	HandlerName() string
	Method() string
}

type ISession

type ISession interface {
	SID() SID
	UID() UID
	FrontendId() FrontendId
	SetStatus(status int)
	Status() int

	Data() map[string]interface{}
	Remove(key string)
	Set(key string, value interface{})
	Contains(key string) bool

	Conn() net.Conn
	OnClose(listener SessionListener)
	OnError(listener SessionListener)
	OnMessage(listener MessageListener)
	Send(msg []byte) error
	SendBatch(batchMsg ...[]byte)

	Closed()
}

type MessageListener

type MessageListener func(bytes []byte) error

type NodeMap

type NodeMap map[string]map[string]INode

{key:nodeType,value:{key:nodeId,value:NodeConfig}}

type Packet

type Packet struct {
	Type   byte
	Length int
	Data   []byte
}

Packet represents a network packet.

func New

func New() *Packet

New create a Packet instance.

func (*Packet) String

func (p *Packet) String() string

String represents the Packet's in text mode.

type PacketDecoder

type PacketDecoder interface {
	Decode(data []byte) ([]*Packet, error)
}

type PacketEncoder

type PacketEncoder interface {
	Encode(typ byte, buf []byte) ([]byte, error)
}

type RouteFunc

type RouteFunc func(session ISession, msg RpcMessage, nodeInfo []RpcNodeInfo)

type RouteFunction

type RouteFunction func(session ISession, packet interface{}, ctx IApplication) error

type RpcFilter

type RpcFilter struct {
	Name   string
	Before RpcFilterFunc
	After  RpcFilterFunc
}

type RpcFilterFunc

type RpcFilterFunc func(nodeId string, msg interface{})

type RpcMessage

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

type RpcNodeInfo

type RpcNodeInfo interface {
	Id() string
	Address() string
	NodeType() string
	Weight() int
}

type SID

type SID = int64

type Serializer

type Serializer interface {
	Marshal(interface{}) ([]byte, error)

	Unmarshal([]byte, interface{}) error

	Name() string
}

Serializer 消息序列化

type SessionListener

type SessionListener func(session ISession)

type UID

type UID = int64

Jump to

Keyboard shortcuts

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