Documentation ¶
Index ¶
- Constants
- type Channel
- func (c *Channel) ChannelExist(channel string) (bool, error)
- func (c *Channel) ChannelScan(channel string) *redis.ScanCmd
- func (c *Channel) ChannelsExist(channels []string) (bool, error)
- func (c *Channel) CountListeners(name string) int64
- func (c *Channel) CountSubscribers(name string) int64
- func (c *Channel) CreateChannel(channel ChannelResult) (bool, error)
- func (c *Channel) DeleteChannelByName(name string) (bool, error)
- func (c *Channel) GetChannelByName(name string) (ChannelResult, error)
- func (c *Channel) GetListeners(channel string) []string
- func (c *Channel) GetSubscribers(channel string) []string
- func (c *Channel) Init() bool
- func (c *Channel) UpdateChannelByName(channel ChannelResult) (bool, error)
- type ChannelResult
- type Client
- func (c *Client) AddToChannel(ID string, channel string) (bool, error)
- func (c *Client) Connect(clientResult ClientResult) (bool, error)
- func (c *Client) CreateClient(client ClientResult) (bool, error)
- func (c *Client) DeleteClientByID(ID string) (bool, error)
- func (c *Client) Disconnect(clientResult ClientResult) (bool, error)
- func (c *Client) GetClientByID(ID string) (ClientResult, error)
- func (c *Client) Init() bool
- func (c *Client) RemoveFromChannel(ID string, channel string) (bool, error)
- func (c *Client) Subscribe(ID string, channels []string) (bool, error)
- func (c *Client) Unsubscribe(ID string, channels []string) (bool, error)
- func (c *Client) UpdateClientByID(client ClientResult) (bool, error)
- type ClientResult
- type Config
- type ConfigResult
Constants ¶
const ChannelsHashPrefix string = "beaver.channel"
ChannelsHashPrefix is the hash prefix
const ClientsHashPrefix string = "beaver.client"
ClientsHashPrefix is the hash prefix
const ConfigsHashPrefix string = "beaver.config"
ConfigsHashPrefix is the hash prefix
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
Channel struct
func (*Channel) ChannelExist ¶
ChannelExist checks if channel exists
func (*Channel) ChannelScan ¶
ChannelScan get clients under channel listeners (connected clients)
func (*Channel) ChannelsExist ¶
ChannelsExist checks if channels exist
func (*Channel) CountListeners ¶
CountListeners counts channel listeners
func (*Channel) CountSubscribers ¶
CountSubscribers counts channel subscribers
func (*Channel) CreateChannel ¶
func (c *Channel) CreateChannel(channel ChannelResult) (bool, error)
CreateChannel creates a channel
func (*Channel) DeleteChannelByName ¶
DeleteChannelByName deletes a channel with name
func (*Channel) GetChannelByName ¶
func (c *Channel) GetChannelByName(name string) (ChannelResult, error)
GetChannelByName gets a channel by name
func (*Channel) GetListeners ¶
GetListeners gets a list of listeners with channel name
func (*Channel) GetSubscribers ¶
GetSubscribers gets a list of subscribers with channel name
func (*Channel) UpdateChannelByName ¶
func (c *Channel) UpdateChannelByName(channel ChannelResult) (bool, error)
UpdateChannelByName updates a channel by name
type ChannelResult ¶
type ChannelResult struct { Name string `json:"name"` Type string `json:"type"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` }
ChannelResult struct
func (*ChannelResult) ConvertToJSON ¶
func (c *ChannelResult) ConvertToJSON() (string, error)
ConvertToJSON converts object to json
func (*ChannelResult) LoadFromJSON ¶
func (c *ChannelResult) LoadFromJSON(data []byte) (bool, error)
LoadFromJSON load object from json
type Client ¶
Client struct
func (*Client) AddToChannel ¶
AddToChannel adds a client to a channel
func (*Client) Connect ¶
func (c *Client) Connect(clientResult ClientResult) (bool, error)
Connect a client
func (*Client) CreateClient ¶
func (c *Client) CreateClient(client ClientResult) (bool, error)
CreateClient creates a client
func (*Client) DeleteClientByID ¶
DeleteClientByID deletes a client with ID
func (*Client) Disconnect ¶
func (c *Client) Disconnect(clientResult ClientResult) (bool, error)
Disconnect a client
func (*Client) GetClientByID ¶
func (c *Client) GetClientByID(ID string) (ClientResult, error)
GetClientByID gets a client by ID
func (*Client) RemoveFromChannel ¶
RemoveFromChannel removes a client from a channel
func (*Client) Unsubscribe ¶
Unsubscribe from channels
func (*Client) UpdateClientByID ¶
func (c *Client) UpdateClientByID(client ClientResult) (bool, error)
UpdateClientByID updates a client by ID
type ClientResult ¶
type ClientResult struct { ID string `json:"id"` Token string `json:"token"` Channels []string `json:"channels"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` }
ClientResult struct
func (*ClientResult) ConvertToJSON ¶
func (c *ClientResult) ConvertToJSON() (string, error)
ConvertToJSON converts object to json
func (*ClientResult) GenerateClient ¶
func (c *ClientResult) GenerateClient() (bool, error)
GenerateClient generates client ID & Token
func (*ClientResult) LoadFromJSON ¶
func (c *ClientResult) LoadFromJSON(data []byte) (bool, error)
LoadFromJSON load object from json
type Config ¶
Config struct
func (*Config) CreateConfig ¶
CreateConfig creates a config
func (*Config) DeleteConfigByKey ¶
DeleteConfigByKey deletes a config with key
func (*Config) GetConfigByKey ¶
GetConfigByKey gets a config value with key
type ConfigResult ¶
ConfigResult struct
func (*ConfigResult) ConvertToJSON ¶
func (c *ConfigResult) ConvertToJSON() (string, error)
ConvertToJSON converts object to json
func (*ConfigResult) LoadFromJSON ¶
func (c *ConfigResult) LoadFromJSON(data []byte) (bool, error)
LoadFromJSON load object from json