Documentation ¶
Index ¶
- Constants
- func Close() error
- func GetAuthHandler(name string) auth.AuthHandler
- func GetUid() types.Uid
- func GetUidString() string
- func InitDb(reset bool) error
- func IsOpen() bool
- func Open(jsonconf string) error
- func Register(name string, adapter adapter.Adapter)
- func RegisterAuthScheme(name string, handler auth.AuthHandler)
- type DeviceMapper
- type MessagesObjMapper
- func (MessagesObjMapper) Delete(topic string, forUser types.Uid, hard bool, cleared int) (err error)
- func (MessagesObjMapper) DeleteList(topic string, forUser types.Uid, hard bool, list []int) (err error)
- func (MessagesObjMapper) GetAll(topic string, forUser types.Uid, opt *types.BrowseOpt) ([]types.Message, error)
- func (MessagesObjMapper) Save(msg *types.Message) error
- type SubsObjMapper
- func (SubsObjMapper) Create(subs ...*types.Subscription) error
- func (SubsObjMapper) Delete(topic string, user types.Uid) error
- func (SubsObjMapper) Get(topic string, user types.Uid) (*types.Subscription, error)
- func (SubsObjMapper) Update(topic string, user types.Uid, update map[string]interface{}) error
- type TopicsObjMapper
- func (TopicsObjMapper) Create(topic *types.Topic, owner types.Uid, private interface{}) error
- func (TopicsObjMapper) CreateP2P(initiator, invited *types.Subscription) error
- func (TopicsObjMapper) Delete(topic string) error
- func (TopicsObjMapper) Get(topic string) (*types.Topic, error)
- func (TopicsObjMapper) GetSubs(topic string) ([]types.Subscription, error)
- func (TopicsObjMapper) GetUsers(topic string) ([]types.Subscription, error)
- func (TopicsObjMapper) GetUsersAny(topic string) ([]types.Subscription, error)
- func (TopicsObjMapper) Update(topic string, update map[string]interface{}) error
- type UsersObjMapper
- func (UsersObjMapper) AddAuthRecord(uid types.Uid, authLvl int, scheme, unique string, secret []byte, ...) (error, bool)
- func (u UsersObjMapper) Create(user *types.User, private interface{}) (*types.User, error)
- func (UsersObjMapper) Delete(id types.Uid, soft bool) error
- func (u UsersObjMapper) FindSubs(id types.Uid, query []interface{}) ([]types.Subscription, error)
- func (UsersObjMapper) Get(uid types.Uid) (*types.User, error)
- func (UsersObjMapper) GetAll(uid ...types.Uid) ([]types.User, error)
- func (UsersObjMapper) GetAuthRecord(scheme, unique string) (types.Uid, int, []byte, time.Time, error)
- func (u UsersObjMapper) GetSubs(id types.Uid) ([]types.Subscription, error)
- func (u UsersObjMapper) GetTopics(id types.Uid) ([]types.Subscription, error)
- func (u UsersObjMapper) GetTopicsAny(id types.Uid) ([]types.Subscription, error)
- func (UsersObjMapper) Update(uid types.Uid, update map[string]interface{}) error
- func (UsersObjMapper) UpdateAuthRecord(uid types.Uid, authLvl int, scheme, unique string, secret []byte, ...) (int, error)
- func (UsersObjMapper) UpdateLastSeen(uid types.Uid, userAgent string, when time.Time) error
- func (UsersObjMapper) UpdateStatus(id types.Uid, status interface{}) error
Constants ¶
const (
MAX_USERS_FOR_TOPIC = 32
)
Variables ¶
This section is empty.
Functions ¶
func GetAuthHandler ¶
func GetAuthHandler(name string) auth.AuthHandler
func Open ¶
Open initializes the persistence system. Adapter holds a connection pool for a single database.
jsonconf - configuration string
func Register ¶
Register makes a persistence adapter available by the provided name. If Register is called twice with the same name or if the adapter is nil, it panics. Name is currently unused, i.e. only a single adapter can be registered
func RegisterAuthScheme ¶
func RegisterAuthScheme(name string, handler auth.AuthHandler)
Register an authentication scheme handler
Types ¶
type DeviceMapper ¶
type DeviceMapper struct{}
Storage for device IDs, used to generate push notifications
var Devices DeviceMapper
type MessagesObjMapper ¶
type MessagesObjMapper struct{}
Messages struct to hold methods for persistence mapping for the Message object.
var Messages MessagesObjMapper
func (MessagesObjMapper) Delete ¶
func (MessagesObjMapper) Delete(topic string, forUser types.Uid, hard bool, cleared int) (err error)
Delete messages. Hard-delete if hard == tru, otherwise a soft-delete
func (MessagesObjMapper) DeleteList ¶
type SubsObjMapper ¶
type SubsObjMapper struct{}
Topics struct to hold methods for persistence mapping for the topic object.
var Subs SubsObjMapper
func (SubsObjMapper) Create ¶
func (SubsObjMapper) Create(subs ...*types.Subscription) error
func (SubsObjMapper) Delete ¶
func (SubsObjMapper) Delete(topic string, user types.Uid) error
Delete deletes a subscription
func (SubsObjMapper) Get ¶
func (SubsObjMapper) Get(topic string, user types.Uid) (*types.Subscription, error)
Get given subscription
type TopicsObjMapper ¶
type TopicsObjMapper struct{}
Topics struct to hold methods for persistence mapping for the topic object.
var Topics TopicsObjMapper
func (TopicsObjMapper) CreateP2P ¶
func (TopicsObjMapper) CreateP2P(initiator, invited *types.Subscription) error
CreateP2P creates a P2P topic by generating two user's subsciptions to each other.
func (TopicsObjMapper) Delete ¶
func (TopicsObjMapper) Delete(topic string) error
func (TopicsObjMapper) Get ¶
func (TopicsObjMapper) Get(topic string) (*types.Topic, error)
Get a single topic with a list of relevent users de-normalized into it
func (TopicsObjMapper) GetSubs ¶
func (TopicsObjMapper) GetSubs(topic string) ([]types.Subscription, error)
GetSubs loads a list of subscriptions to the given topic, user.Public and deleted subscriptions are not loaded
func (TopicsObjMapper) GetUsers ¶
func (TopicsObjMapper) GetUsers(topic string) ([]types.Subscription, error)
GetUsers loads subscriptions for topic plus loads user.Public
func (TopicsObjMapper) GetUsersAny ¶
func (TopicsObjMapper) GetUsersAny(topic string) ([]types.Subscription, error)
GetUsersAny is the same as GetUsers, except it loads deleted subscriptions too.
type UsersObjMapper ¶
type UsersObjMapper struct{}
Users struct to hold methods for persistence mapping for the User object.
var Users UsersObjMapper
Users is the ancor for storing/retrieving User objects
func (UsersObjMapper) AddAuthRecord ¶
func (UsersObjMapper) AddAuthRecord(uid types.Uid, authLvl int, scheme, unique string, secret []byte, expires time.Time) (error, bool)
Create a new authentication record for user
func (UsersObjMapper) Create ¶
CreateUser inserts User object into a database, updates creation time and assigns UID
func (UsersObjMapper) Delete ¶
func (UsersObjMapper) Delete(id types.Uid, soft bool) error
TODO(gene): implement
func (UsersObjMapper) FindSubs ¶
func (u UsersObjMapper) FindSubs(id types.Uid, query []interface{}) ([]types.Subscription, error)
GetSubs loads a list of subscriptions for the given user
func (UsersObjMapper) GetAuthRecord ¶
func (UsersObjMapper) GetAuthRecord(scheme, unique string) (types.Uid, int, []byte, time.Time, error)
Given a unique identifier and a authentication scheme name, fetch user ID and authentication secret
func (UsersObjMapper) GetSubs ¶
func (u UsersObjMapper) GetSubs(id types.Uid) ([]types.Subscription, error)
GetSubs loads a list of subscriptions for the given user
func (UsersObjMapper) GetTopics ¶
func (u UsersObjMapper) GetTopics(id types.Uid) ([]types.Subscription, error)
GetTopics load a list of user's subscriptions with Public field copied to subscription
func (UsersObjMapper) GetTopicsAny ¶
func (u UsersObjMapper) GetTopicsAny(id types.Uid) ([]types.Subscription, error)
GetTopics load a list of user's subscriptions with Public field copied to subscription. Deleted topics are returned too.
func (UsersObjMapper) Update ¶
func (UsersObjMapper) Update(uid types.Uid, update map[string]interface{}) error
func (UsersObjMapper) UpdateAuthRecord ¶
func (UsersObjMapper) UpdateAuthRecord(uid types.Uid, authLvl int, scheme, unique string, secret []byte, expires time.Time) (int, error)
Update authentication record with a new secret and expiration time
func (UsersObjMapper) UpdateLastSeen ¶
func (UsersObjMapper) UpdateStatus ¶
func (UsersObjMapper) UpdateStatus(id types.Uid, status interface{}) error