Documentation ¶
Overview ¶
****************************************************************************
- Storage schema *****************************************************************************
- System-accessible tables: ***************************
- 1. Customer (customer of the service) *****************************
- Customer-accessible tables: *****************************
- 2. Application (a customer may have multiple applications)
- 3. Application keys (an application may have multiple API keys) ****************************************
- Application/end-user-accessible tables ****************************************
- 4. User (end-user)
- 5. Session (data associated with logged-in user)
- 6. Topics (aka Inbox; a list of user's threads/conversations, with access rights, indexed by user id and by topic name, neither userId nor topicName are unique)
- 7. Messages (persistent store of messages)
- 8. Contacts (a.k.a. ledger, address book) ****************************************************************************
Index ¶
- Constants
- func Close() error
- func InitDb(reset bool) error
- func IsOpen() bool
- func Open(name, jsonconf string) error
- func Register(name string, adapter adapter.Adapter)
- func UidFromBytes(b []byte) types.Uid
- func ZeroUid() types.Uid
- type MessagesObjMapper
- func (MessagesObjMapper) Delete(appId uint32, uid types.Uid) error
- func (MessagesObjMapper) DeleteAll(appId uint32, user types.Uid, topic string) error
- func (MessagesObjMapper) GetAll(appid uint32, topic string, opt *types.BrowseOpt) ([]types.Message, error)
- func (MessagesObjMapper) Save(appid uint32, msg *types.Message) error
- type SubsObjMapper
- func (SubsObjMapper) Create(appid uint32, sub *types.Subscription) error
- func (SubsObjMapper) Delete(appid uint32, topic string, user types.Uid) error
- func (SubsObjMapper) Get(appid uint32, topic string, user types.Uid) (*types.Subscription, error)
- func (SubsObjMapper) Update(appid uint32, topic string, user types.Uid, update map[string]interface{}) error
- type TopicsObjMapper
- func (TopicsObjMapper) Create(appid uint32, topic *types.Topic, owner types.Uid, private interface{}) error
- func (TopicsObjMapper) CreateP2P(appid uint32, initiator, invited *types.Subscription) error
- func (TopicsObjMapper) Get(appid uint32, topic string) (*types.Topic, error)
- func (TopicsObjMapper) GetSubs(appid uint32, topic string, opts *types.BrowseOpt) ([]types.Subscription, error)
- func (TopicsObjMapper) GetUsers(appid uint32, topic string, opts *types.BrowseOpt) ([]types.Subscription, error)
- func (TopicsObjMapper) Update(appid uint32, topic string, update map[string]interface{}) error
- func (TopicsObjMapper) UpdateLastSeen(appid uint32, topic string, id types.Uid, tag string, when time.Time) error
- type UsersObjMapper
- func (UsersObjMapper) ChangeAuthCredential(appid uint32, uid types.Uid, scheme, secret string) error
- func (u UsersObjMapper) Create(appid uint32, user *types.User, scheme, secret string, private interface{}) (*types.User, error)
- func (UsersObjMapper) Delete(appId uint32, id types.Uid, soft bool) error
- func (UsersObjMapper) Find(appId uint32, params map[string]interface{}) ([]types.User, error)
- func (UsersObjMapper) Get(appid uint32, uid types.Uid) (*types.User, error)
- func (u UsersObjMapper) GetSubs(appid uint32, id types.Uid, opts *types.BrowseOpt) ([]types.Subscription, error)
- func (u UsersObjMapper) GetTopics(appid uint32, id types.Uid, opts *types.BrowseOpt) ([]types.Subscription, error)
- func (UsersObjMapper) Login(appid uint32, scheme, secret string) (types.Uid, error)
- func (UsersObjMapper) Update(appid uint32, uid types.Uid, update map[string]interface{}) error
- func (UsersObjMapper) UpdateStatus(appid uint32, id types.Uid, status interface{}) error
Constants ¶
const (
MAX_USERS_FOR_TOPIC = 32
)
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open initializes the persistence system. Adapter holds a connection pool for a single database.
name - the name of adapter to use 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 UidFromBytes ¶
Types ¶
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(appId uint32, uid types.Uid) error
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(appid uint32, sub *types.Subscription) error
func (SubsObjMapper) Get ¶
func (SubsObjMapper) Get(appid uint32, topic string, user types.Uid) (*types.Subscription, error)
type TopicsObjMapper ¶
type TopicsObjMapper struct{}
Topics struct to hold methods for persistence mapping for the topic object.
var Topics TopicsObjMapper
func (TopicsObjMapper) Create ¶
func (TopicsObjMapper) Create(appid uint32, topic *types.Topic, owner types.Uid, private interface{}) error
Create creates a topic and owner's subscription to topic
func (TopicsObjMapper) CreateP2P ¶
func (TopicsObjMapper) CreateP2P(appid uint32, initiator, invited *types.Subscription) error
CreateP2P creates a P2P topic by generating two user's subsciptions to each other.
func (TopicsObjMapper) GetSubs ¶
func (TopicsObjMapper) GetSubs(appid uint32, topic string, opts *types.BrowseOpt) ([]types.Subscription, error)
GetSubs loads a list of subscriptions to the given topic, user.Public is not loaded
func (TopicsObjMapper) GetUsers ¶
func (TopicsObjMapper) GetUsers(appid uint32, topic string, opts *types.BrowseOpt) ([]types.Subscription, error)
GetUsers loads subscriptions for topic plus loads user.Public
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) ChangeAuthCredential ¶
func (UsersObjMapper) ChangeAuthCredential(appid uint32, uid types.Uid, scheme, secret string) error
ChangePassword changes user's password in "basic" authentication scheme
func (UsersObjMapper) Create ¶
func (u UsersObjMapper) Create(appid uint32, user *types.User, scheme, secret string, private interface{}) (*types.User, error)
CreateUser inserts User object into a database, updates creation time and assigns UID
func (UsersObjMapper) GetSubs ¶
func (u UsersObjMapper) GetSubs(appid uint32, id types.Uid, opts *types.BrowseOpt) ([]types.Subscription, error)
GetSubs loads a list of subscriptions for the given user
func (UsersObjMapper) GetTopics ¶
func (u UsersObjMapper) GetTopics(appid uint32, id types.Uid, opts *types.BrowseOpt) ([]types.Subscription, error)
GetTopics is exacly the same as Topics.GetForUser
func (UsersObjMapper) Login ¶
Process user login. TODO(gene): abstract out the authentication scheme
func (UsersObjMapper) UpdateStatus ¶
func (UsersObjMapper) UpdateStatus(appid uint32, id types.Uid, status interface{}) error