Documentation ¶
Index ¶
- Constants
- func NewConn(conn *nats.Conn, conf *NatsConfig) network.IConn
- type Conn
- func (c *Conn) Close()
- func (c *Conn) Destroy()
- func (c *Conn) DirectErrorMsg(m *ss.Message, err error) *ss.Message
- func (c *Conn) GetKVBucket() (nats.KeyValue, error)
- func (c *Conn) GetStreamName(msgType, srcType, srcID uint32) string
- func (c *Conn) GetSubject(msgType, destType, destID, srcType, srcID uint32) string
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) ReadMessage() (interface{}, error)
- func (c *Conn) RegisterService(srcType, srcID uint32) error
- func (c *Conn) RegisterStream(msgType, srcType, srcID uint32) error
- func (c *Conn) RegisterSubject(msgType, srcType, srcID uint32) error
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) Reply(m *ss.Message) (*ss.Message, error)
- func (c *Conn) Request(subject string, msg *ss.Message) (*ss.Message, error)
- func (c *Conn) ResetStream() error
- func (c *Conn) SubscribeToNats(name, subject string) (*nats.Subscription, error)
- func (c *Conn) SubscribeToReply(name, subject string)
- func (c *Conn) SubscribeToStream(name, subject string) (*nats.Subscription, error)
- func (c *Conn) WriteMessage(args ...interface{}) error
- type INatsStream
- type NatsConfig
- type NatsRPC
- func (c *NatsRPC) Close()
- func (c *NatsRPC) DisconnectError(nc *nats.Conn, err error)
- func (c *NatsRPC) ErrorHandler(nc *nats.Conn, sub *nats.Subscription, err error)
- func (c *NatsRPC) GetAgent() network.IAgent
- func (c *NatsRPC) GetHashValue(destType uint32, value uint64) uint32
- func (c *NatsRPC) LoadServiceInfo(os nats.KeyValue, localInfo *ServiceGroup) error
- func (c *NatsRPC) Reconnect(nc *nats.Conn)
- func (c *NatsRPC) RegisterConfig() error
- func (c *NatsRPC) Run()
- func (c *NatsRPC) Wait()
- type ServiceGroup
Constants ¶
View Source
const NatsServiceKey = "gameconfig"
Variables ¶
This section is empty.
Functions ¶
func NewConn ¶
func NewConn(conn *nats.Conn, conf *NatsConfig) network.IConn
NewConn create websocket conn
Types ¶
type Conn ¶
Conn nats conn define
func (*Conn) GetKVBucket ¶
func (*Conn) GetStreamName ¶
func (*Conn) GetSubject ¶
func (*Conn) ReadMessage ¶
ReadMessage goroutine not safe
func (*Conn) RegisterService ¶
func (*Conn) RegisterStream ¶
func (*Conn) RegisterSubject ¶
func (*Conn) ResetStream ¶
func (*Conn) SubscribeToNats ¶
func (*Conn) SubscribeToReply ¶
func (*Conn) SubscribeToStream ¶
func (*Conn) WriteMessage ¶
WriteMessage args must not be modified by the others goroutines
type INatsStream ¶
type INatsStream interface { Send(*ss.Message) error Recv() (*ss.Message, error) // Context returns the context for this stream. Context() nats.JetStreamContext Close() }
INatsStream define rpc stream interface
type NatsConfig ¶
type NatsConfig struct { ServiceType int `mapstructure:"service_type"` ServiceID int `mapstructure:"service_id"` Nats []string `mapstructure:"nats"` Services []ServiceGroup `mapstructure:"services"` PingInterval time.Duration `mapstructure:"ping_interval"` MaxPingsOutstanding int `mapstructure:"max_ping_outstanding"` QueueSize int `mapstructure:"queue_size"` SocketQueueSize int `mapstructure:"socket_queue_size"` AsyncMaxPending uint32 `mapstructure:"async_max_pending"` WorkerPoolCapacity int `mapstructure:"worker_pool_capacity"` WorkerPoolQueueSize int `mapstructure:"worker_pool_queue_size"` }
NatsConfig grpc client config
func (*NatsConfig) GetQueueSize ¶
func (c *NatsConfig) GetQueueSize() int
GetQueueSize get module queue size
type NatsRPC ¶
type NatsRPC struct { sync.Mutex Conf *NatsConfig NewAgent network.AgentCreateFunc CloseAgent network.AgentCloseFunc // contains filtered or unexported fields }
NatsRPC nats PRC
func NewNatsRPC ¶
func NewNatsRPC(conf config.IConfig, agentFunc network.AgentCreateFunc, agentCloseFunc network.AgentCloseFunc) *NatsRPC
NewNatsRPC create nats client
func (*NatsRPC) DisconnectError ¶
func (*NatsRPC) ErrorHandler ¶
func (*NatsRPC) LoadServiceInfo ¶
func (c *NatsRPC) LoadServiceInfo(os nats.KeyValue, localInfo *ServiceGroup) error
func (*NatsRPC) RegisterConfig ¶
type ServiceGroup ¶
type ServiceGroup struct { Key string `mapstructure:"key" json:"key"` Type int `mapstructure:"type" json:"type"` Version int `mapstructure:"version" json:"version"` Mode int `mapstructure:"mode" json:"mode"` Hash []int `mapstructure:"hash" json:"hash"` }
ServiceGroup service group info
Click to show internal directories.
Click to hide internal directories.