Documentation ¶
Index ¶
- Constants
- Variables
- type Call
- type Client
- func (c *Client) Broadcast(data []byte) error
- func (c *Client) Close() error
- func (c *Client) Connect(eventName string, addr string) error
- func (c *Client) Pipe(id uint32) protocol.Pipe
- func (c *Client) RangePipes(f func(uint32, protocol.Pipe) bool)
- func (c *Client) Send(src, dest uint32, data []byte) error
- func (c *Client) SendData(src, dest uint32, hash uint64, data []byte) error
- func (c *Client) SendMessage(src uint32, dest uint32, hash uint64, m *mangos.Message) error
- func (c *Client) SetAutoReconnect(v bool)
- func (c *Client) SetDataErrorContinue(v bool)
- func (c *Client) SetInterval(v time.Duration)
- func (c *Client) SetReadTimeout(v time.Duration)
- func (c *Client) SetRecvSize(v int)
- func (c *Client) SetSendSize(v int)
- func (c *Client) SetWriteTimeout(v time.Duration)
- func (c *Client) Stop()
- func (c *Client) String() string
- type Config
- type Options
- type Pipe
- func (p *Pipe) Close() error
- func (p *Pipe) Event() uint32
- func (p *Pipe) GetPrivate() interface{}
- func (p *Pipe) ID() uint32
- func (p *Pipe) LocalAddr() string
- func (p *Pipe) Pipe() mangos.Pipe
- func (p *Pipe) Pipes() map[uint32]*Pipe
- func (p *Pipe) RecvMsg() *mproto.Message
- func (p *Pipe) RemoteAddr() string
- func (p *Pipe) RemoteID() uint32
- func (p *Pipe) SendMsg(m *mproto.Message) error
- func (p *Pipe) SetEvent(v uint32)
- func (p *Pipe) SetPrivate(v interface{})
- func (p *Pipe) Stop()
- type PipeHandler
- type Protocol
- func (s *Protocol) AddPipe(pp mproto.Pipe) error
- func (s *Protocol) Close() error
- func (s *Protocol) GetOption(option string) (interface{}, error)
- func (*Protocol) Info() mproto.Info
- func (s *Protocol) OpenContext() (mproto.Context, error)
- func (s *Protocol) Pipe(id uint32) protocol.Pipe
- func (s *Protocol) RangePipes(f func(uint32, protocol.Pipe) bool)
- func (s *Protocol) RecvMsg() (*mproto.Message, error)
- func (s *Protocol) RemovePipe(pp mproto.Pipe)
- func (s *Protocol) SendMsg(m *mproto.Message) error
- func (s *Protocol) SetOption(name string, value interface{}) error
- func (s *Protocol) SetPipeEventHook(v protocol.PipeEventHook)
- func (s *Protocol) String() string
- type XClient
- func (c *XClient) AddClient(_ string, addr string)
- func (c *XClient) Call(ctx context.Context, src, dest uint32, eventHash uint64, ...) error
- func (c *XClient) Go(ctx context.Context, src, dest uint32, eventHash uint64, ...) *Call
- func (c *XClient) OnPipeClosed(p protocol.Pipe)
- func (c *XClient) OnPipeConnected(p protocol.Pipe)
- func (c *XClient) OnPipeDataArrived(p protocol.Pipe, msg interface{}) error
- func (c *XClient) OnPipeTimer(p protocol.Pipe)
- func (c *XClient) Pick(hash string) (protocol.Pipe, error)
- func (c *XClient) PickSend(srcHash string, dest uint32, destHash uint64, data []byte) error
- func (c *XClient) RemoveClient(_ string, addr string)
- func (c *XClient) Stop()
- func (c *XClient) UpdateClient(_ string, addr string, conn any)
- func (c *XClient) Watch()
Constants ¶
View Source
const ( Self = protocol.ProtoEvent Peer = protocol.ProtoEventBus SelfName = "event" PeerName = "ebus" )
Protocol identity information.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct { ID uint64 ServicePath string // The name of the service and method to call. ServiceMethod string // The name of the service and method to call. ReqMetadata map[string]string // metadata ResMetadata map[string]string Content interface{} Args interface{} // The argument to the function (*struct). Reply interface{} // The reply from the function (*struct). Error error // After completion, the error status. Done chan *Call // Strobes when call is complete. }
Call represents an active RPC.
type Client ¶
func NewClient ¶
func NewClient(cfg *Config, handler PipeHandler) *Client
func (*Client) SendMessage ¶
func (*Client) SetAutoReconnect ¶
func (*Client) SetDataErrorContinue ¶
func (*Client) SetInterval ¶
func (*Client) SetReadTimeout ¶
func (*Client) SetRecvSize ¶
func (*Client) SetSendSize ¶
func (*Client) SetWriteTimeout ¶
type Config ¶
type Config struct { ServiceId int `json:"service_id" yaml:"service_id" toml:"service_id"` EventName string `json:"event" yaml:"event" toml:"event"` Address string `json:"address" yaml:"address" toml:"address"` SendChanSize int `json:"send_chan_size,omitempty" yaml:"send_chan_size,omitempty" toml:"send_chan_size,omitempty"` RecvChanSize int `json:"recv_chan_size,omitempty" yaml:"recv_chan_size,omitempty" toml:"recv_chan_size,omitempty"` DataErrorContinue bool `json:"data_error_continue,omitempty" yaml:"data_error_continue,omitempty" toml:"data_error_continue,omitempty"` Reconnect bool `json:"reconnect,omitempty" yaml:"reconnect,omitempty" toml:"reconnect,omitempty"` Interval time.Duration `json:"interval,omitempty" yaml:"interval,omitempty" toml:"interval,omitempty"` ReadTimeout time.Duration `json:"read_timeout,omitempty" yaml:"read_timeout,omitempty" toml:"read_timeout,omitempty"` WriteTimeout time.Duration `json:"write_timeout,omitempty" yaml:"write_timeout,omitempty" toml:"write_timeout,omitempty"` }
type Options ¶
type Options struct { SerializeType byte `json:"serialize_type,omitempty" yaml:"serialize_type,omitempty" toml:"serialize_type,omitempty"` CompressType byte `json:"compress_type,omitempty" yaml:"compress_type,omitempty" toml:"compress_type,omitempty"` NotifyBlock bool `json:"notify_block,omitempty" yaml:"notify_block,omitempty" toml:"notify_block,omitempty"` IdleTimeout time.Duration `json:"idle_timeout,omitempty" yaml:"idle_timeout,omitempty" toml:"idle_timeout,omitempty"` TraceMessage bool `json:"trace_message,omitempty" yaml:"trace_message,omitempty" toml:"trace_message,omitempty"` }
type Pipe ¶
type Pipe struct {
// contains filtered or unexported fields
}
func (*Pipe) GetPrivate ¶
func (p *Pipe) GetPrivate() interface{}
func (*Pipe) RemoteAddr ¶
func (*Pipe) SetPrivate ¶
func (p *Pipe) SetPrivate(v interface{})
type PipeHandler ¶
type Protocol ¶
func (*Protocol) RemovePipe ¶
func (*Protocol) SetPipeEventHook ¶
func (s *Protocol) SetPipeEventHook(v protocol.PipeEventHook)
type XClient ¶
type XClient struct { *Client // contains filtered or unexported fields }
func NewXClient ¶
func NewXClient(cfg *Config, watchCfg *discovery.ClientConfig, handler PipeHandler) *XClient
func (*XClient) Call ¶
func (c *XClient) Call(ctx context.Context, src, dest uint32, eventHash uint64, servicePath, serviceMethod string, args interface{}, reply interface{}) error
Call invokes the named function, waits for it to complete, and returns its error status.
func (*XClient) Go ¶
func (c *XClient) Go(ctx context.Context, src, dest uint32, eventHash uint64, servicePath, serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call
Go invokes the function asynchronously. It returns the Call structure representing the invocation. The done channel will signal when the call is complete by returning the same Call object. If done is nil, Go will allocate a new channel. If non-nil, done must be buffered or Go will deliberately crash.
func (*XClient) OnPipeClosed ¶
func (*XClient) OnPipeConnected ¶
func (*XClient) OnPipeDataArrived ¶
func (*XClient) OnPipeTimer ¶
func (*XClient) RemoveClient ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.