container

package
v0.0.0-...-e7f8777 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateYoung = "young"
	StateAdult = "adult"
)
View Source
const (
	KeyServiceState = "service_state"
)

Variables

This section is empty.

Functions

func EnableMonitor

func EnableMonitor(listen string)

func Forward

func Forward(serviceName string, packet *pkt.LogicPkt) error

forward message to service

func ForwardWithSelector

func ForwardWithSelector(serviceName string, packet *pkt.LogicPkt, selector Selector) error

func HashCode

func HashCode(key string) int

func Init

func Init(srv qim.Server, lg *zap.Logger, deps ...string) error

init container with a Server, and its deps

For example, in the gateway, it depends on the login and chat services, and it will cal the function like this: _ = container.Init(srv, wire.SNChat, wire.SNLogin)

func Push

func Push(server string, p *pkt.LogicPkt) error

push message to server

func SetDialer

func SetDialer(dialer qim.Dialer)

func SetSelector

func SetSelector(selector Selector)

func SetServiceNaming

func SetServiceNaming(nm naming.Naming)

func Start

func Start() error

start server

Types

type ClientMap

type ClientMap interface {
	Add(client qim.Client)
	Remove(id string)
	Get(id string) (qim.Client, bool)
	Services(kvs ...string) []qim.Service
}

func NewClients

func NewClients(num int) ClientMap

type ClientsImpl

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

func (*ClientsImpl) Add

func (ch *ClientsImpl) Add(client qim.Client)

Add implements ClientMap

func (*ClientsImpl) Get

func (ch *ClientsImpl) Get(id string) (qim.Client, bool)

Get implements ClientMap

func (*ClientsImpl) Remove

func (ch *ClientsImpl) Remove(id string)

Remove implements ClientMap

func (*ClientsImpl) Services

func (ch *ClientsImpl) Services(kvs ...string) []qim.Service

Services implements ClientMap

type Container

type Container struct {
	sync.RWMutex
	Naming naming.Naming
	Srv    qim.Server
	// contains filtered or unexported fields
}

func Default

func Default() *Container

type HashSelector

type HashSelector struct {
}

func (*HashSelector) Lookup

func (*HashSelector) Lookup(header *pkt.Header, srvs []qim.Service) string

Lookup implements Selector

type Selector

type Selector interface {
	Lookup(header *pkt.Header, srvs []qim.Service) string
}

Jump to

Keyboard shortcuts

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