enginegorm

package
v0.0.0-...-ca8e307 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2018 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(setter config.Setter) error

Configure is a Configurator function for Redis engine.

func Plugin

func Plugin(n *node.Node, c config.Getter) (engine.Engine, error)

Plugin returns new memory engine.

Types

type Config

type Config struct {
	URL      string
	Redis    string
	Dialects string
	Mode     string
	Go       int

	JPushMerchantKey    string
	JPushMerchantSecret string
	JPushConsumerKey    string
	JPushConsumerSecret string
	JpushUrl            string
	JpushDeviceUrl      string
	JpushReportUrl      string
}

type DBData

type DBData struct {
	ID uint `gorm:"primary_key"`

	UID       string            `json:"uid"`
	Channel   string            `json:"channel"`
	Client    string            `json:"client"`
	Data      raw.Raw           `json:"data"  gorm:"type:jsonb"`
	Info      *proto.ClientInfo `json:"info" gorm:"type:jsonb"`
	Read      bool              `json:"read"`
	Timestamp int64             `json:"timestamp"`

	Appkey pq.StringArray `json:"-" gorm:"type:varchar(125)[]"`
	Users  pq.StringArray `json:"-" gorm:"type:varchar(125)[]"`
	NUsers pq.StringArray `json:"-" gorm:"type:varchar(125)[]"`
}

func (DBData) TableName

func (d DBData) TableName() string

type DataBakup

type DataBakup struct {
	// contains filtered or unexported fields
}

func (*DataBakup) Scan

func (j *DataBakup) Scan(value interface{}) error

Scan scan value into Jsonb

func (DataBakup) Value

func (j DataBakup) Value() (driver.Value, error)

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func New

func New(n *node.Node, conf *Config) (*Engine, error)

New initializes Memory Engine.

func (*Engine) AddPresence

func (e *Engine) AddPresence(ch string, uid string, info proto.ClientInfo, expire int) error

AddPresence adds client info into presence hub.

func (*Engine) Channels

func (e *Engine) Channels() ([]string, error)

Channels returns all channels node currently subscribed on.

func (*Engine) Forbidden

func (e *Engine) Forbidden(raw.Raw) bool

func (*Engine) History

func (e *Engine) History(ch, appkey, client, last string, skip, limit int) ([]proto.Message, int, error)

History extracts history from history hub.

func (*Engine) Micro

func (e *Engine) Micro(connID string, cmd proto.MicroCommand) (proto.Response, error)

func (*Engine) Name

func (e *Engine) Name() string

Name returns a name of engine.

func (*Engine) Permission

func (e *Engine) Permission(eid, permission string) bool

func (*Engine) Presence

func (e *Engine) Presence(ch string) (map[string]proto.ClientInfo, error)

Presence extracts presence info from presence hub.

func (*Engine) PublishAdmin

func (e *Engine) PublishAdmin(message *proto.AdminMessage) <-chan error

PublishAdmin - see Engine interface description.

func (*Engine) PublishControl

func (e *Engine) PublishControl(message *proto.ControlMessage) <-chan error

PublishControl - see Engine interface description.

func (*Engine) PublishJoin

func (e *Engine) PublishJoin(message *proto.JoinMessage, opts *channel.Options) <-chan error

PublishJoin - see Engine interface description.

func (*Engine) PublishLeave

func (e *Engine) PublishLeave(message *proto.LeaveMessage, opts *channel.Options) <-chan error

PublishLeave - see Engine interface description.

func (*Engine) PublishMessage

func (e *Engine) PublishMessage(message *proto.Message, appkey, users, nusers string, opts *channel.Options) <-chan error

PublishMessage adds message into history hub and calls node ClientMsg method to handle message. We don't have any PUB/SUB here as Memory Engine is single node only.

func (*Engine) ReadMessage

func (e *Engine) ReadMessage(ch, msgid, uid string) (bool, error)

func (*Engine) RemovePresence

func (e *Engine) RemovePresence(ch, uid, user string) error

RemovePresence removes client info from presence hub.

func (*Engine) Run

func (e *Engine) Run() error

Run runs memory engine - we do not have any logic here as Memory Engine ready to work just after initialization.

func (*Engine) Save

func (e *Engine) Save()

func (*Engine) Shutdown

func (e *Engine) Shutdown() error

Shutdown shuts down engine.

func (*Engine) Subscribe

func (e *Engine) Subscribe(ch string) error

Subscribe is noop here.

func (*Engine) Unsubscribe

func (e *Engine) Unsubscribe(ch string) error

Unsubscribe node from channel. In case of memory engine its only job is to touch channel history for history lifetime period.

type Persence

type Persence struct {
	ID uint `gorm:"primary_key"`

	User      string `gorm:"user"`
	Channel   string `gorm:"channel"`
	ChannelID string `gorm:"channelid"`
	Online    bool   `gorm:"online"`
}

func (Persence) TableName

func (Persence) TableName() string

Jump to

Keyboard shortcuts

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