container

package
v0.0.0-...-69995ca Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 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)

EnableMonitor start

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

ForwardWithSelector forward data to the specified node of service which is chosen by selector

func HashCode

func HashCode(key string) int

HashCode generated a hash code

func Init

func Init(srv kim.Server, deps ...string) error

Init Init

func Push

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

push message to server

func SetDialer

func SetDialer(dialer kim.Dialer)

SetDialer set tcp dialer

func SetSelector

func SetSelector(selector Selector)

SetSelector set a default selector

func SetServiceNaming

func SetServiceNaming(nm naming.Naming)

SetServiceNaming

func Start

func Start() error

Start server

Types

type ClientMap

type ClientMap interface {
	Add(client kim.Client)
	Remove(id string)
	Get(id string) (client kim.Client, ok bool)
	// Find(name string) (client []kim.Client)
	Services(kvs ...string) []kim.Service
}

Clients Clients

func NewClients

func NewClients(num int) ClientMap

NewClients NewClients

type ClientsImpl

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

func (*ClientsImpl) Add

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

Add addChannel

func (*ClientsImpl) Get

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

Get Get

func (*ClientsImpl) Remove

func (ch *ClientsImpl) Remove(id string)

Remove addChannel

func (*ClientsImpl) Services

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

返回服务列表,可以传一对

type Container

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

Container Container

func Default

func Default() *Container

Default Default

type HashSelector

type HashSelector struct {
}

HashSelector HashSelector

func (*HashSelector) Lookup

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

Lookup a server

type Selector

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

Selector is used to select a Service

Jump to

Keyboard shortcuts

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