common

package
v0.0.0-...-19cfaaf Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDBNotOpen      = errors.New("db not open")
	ErrNoResult       = errors.New("no result")
	ErrInvalidUser    = errors.New("invalid user")
	ErrInvalidMessage = errors.New("invalid message")
)

Functions

This section is empty.

Types

type Message

type Message struct {
	MessageID int64         `json:"id"`
	From      *User         `json:"from"`
	To        *User         `json:"to"`
	Content   []byte        `json:"content,omitempty"`
	CreatedAt time.Time     `json:"created_at"`
	Duration  time.Duration `json:"duration"`
	Played    bool          `json:"played"`
	Path      string        `json:"path"`
	RemoteURL string        `json:"remote_url"`
}

func NewMessage

func NewMessage(from, to *User) *Message

type SqliteStoreOptions

type SqliteStoreOptions struct {
	DBPath string
}

type Store

type Store interface {
	AddUser(user *User) error
	FindUser(userID int64) (*User, error)
	FindUserByName(name string) ([]*User, error)
	FindUserByKey(key string) (*User, error)
	GetUserMessages(key string) ([]*Message, error)

	AddMessage(msg *Message) error
	UpdateMessagePlayed(msgID int64, played bool) error
	DeleteMessage(msgID int64) error
	GetMessage(msgID int64) (*Message, error)

	Close()
}

type StoreSqlite

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

func NewStoreSqlite

func NewStoreSqlite(options *SqliteStoreOptions) *StoreSqlite

func (*StoreSqlite) AddMessage

func (s *StoreSqlite) AddMessage(msg *Message) error

func (*StoreSqlite) AddUser

func (s *StoreSqlite) AddUser(user *User) error

func (*StoreSqlite) Close

func (s *StoreSqlite) Close()

func (*StoreSqlite) DeleteMessage

func (s *StoreSqlite) DeleteMessage(msgID int64) error

func (*StoreSqlite) FindUser

func (s *StoreSqlite) FindUser(userID int64) (*User, error)

func (*StoreSqlite) FindUserByKey

func (s *StoreSqlite) FindUserByKey(key string) (*User, error)

func (*StoreSqlite) FindUserByName

func (s *StoreSqlite) FindUserByName(name string) ([]*User, error)

func (*StoreSqlite) GetMessage

func (s *StoreSqlite) GetMessage(msgID int64) (*Message, error)

func (*StoreSqlite) GetUserMessages

func (s *StoreSqlite) GetUserMessages(key string) ([]*Message, error)

func (*StoreSqlite) UpdateMessagePlayed

func (s *StoreSqlite) UpdateMessagePlayed(msgID int64, played bool) error

type User

type User struct {
	UserID int64  `json:"id"`
	Key    string `json:"key"`
	Name   string `json:"name"`
	Email  string `json:"email"`
}

Jump to

Keyboard shortcuts

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