Documentation ¶
Index ¶
Constants ¶
View Source
const ( CmdProtoVersion = "version" CmdReadKey = "kget" CmdReadBulk = "kget-bulk" CmdReadPrefix = "kget-all" CmdWriteKey = "kset" CmdWriteBulk = "kset-bulk" CmdSubscribeKey = "ksub" CmdSubscribePrefix = "ksub-prefix" CmdUnsubscribeKey = "kunsub" CmdUnsubscribePrefix = "kunsub-prefix" CmdListKeys = "klist" CmdAuthRequest = "klogin" CmdAuthChallenge = "kauth" )
Commands
View Source
const ( ErrServerError = "server error" ErrInvalidFmt = "invalid message format" ErrMissingParam = "required parameter missing" ErrUnknownCmd = "unknown command" ErrAuthNotInit = "authentication not initialized" ErrAuthFailed = "authentication failed" ErrAuthRequired = "authentication required" )
View Source
const ProtoVersion = "v6"
Variables ¶
View Source
var (
ErrClientNotFound = errors.New("client not found")
)
Functions ¶
Types ¶
type Client ¶
type Client interface { Options() ClientOptions Close() SendMessage([]byte) SendJSON(interface{}) SetUID(int64) UID() int64 }
Client is a middleman between the websocket connection and the hub.
type ClientOptions ¶
type ClientOptions struct { // Adds a prefix to all key operations to restrict them to a namespace Namespace string }
ClientOptions is a list of tweakable options for clients
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func NewHub ¶
func NewHub(db *badger.DB, options HubOptions, logger logrus.FieldLogger) (*Hub, error)
func (*Hub) CreateClient ¶
func (hub *Hub) CreateClient(w http.ResponseWriter, r *http.Request, options ClientOptions)
CreateClient upgrades a HTTP request to websocket and makes it a client for the hub
func (*Hub) SetOptions ¶
func (hub *Hub) SetOptions(options HubOptions)
type HubOptions ¶
type HubOptions struct {
Password string
}
type WebsocketClient ¶
type WebsocketClient struct {
// contains filtered or unexported fields
}
func (*WebsocketClient) Close ¶
func (c *WebsocketClient) Close()
func (*WebsocketClient) Options ¶
func (c *WebsocketClient) Options() ClientOptions
func (*WebsocketClient) SendJSON ¶
func (c *WebsocketClient) SendJSON(data interface{})
func (*WebsocketClient) SendMessage ¶
func (c *WebsocketClient) SendMessage(data []byte)
func (*WebsocketClient) SetUID ¶
func (c *WebsocketClient) SetUID(uid int64)
func (*WebsocketClient) UID ¶
func (c *WebsocketClient) UID() int64
Source Files ¶
Click to show internal directories.
Click to hide internal directories.