Documentation ¶
Overview ¶
Package store provides methods for registering and accessing database adapters.
Index ¶
- type Store
- func (s *Store) AddAuthRecord(uid st.Uid, authLvl auth.Level, scheme, unique string, secret []byte, ...) error
- func (s Store) Adp() types.Adapter
- func (s *Store) AuthGetAuthNames() []string
- func (s *Store) AuthGetLogicalAuthHandler(name string) types.AuthHandler
- func (s *Store) AuthGetUniqueRecord(scheme, unique string) (st.Uid, auth.Level, []byte, time.Time, error)
- func (s *Store) CredConfirm(id types.Uid, method string) error
- func (s *Store) CredDel(id types.Uid, method, value string) error
- func (s *Store) CredFail(id types.Uid, method string) error
- func (s *Store) CredGetActive(id types.Uid, method string) (*types.Credential, error)
- func (s *Store) CredGetAllCreds(id types.Uid, method string, validatedOnly bool) ([]types.Credential, error)
- func (s *Store) CredUpsert(cred *types.Credential) (bool, error)
- func (s *Store) DBClose() error
- func (s *Store) DBGetAdapterName() string
- func (s *Store) DBGetAdapterVersion() int
- func (s *Store) DBStats() func() interface{}
- func (s *Store) DelAuthRecords(uid st.Uid, scheme string) error
- func (s *Store) DevDelete(uid types.Uid, deviceID string) error
- func (s *Store) DevGetAll(uid ...types.Uid) (map[types.Uid][]types.DeviceDef, int, error)
- func (s *Store) DevUpdate(uid types.Uid, oldDeviceID string, dev *types.DeviceDef) error
- func (s *Store) FilesDeleteUnused(olderThan time.Time, limit int) error
- func (s *Store) FilesFinishUpload(fd *types.FileDef, success bool, size int64) (*types.FileDef, error)
- func (s *Store) FilesGet(fid string) (*types.FileDef, error)
- func (s *Store) FilesLinkAttachments(topic string, msgId types.Uid, attachments []string) error
- func (s *Store) FilesStartUpload(fd *types.FileDef) error
- func (s *Store) GetAuthHandler(name string) types.AuthHandler
- func (s *Store) GetAuthRecord(user st.Uid, scheme string) (string, auth.Level, []byte, time.Time, error)
- func (s *Store) GetMediaHandler() types.Handler
- func (s *Store) GetValidator(name string) validate.Validator
- func (s *Store) InitAuthLogicalNames(ln []string) error
- func (s *Store) MsgDeleteList(topic string, delID int, forUser types.Uid, ranges []types.Range) error
- func (s *Store) MsgGetAll(topic string, forUser types.Uid, opt *types.QueryOpt) ([]types.Message, error)
- func (s *Store) MsgGetDeleted(topic string, forUser types.Uid, opt *types.QueryOpt) ([]types.Range, int, error)
- func (s *Store) MsgSave(msg *types.Message, attachmentURLs []string, readBySender bool) (error, bool)
- func (s *Store) SetDefaultMediaHandler(name string, cfg interface{}) error
- func (s *Store) SubsCreate(subs ...*types.Subscription) error
- func (s *Store) SubsDelete(topic string, user types.Uid) error
- func (s *Store) SubsGetSubs(topic string, user types.Uid, keepDeleted bool) (*types.Subscription, error)
- func (s *Store) SubsUpdate(topic string, user types.Uid, update map[string]interface{}) error
- func (s *Store) TopCreate(topic *types.Topic, owner types.Uid, private interface{}) error
- func (s *Store) TopCreateP2P(initiator, invited *types.Subscription) error
- func (s *Store) TopDelete(topic string, isChan, hard bool) error
- func (s *Store) TopGet(topic string) (*types.Topic, error)
- func (s *Store) TopGetSubs(topic string, opts *types.QueryOpt) ([]types.Subscription, error)
- func (s *Store) TopGetSubsAny(topic string, opts *types.QueryOpt) ([]types.Subscription, error)
- func (s *Store) TopGetTopicSubs(topic string, opts *types.QueryOpt) ([]types.Subscription, error)
- func (s *Store) TopGetTopicSubsAny(topic string, opts *types.QueryOpt) ([]types.Subscription, error)
- func (s *Store) TopGetUsers(topic string, opts *types.QueryOpt) ([]types.Subscription, error)
- func (s *Store) TopGetUsersAny(topic string, opts *types.QueryOpt) ([]types.Subscription, error)
- func (s *Store) TopOwnerChange(topic string, newOwner types.Uid) error
- func (s *Store) TopUpdate(topic string, update map[string]interface{}) error
- func (s *Store) UpdateAuthRecord(uid st.Uid, authLvl auth.Level, scheme, unique string, secret []byte, ...) error
- func (s *Store) UsersCreate(user *types.User, private interface{}) (*types.User, error)
- func (s *Store) UsersDelete(id types.Uid, hard bool) error
- func (s *Store) UsersFindSubs(id types.Uid, required [][]string, optional []string, activeOnly bool) ([]types.Subscription, error)
- func (s *Store) UsersGet(uid types.Uid) (*types.User, error)
- func (s *Store) UsersGetAll(uid ...types.Uid) ([]types.User, error)
- func (s *Store) UsersGetAllCreds(id types.Uid, method string, validatedOnly bool) ([]types.Credential, error)
- func (s *Store) UsersGetByCred(method, value string) (types.Uid, error)
- func (s *Store) UsersGetChannels(id types.Uid) ([]string, error)
- func (s *Store) UsersGetOwnTopics(id types.Uid) ([]string, error)
- func (s *Store) UsersGetSubs(id types.Uid) ([]types.Subscription, error)
- func (s *Store) UsersGetTopics(id types.Uid, opts *types.QueryOpt) ([]types.Subscription, error)
- func (s *Store) UsersGetTopicsAny(id types.Uid, opts *types.QueryOpt) ([]types.Subscription, error)
- func (s *Store) UsersGetUnreadCount(ids ...types.Uid) (map[types.Uid]int, error)
- func (s *Store) UsersGetUnvalidated(lastUpdatedBefore time.Time, limit int) ([]types.Uid, error)
- func (s *Store) UsersUpdate(uid types.Uid, update map[string]interface{}) error
- func (s *Store) UsersUpdateLastSeen(uid types.Uid, userAgent string, when time.Time) error
- func (s *Store) UsersUpdateState(uid types.Uid, state types.ObjState) error
- func (s *Store) UsersUpdateTags(uid types.Uid, add, remove, reset []string) ([]string, error)
- type StoreArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct { UidGen *st.UidGenerator // contains filtered or unexported fields }
func NewStore ¶
NewStore() configure the selected db adapter (AdapterName), and opens the db connection TODO: register the available auth methods from the auth pkg
func (*Store) AddAuthRecord ¶
func (s *Store) AddAuthRecord(uid st.Uid, authLvl auth.Level, scheme, unique string, secret []byte, expires time.Time) error
AddAuthRecord creates a new authentication record for the given user.
func (*Store) AuthGetAuthNames ¶
AuthGetAuthNames returns all addressable auth handler names, logical
and hardcoded excluding those which are disabled like "basic:".
func (*Store) AuthGetLogicalAuthHandler ¶
func (s *Store) AuthGetLogicalAuthHandler(name string) types.AuthHandler
AuthGetLogicalAuthHandler returns an auth handler by logical name. If there is no
handler by that logical name it tries to find one by the hardcoded name.
func (*Store) AuthGetUniqueRecord ¶
func (s *Store) AuthGetUniqueRecord(scheme, unique string) (st.Uid, auth.Level, []byte, time.Time, error)
GetAuthUniqueRecord takes a unique identifier and a authentication scheme name, fetches user ID and authentication secret.
func (*Store) CredConfirm ¶
ConfirmCred marks credential method as confirmed.
func (*Store) CredDel ¶
DelCred deletes user's credentials. If method is "", all credentials are deleted.
func (*Store) CredGetActive ¶
GetActiveCred gets a the currently active credential for the given user and method.
func (*Store) CredGetAllCreds ¶
func (s *Store) CredGetAllCreds(id types.Uid, method string, validatedOnly bool) ([]types.Credential, error)
GetAllCreds returns credentials of the given user, all or validated only.
func (*Store) CredUpsert ¶
func (s *Store) CredUpsert(cred *types.Credential) (bool, error)
UpsertCred adds or updates a credential validation request. Return true if the record was inserted, false if updated.
func (*Store) DBGetAdapterName ¶
func (*Store) DBGetAdapterVersion ¶
func (*Store) DBStats ¶
func (s *Store) DBStats() func() interface{}
DBStats() returns a callback returning db connection stats object.
func (*Store) DelAuthRecords ¶
DelAuthRecords deletes user's auth records of the given scheme.
func (*Store) DevGetAll ¶
GetAll returns all known device IDs for a given list of user IDs. The second return parameter is the count of found device IDs.
func (*Store) FilesDeleteUnused ¶
DeleteUnused removes unused attachments and avatars.
func (*Store) FilesFinishUpload ¶
func (s *Store) FilesFinishUpload(fd *types.FileDef, success bool, size int64) (*types.FileDef, error)
FinishUpload marks started upload as successfully finished or failed.
func (*Store) FilesLinkAttachments ¶
LinkAttachments connects earlier uploaded attachments to a
message or topic to prevent it from being garbage collected.
func (*Store) FilesStartUpload ¶
StartUpload records that the given user initiated a file upload
func (*Store) GetAuthHandler ¶
func (s *Store) GetAuthHandler(name string) types.AuthHandler
func (*Store) GetAuthRecord ¶
func (s *Store) GetAuthRecord(user st.Uid, scheme string) (string, auth.Level, []byte, time.Time, error)
GetAuthRecord takes a user ID and a authentication scheme name,
fetches unique scheme-dependent identifier and authentication secret.
func (*Store) GetMediaHandler ¶
GetMediaHandler returns default media handler.
func (*Store) GetValidator ¶
GetValidator returns registered validator by name.
func (*Store) InitAuthLogicalNames ¶
InitAuthLogicalNames() initializes authentication mapping "logical handler name":"actual handler name".
Logical name must not be empty, actual name could be an empty string.
Registered authentication handlers (what are currently supported)
func (*Store) MsgDeleteList ¶
func (s *Store) MsgDeleteList(topic string, delID int, forUser types.Uid, ranges []types.Range) error
DeleteList deletes multiple messages defined by a list of ranges.
func (*Store) MsgGetAll ¶
func (s *Store) MsgGetAll(topic string, forUser types.Uid, opt *types.QueryOpt) ([]types.Message, error)
GetAll returns multiple messages.
func (*Store) MsgGetDeleted ¶
func (s *Store) MsgGetDeleted(topic string, forUser types.Uid, opt *types.QueryOpt) ([]types.Range, int, error)
GetDeleted returns the ranges of deleted messages and the largest DelId reported in the list.
func (*Store) SetDefaultMediaHandler ¶
UseMediaHandler sets specified media handler as default.
func (*Store) SubsCreate ¶
func (s *Store) SubsCreate(subs ...*types.Subscription) error
Create creates multiple subscriptions
func (*Store) SubsDelete ¶
Delete deletes a subscription
func (*Store) SubsGetSubs ¶
func (s *Store) SubsGetSubs(topic string, user types.Uid, keepDeleted bool) (*types.Subscription, error)
SubsGetSubs loads *all* subscriptions for the given user.
Does not load Public/Trusted or Private, does not load deleted subscriptions.
func (*Store) SubsUpdate ¶
Update values of topic's subscriptions.
func (*Store) TopCreateP2P ¶
func (s *Store) TopCreateP2P(initiator, invited *types.Subscription) error
CreateP2P creates a P2P topic by generating two user's subsciptions to each other.
func (*Store) TopGetSubs ¶
GetSubs loads a list of subscriptions to the given topic, user.Public+Trusted and deleted subscriptions are not loaded. Suspended subscriptions are loaded.
func (*Store) TopGetSubsAny ¶
GetSubsAny loads a list of subscriptions to the given topic including deleted subscription. user.Public/Trusted are not loaded
func (*Store) TopGetTopicSubs ¶
TopGetTopicSubs loads a list of subscriptions to the given topic, user.Public+Trusted
and deleted subscriptions are not loaded. Suspended subscriptions are loaded.
func (*Store) TopGetTopicSubsAny ¶
func (s *Store) TopGetTopicSubsAny(topic string, opts *types.QueryOpt) ([]types.Subscription, error)
TopGetTopicSubsAny loads a list of subscriptions to the given topic including
deleted subscription. user.Public/Trusted are not loaded
func (*Store) TopGetUsers ¶
GetUsers loads subscriptions for topic plus loads user.Public+Trusted. Deleted subscriptions are not loaded.
func (*Store) TopGetUsersAny ¶
GetUsersAny loads subscriptions for topic plus loads user.Public+Trusted.
It's the same as GetUsers, except it loads deleted subscriptions too.
func (*Store) TopOwnerChange ¶
OwnerChange replaces the old topic owner with the new owner.
func (*Store) UpdateAuthRecord ¶
func (s *Store) UpdateAuthRecord(uid st.Uid, authLvl auth.Level, scheme, unique string, secret []byte, expires time.Time) error
UpdateAuthRecord updates authentication record with a new secret and expiration time.
func (*Store) UsersCreate ¶
Create inserts User object into a database, updates creation time and assigns UID
func (*Store) UsersDelete ¶
Delete deletes user records.
func (*Store) UsersFindSubs ¶
func (s *Store) UsersFindSubs(id types.Uid, required [][]string, optional []string, activeOnly bool) ([]types.Subscription, error)
FindSubs find a list of users and topics for the given tags. Results are formatted as subscriptions.
`required` specifies an AND of ORs for required terms:
at least one element of every sublist in `required` must be present in the object's tags list.
`optional` specifies a list of optional terms.
func (*Store) UsersGetAll ¶
GetAll returns a slice of user objects for the given user ids
func (*Store) UsersGetAllCreds ¶
func (s *Store) UsersGetAllCreds(id types.Uid, method string, validatedOnly bool) ([]types.Credential, error)
GetAllCreds returns credentials of the given user, all or validated only.
func (*Store) UsersGetByCred ¶
GetByCred returns user ID for the given validated credential.
func (*Store) UsersGetChannels ¶
GetChannels returns a slice of group topic names where the user is a channel reader.
func (*Store) UsersGetOwnTopics ¶
GetOwnTopics returns a slice of group topic names where the user is the owner.
func (*Store) UsersGetSubs ¶
GetSubs loads *all* subscriptions for the given user. Does not load Public/Trusted or Private, does not load deleted subscriptions.
func (*Store) UsersGetTopics ¶
GetTopics load a list of user's subscriptions with Public+Trusted fields copied to subscription
func (*Store) UsersGetTopicsAny ¶
GetTopicsAny load a list of user's subscriptions with Public+Trusted
fields copied to subscription. Deleted topics are returned too.
func (*Store) UsersGetUnreadCount ¶
GetUnreadCount returs users' total count of unread messages in all topics with the R permissions.
func (*Store) UsersGetUnvalidated ¶
GetUnvalidated returns a list of stale user ids which have unvalidated credentials,
their auth levels and a comma-separated list of these credential names.
func (*Store) UsersUpdate ¶
Update is a general-purpose update of user data.
func (*Store) UsersUpdateLastSeen ¶
UpdateLastSeen updates LastSeen and UserAgent.
func (*Store) UsersUpdateState ¶
UpdateState changes user's state and state of some topics associated with the user.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mock_store is a generated GoMock package.
|
Package mock_store is a generated GoMock package. |