Documentation ¶
Index ¶
- type Callback
- type Connector
- func (c *Connector) Close()
- func (c *Connector) Connected() bool
- func (c *Connector) Deserialize(data []byte, v interface{}) error
- func (c *Connector) GetMid() uint64
- func (c *Connector) Name() string
- func (c *Connector) Notify(route string, v interface{}) error
- func (c *Connector) On(event string, callback Callback)
- func (c *Connector) OnConnected(callback Callback)
- func (c *Connector) OnUnexpectedEvent(callback Callback)
- func (c *Connector) Ready() <-chan struct{}
- func (c *Connector) Request(route string, v interface{}, callback Callback) error
- func (c *Connector) Send(data []byte)
- func (c *Connector) Serialize(v interface{}) ([]byte, error)
- func (c *Connector) Start(addr string) (err error)
- type Option
- func WithBranch(branch uint32) Option
- func WithCodec(codec codec.Codec) Option
- func WithDictionary(dictionary message.Dictionary) Option
- func WithIsWebSocket(isWebSocket bool) Option
- func WithLogger(l log.Logger) Option
- func WithName(name string) Option
- func WithSerializerType(serializerType serializer.SerializerType) Option
- func WithShortVersion(shortVersion uint32) Option
- func WithWebSocketCompression(webSocketCompression bool) Option
- func WithWebSocketPath(path string) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback func(data interface{})
Callback represents the callback type which will be called when the correspond events is occurred.
type Connector ¶
type Connector struct { Options // contains filtered or unexported fields }
Connector is a tiny Nano client
func NewConnector ¶
NewConnector create a new Connector
func (*Connector) Close ¶
func (c *Connector) Close()
Close closes the connection, and shutdown the benchmark
func (*Connector) Deserialize ¶
Deserialize Unmarshals byte slice into customized data
func (*Connector) OnConnected ¶
OnConnected set the callback which will be called when the client connected to the server
func (*Connector) OnUnexpectedEvent ¶
OnUnexpectedEvent sets callback for events that are not "On"
func (*Connector) Request ¶
Request send a request to server and register a callbck for the response
type Option ¶
type Option func(options *Options)
Option used to customize handler
func WithBranch ¶ added in v1.0.1
func WithDictionary ¶
func WithDictionary(dictionary message.Dictionary) Option
func WithIsWebSocket ¶ added in v1.0.1
func WithSerializerType ¶ added in v1.1.10
func WithSerializerType(serializerType serializer.SerializerType) Option
WithSerializerType customizes application serializer, which automatically Marshal and UnMarshal handler payload
func WithShortVersion ¶ added in v1.0.6
func WithWebSocketCompression ¶ added in v1.1.32
func WithWebSocketPath ¶ added in v1.1.32
WithWebSocketPath set the websocket path
type Options ¶
type Options struct { SerializerType serializer.SerializerType // serializer for connector WebSocketPath string // websocket path IsWebSocket bool // is websocket Logger log.Logger // logger Codec codec.Codec // codec Dictionary message.Dictionary // dictionary Branch uint32 ShortVersion uint32 WebSocketCompression bool // contains filtered or unexported fields }
Options contains some configurations for connector