inmem

package
v0.0.0-...-471d7c0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2016 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	UserDB
}

DB is an in-memory database.

func NewDB

func NewDB() *DB

NewDB creates a new in-memory database.

type Queue

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

Queue is a message queue for queueing and sending messages to users.

func NewQueue

func NewQueue(senderFunc SenderFunc) *Queue

NewQueue creates a new queue object.

func (*Queue) AddRequest

func (q *Queue) AddRequest(userID string, method string, params interface{}, resHandler func(ctx *neptulon.ResCtx) error) error

AddRequest queues a request message to be sent to the given user.

func (*Queue) Middleware

func (q *Queue) Middleware(ctx *neptulon.ReqCtx) error

Middleware registers a queue middleware to register user/connection IDs for connecting users (upon their first incoming-message).

func (*Queue) RemoveConn

func (q *Queue) RemoveConn(userID string)

RemoveConn removes a user's associated connection ID.

type SenderFunc

type SenderFunc func(connID string, method string, params interface{}, resHandler func(ctx *neptulon.ResCtx) error) (reqID string, err error)

SenderFunc is a function for sending messages over connections ID.

type UserDB

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

UserDB is in-memory user database.

func (UserDB) GetByEmail

func (db UserDB) GetByEmail(email string) (u *models.User, ok bool)

GetByEmail retrieves a user by e-mail address.

func (UserDB) GetByID

func (db UserDB) GetByID(id string) (u *models.User, ok bool)

GetByID retrieves a user by ID.

func (UserDB) SaveUser

func (db UserDB) SaveUser(u *models.User) error

SaveUser save or updates a user object in the database.

func (UserDB) Seed

func (db UserDB) Seed(overwrite bool, jwtPass string) error

Seed seeds database with essential data.

Jump to

Keyboard shortcuts

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