Documentation ¶
Index ¶
- Constants
- Variables
- func WaitTokenTimeout(t Token, d time.Duration) error
- type Client
- type ClientOptions
- func (o *ClientOptions) AddServer(server string) *ClientOptions
- func (o *ClientOptions) SetConnectTimeout(k time.Duration) *ClientOptions
- func (o *ClientOptions) SetConnectionAttemptHandler(onConnectAttempt ConnectionAttemptHandler) *ClientOptions
- func (o *ClientOptions) SetHeartbeat(k time.Duration) *ClientOptions
- func (o *ClientOptions) SetTlsConfig(config *tls.Config) *ClientOptions
- func (o *ClientOptions) SetToken(id string) *ClientOptions
- func (o *ClientOptions) SetWriteTimeout(k time.Duration) *ClientOptions
- type ConnectToken
- func (b *ConnectToken) Done() <-chan struct{}
- func (b *ConnectToken) Error() error
- func (b *ConnectToken) HandlerError(e error)
- func (c *ConnectToken) ReturnCode() byte
- func (b *ConnectToken) SetErrorHandler(f func(error))
- func (b *ConnectToken) Wait() bool
- func (b *ConnectToken) WaitTimeout(d time.Duration) bool
- type ConnectionAttemptHandler
- type ConnectionLostHandler
- type DisconnectToken
- type Logger
- type Message
- type MessageHandler
- type NOOPLogger
- type PacketAndToken
- type PushToken
- type ReconnectHandler
- type Token
- type TokenErrorSetter
Constants ¶
View Source
const ( NET string = "[net] " CLI string = "[client] " )
Variables ¶
View Source
var ( RefusedNotAuthorisedErr = errors.New("The server has rejected our request. Please check your permissions") ProtocolViolationErr = errors.New("The server has rejected our request. Please check your permissions") )
View Source
var ErrNotConnected = errors.New("not Connected")
View Source
var TimedOut = errors.New("context canceled")
Functions ¶
Types ¶
type Client ¶
type Client interface { IsConnected() bool Connect() Token Push(payload interface{}) Token Disconnect(quiesce uint) AddPayloadHandlerLast(handler MessageHandler) }
func NewClient ¶
func NewClient(o *ClientOptions) Client
type ClientOptions ¶
type ClientOptions struct { Servers []*url.URL Token string Heartbeat int64 ProtocolVersion uint ConnectRetry bool ConnectRetryInterval time.Duration ConnectTimeout time.Duration WriteTimeout time.Duration AutoReconnect bool OnConnectionLost ConnectionLostHandler MaxReconnectInterval time.Duration OnReconnecting ReconnectHandler TLSConfig *tls.Config OnConnectAttempt ConnectionAttemptHandler }
func NewClientOptions ¶
func NewClientOptions() *ClientOptions
func (*ClientOptions) AddServer ¶
func (o *ClientOptions) AddServer(server string) *ClientOptions
func (*ClientOptions) SetConnectTimeout ¶
func (o *ClientOptions) SetConnectTimeout(k time.Duration) *ClientOptions
func (*ClientOptions) SetConnectionAttemptHandler ¶
func (o *ClientOptions) SetConnectionAttemptHandler(onConnectAttempt ConnectionAttemptHandler) *ClientOptions
func (*ClientOptions) SetHeartbeat ¶
func (o *ClientOptions) SetHeartbeat(k time.Duration) *ClientOptions
func (*ClientOptions) SetTlsConfig ¶
func (o *ClientOptions) SetTlsConfig(config *tls.Config) *ClientOptions
func (*ClientOptions) SetToken ¶
func (o *ClientOptions) SetToken(id string) *ClientOptions
func (*ClientOptions) SetWriteTimeout ¶
func (o *ClientOptions) SetWriteTimeout(k time.Duration) *ClientOptions
type ConnectToken ¶
type ConnectToken struct {
// contains filtered or unexported fields
}
func (*ConnectToken) Done ¶
func (b *ConnectToken) Done() <-chan struct{}
Done implements the Token Done method.
func (*ConnectToken) HandlerError ¶
func (b *ConnectToken) HandlerError(e error)
func (*ConnectToken) ReturnCode ¶
func (c *ConnectToken) ReturnCode() byte
func (*ConnectToken) SetErrorHandler ¶
func (b *ConnectToken) SetErrorHandler(f func(error))
func (*ConnectToken) WaitTimeout ¶
type ConnectionLostHandler ¶
type DisconnectToken ¶
type DisconnectToken struct {
// contains filtered or unexported fields
}
func (*DisconnectToken) Done ¶
func (b *DisconnectToken) Done() <-chan struct{}
Done implements the Token Done method.
func (*DisconnectToken) HandlerError ¶
func (b *DisconnectToken) HandlerError(e error)
func (*DisconnectToken) SetErrorHandler ¶
func (b *DisconnectToken) SetErrorHandler(f func(error))
func (*DisconnectToken) WaitTimeout ¶
type Logger ¶
type Logger interface { Println(v ...interface{}) Printf(format string, v ...interface{}) }
var ( ERROR Logger = NOOPLogger{} INFO Logger = NOOPLogger{} WARN Logger = NOOPLogger{} DEBUG Logger = NOOPLogger{} )
type MessageHandler ¶
type NOOPLogger ¶
type NOOPLogger struct{}
func (NOOPLogger) Printf ¶
func (NOOPLogger) Printf(format string, v ...interface{})
func (NOOPLogger) Println ¶
func (NOOPLogger) Println(v ...interface{})
type PacketAndToken ¶
type PacketAndToken struct {
// contains filtered or unexported fields
}
type PushToken ¶
type PushToken struct {
// contains filtered or unexported fields
}
func (*PushToken) Done ¶
func (b *PushToken) Done() <-chan struct{}
Done implements the Token Done method.
func (*PushToken) HandlerError ¶
func (b *PushToken) HandlerError(e error)
func (*PushToken) SetErrorHandler ¶
func (b *PushToken) SetErrorHandler(f func(error))
func (*PushToken) WaitTimeout ¶
type ReconnectHandler ¶
type ReconnectHandler func(Client, *ClientOptions)
type TokenErrorSetter ¶
type TokenErrorSetter interface {
// contains filtered or unexported methods
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.