Documentation ¶
Index ¶
- Constants
- Variables
- func RandomMessageID(prefix string) string
- func ReadDate(value string) (time.Time, error)
- func ReadDateTime(value string, utc bool) (time.Time, error)
- func ReadLocalDateTime(value string) (time.Time, error)
- func ReadTime(value string) (time.Time, error)
- func ReadUTCDateTime(value string) (time.Time, error)
- func ReadZoneDateTime(value string) (time.Time, error)
- func WriteDate(value time.Time) string
- func WriteLocalDateTime(value time.Time) string
- func WriteTime(value time.Time) string
- func WriteUTCDateTime(value time.Time) string
- func WriteZoneDateTime(value time.Time) string
- type AuthApiKey
- type AuthBasic
- type AuthCustom
- type AuthToken
- type Authorization
- type BinaryMarshaller
- type ClientSocketTransport
- type ClientTransport
- func NewHTTPClientTransport(endpoint string, timeout time.Duration) ClientTransport
- func NewHTTPClientTransportEx(endpoint string, timeout time.Duration, skipSSLVerify bool, ...) ClientTransport
- func NewWebSocketClientTransport(endpoint string, subprotocols []string) (ClientTransport, error)
- func NewWebSocketClientTransportEx(endpoint string, timeout time.Duration, skipSSLVerify bool, ...) (ClientTransport, error)
- type ConnectionContext
- type ConnectionHandlers
- type Dispatcher
- type JSONMarshaller
- type LogLevel
- type Logger
- type Marshaller
- type OnAuth
- type OnConnect
- type OnDisconnect
- type ServiceDispatcher
- type SystemContext
- type TransportHeaders
- type WebSocketFailureMessage
- type WebSocketMessageBase
- type WebSocketRequestMessage
- type WebSocketResponseMessage
- type WebSocketServerTransport
Constants ¶
View Source
const ( DefaultWriteWaitTime = 10 * time.Second DefaultPongWaitTime = 60 * time.Second DefaultPingPeriod = (DefaultPongWaitTime * 9) / 10 DefaultMaxPackageSize = 1024 * 1024 * 16 // 16 MB DefaultReadBufferSize = 1024 * 8 // 8 KB DefaultWriteBufferSize = 1024 * 8 // 8 KB DefaultProcessingThreads = 2 DefaultRegistrationBuffer = 2 DefaultConnectionBuffer = 5 MessageRandomSymbols = "abcdefghijklmnopqrstuvwxyz0123456789" MessageRandomLength = 32 MessageKindFailure = "?:failure" MessageKindRPCRequest = "rpc:request" MessageKindRPCResponse = "rpc:response" MessageKindRPCFailure = "rpc:failure" MessageKindBuzzerRequest = "buzzer:request" MessageKindBuzzerResponse = "buzzer:request" MessageKindBuzzerFailure = "buzzer:request" MessageKindStreamS2C = "stream:s2c" MessageKindStreamC2S = "stream:c2s" )
View Source
const (
DefaultTimeout = time.Second * 60
)
Variables ¶
View Source
var DATETIME_FORMATS = []string{
"2006-01-02T15:04:05Z07:00",
"2006-01-02T15:04:05.0Z07:00",
"2006-01-02T15:04:05.00Z07:00",
"2006-01-02T15:04:05.000Z07:00",
"2006-01-02T15:04:05.0000Z07:00",
"2006-01-02T15:04:05.00000Z07:00",
"2006-01-02T15:04:05.000000Z07:00",
"2006-01-02T15:04:05.0000000Z07:00",
"2006-01-02T15:04:05.00000000Z07:00",
"2006-01-02T15:04:05.000000000Z07:00",
"2006-01-02T15:04:05Z",
"2006-01-02T15:04:05.0Z",
"2006-01-02T15:04:05.00Z",
"2006-01-02T15:04:05.000Z",
"2006-01-02T15:04:05.0000Z",
"2006-01-02T15:04:05.00000Z",
"2006-01-02T15:04:05.000000Z",
"2006-01-02T15:04:05.0000000Z",
"2006-01-02T15:04:05.00000000Z",
"2006-01-02T15:04:05.000000000Z",
"2006-01-02T15:04:05",
"2006-01-02T15:04:05.0",
"2006-01-02T15:04:05.00",
"2006-01-02T15:04:05.000",
"2006-01-02T15:04:05.0000",
"2006-01-02T15:04:05.00000",
"2006-01-02T15:04:05.000000",
"2006-01-02T15:04:05.0000000",
"2006-01-02T15:04:05.00000000",
"2006-01-02T15:04:05.000000000",
}
TODO Replace with better logic than brute-forcing this thing
Functions ¶
func RandomMessageID ¶
func WriteLocalDateTime ¶
func WriteUTCDateTime ¶
func WriteZoneDateTime ¶
Types ¶
type AuthApiKey ¶
type AuthApiKey struct {
ApiKey string
}
func NewAuthApiKey ¶
func NewAuthApiKey(apiKey string) *AuthApiKey
type AuthBasic ¶
func NewAuthBasic ¶
type AuthCustom ¶
type AuthCustom struct {
Value string
}
func NewAuthCustom ¶
func NewAuthCustom(value string) *AuthCustom
type Authorization ¶
type Authorization struct { ApiKey *AuthApiKey Token *AuthToken Basic *AuthBasic Custom *AuthCustom }
func (*Authorization) Reset ¶
func (c *Authorization) Reset()
func (*Authorization) ToValue ¶
func (c *Authorization) ToValue() string
func (*Authorization) UpdateFromHeaders ¶
func (c *Authorization) UpdateFromHeaders(h http.Header) error
func (*Authorization) UpdateFromRequest ¶
func (c *Authorization) UpdateFromRequest(r http.Request) error
func (*Authorization) UpdateFromValue ¶
func (c *Authorization) UpdateFromValue(auth string) error
type BinaryMarshaller ¶
type BinaryMarshaller struct { }
func NewBinaryMarshaller ¶
func NewBinaryMarshaller() *BinaryMarshaller
func (*BinaryMarshaller) Marshal ¶
func (m *BinaryMarshaller) Marshal(data interface{}) ([]byte, error)
func (*BinaryMarshaller) Unmarshal ¶
func (m *BinaryMarshaller) Unmarshal(data []byte, model interface{}) error
type ClientSocketTransport ¶
type ClientSocketTransport interface { ClientTransport }
type ClientTransport ¶
type ClientTransport interface { GetAuthorization() *Authorization SetAuthorization(auth *Authorization) error GetHeaders() TransportHeaders SetHeaders(headers TransportHeaders) error Send(service string, method string, dataIn interface{}, dataOut interface{}) error }
Client Specific
func NewHTTPClientTransport ¶
func NewHTTPClientTransport(endpoint string, timeout time.Duration) ClientTransport
func NewHTTPClientTransportEx ¶
func NewHTTPClientTransportEx(endpoint string, timeout time.Duration, skipSSLVerify bool, marshaller Marshaller, logger Logger) ClientTransport
func NewWebSocketClientTransport ¶
func NewWebSocketClientTransport(endpoint string, subprotocols []string) (ClientTransport, error)
func NewWebSocketClientTransportEx ¶
func NewWebSocketClientTransportEx(endpoint string, timeout time.Duration, skipSSLVerify bool, subprotocols []string, enableCompression bool, marshaller Marshaller, logger Logger) (ClientTransport, error)
type ConnectionContext ¶
type ConnectionContext struct { System *SystemContext User interface{} }
type ConnectionHandlers ¶
type ConnectionHandlers struct { OnConnect OnConnect OnAuth OnAuth OnDisconnect OnDisconnect }
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func (*Dispatcher) Register ¶
func (d *Dispatcher) Register(dispatcher ServiceDispatcher) error
func (*Dispatcher) Unregister ¶
func (d *Dispatcher) Unregister(serviceName string) bool
type JSONMarshaller ¶
type JSONMarshaller struct {
// contains filtered or unexported fields
}
func NewJSONMarshaller ¶
func NewJSONMarshaller(pretty bool) *JSONMarshaller
func (*JSONMarshaller) Marshal ¶
func (m *JSONMarshaller) Marshal(data interface{}) ([]byte, error)
func (*JSONMarshaller) Unmarshal ¶
func (m *JSONMarshaller) Unmarshal(data []byte, model interface{}) error
type Marshaller ¶
type OnAuth ¶
type OnAuth func(connection *ConnectionContext) error
type OnConnect ¶
type OnConnect func(connection *ConnectionContext, request *http.Request) error
Server specific
type OnDisconnect ¶
type OnDisconnect func(connection *ConnectionContext)
type ServiceDispatcher ¶
type SystemContext ¶
type SystemContext struct { RemoteAddr string Auth *Authorization }
type TransportHeaders ¶
type WebSocketFailureMessage ¶
type WebSocketMessageBase ¶
type WebSocketMessageBase struct {
Kind string `json:"kind"`
}
type WebSocketRequestMessage ¶
type WebSocketResponseMessage ¶
type WebSocketResponseMessage struct { Kind string `json:"kind"` Ref string `json:"ref"` Data json.RawMessage `json:"data,omitempty"` }
type WebSocketServerTransport ¶
type WebSocketServerTransport struct {
// contains filtered or unexported fields
}
func NewWebSocketServerTransport ¶
func NewWebSocketServerTransport(dispatcher *Dispatcher, handlers *ConnectionHandlers) *WebSocketServerTransport
func NewWebSocketServerTransportEx ¶
func NewWebSocketServerTransportEx(dispatcher *Dispatcher, marshaller Marshaller, logger Logger, handlers *ConnectionHandlers) *WebSocketServerTransport
func (*WebSocketServerTransport) ServeWS ¶
func (t *WebSocketServerTransport) ServeWS(w http.ResponseWriter, r *http.Request)
func (*WebSocketServerTransport) Start ¶
func (t *WebSocketServerTransport) Start()
func (*WebSocketServerTransport) Stop ¶
func (t *WebSocketServerTransport) Stop()
Click to show internal directories.
Click to hide internal directories.