api

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ChannelsHashPrefix string = "beaver.channel"

ChannelsHashPrefix is the hash prefix

View Source
const ClientsHashPrefix string = "beaver.client"

ClientsHashPrefix is the hash prefix

View Source
const ConfigsHashPrefix string = "beaver.config"

ConfigsHashPrefix is the hash prefix

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Driver *driver.Redis
}

Channel struct

func (*Channel) ChannelExist

func (c *Channel) ChannelExist(channel string) (bool, error)

ChannelExist checks if channel exists

func (*Channel) ChannelScan

func (c *Channel) ChannelScan(channel string) *redis.ScanCmd

ChannelScan get clients under channel listeners (connected clients)

func (*Channel) ChannelsExist

func (c *Channel) ChannelsExist(channels []string) (bool, error)

ChannelsExist checks if channels exist

func (*Channel) CountListeners

func (c *Channel) CountListeners(name string) int64

CountListeners counts channel listeners

func (*Channel) CountSubscribers

func (c *Channel) CountSubscribers(name string) int64

CountSubscribers counts channel subscribers

func (*Channel) CreateChannel

func (c *Channel) CreateChannel(channel ChannelResult) (bool, error)

CreateChannel creates a channel

func (*Channel) DeleteChannelByName

func (c *Channel) DeleteChannelByName(name string) (bool, error)

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

func (c *Channel) GetListeners(channel string) []string

GetListeners gets a list of listeners with channel name

func (*Channel) GetSubscribers

func (c *Channel) GetSubscribers(channel string) []string

GetSubscribers gets a list of subscribers with channel name

func (*Channel) Init

func (c *Channel) Init() bool

Init initialize the redis connection

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

type Client struct {
	Driver *driver.Redis
}

Client struct

func (*Client) AddToChannel

func (c *Client) AddToChannel(ID string, channel string) (bool, error)

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

func (c *Client) DeleteClientByID(ID string) (bool, error)

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) Init

func (c *Client) Init() bool

Init initialize the redis connection

func (*Client) RemoveFromChannel

func (c *Client) RemoveFromChannel(ID string, channel string) (bool, error)

RemoveFromChannel removes a client from a channel

func (*Client) Subscribe

func (c *Client) Subscribe(ID string, channels []string) (bool, error)

Subscribe to channels

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(ID string, channels []string) (bool, error)

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

type Config struct {
	Driver *driver.Redis
}

Config struct

func (*Config) CreateConfig

func (c *Config) CreateConfig(key string, value string) (bool, error)

CreateConfig creates a config

func (*Config) DeleteConfigByKey

func (c *Config) DeleteConfigByKey(key string) (bool, error)

DeleteConfigByKey deletes a config with key

func (*Config) GetConfigByKey

func (c *Config) GetConfigByKey(key string) (string, error)

GetConfigByKey gets a config value with key

func (*Config) Init

func (c *Config) Init() bool

Init initialize the redis connection

func (*Config) UpdateConfigByKey

func (c *Config) UpdateConfigByKey(key string, value string) (bool, error)

UpdateConfigByKey updates a config with key

type ConfigResult

type ConfigResult struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL