Documentation ¶
Overview ¶
Package store provides methods for registering and accessing database adapters.
Index ¶
- func DecodeUid(uid types.Uid) int64
- func EncodeUid(id int64) types.Uid
- func InitAuthLogicalNames(config json.RawMessage) error
- func RegisterAdapter(a adapter.Adapter)
- func RegisterAuthScheme(name string, handler auth.AuthHandler)
- func RegisterMediaHandler(name string, mh media.Handler)
- func RegisterValidator(name string, v validate.Validator)
- type DevicePersistenceInterface
- type FilePersistenceInterface
- type MessagesPersistenceInterface
- type PersistentStorageInterface
- type SubsPersistenceInterface
- type TopicsPersistenceInterface
- type UsersPersistenceInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeUid ¶ added in v0.14.2
DecodeUid takes an XTEA encrypted Uid and decrypts it into an int64. This is needed for sql compatibility. Tte original int64 values are generated by snowflake which ensures that the top bit is unset.
func EncodeUid ¶ added in v0.14.2
EncodeUid applies XTEA encryption to an int64 value. It's the inverse of DecodeUid.
func InitAuthLogicalNames ¶ added in v0.15.7
func InitAuthLogicalNames(config json.RawMessage) error
InitAuthLogicalNames initializes authentication mapping "logical handler name":"actual handler name". Logical name must not be empty, actual name could be an empty string.
func RegisterAdapter ¶ added in v0.14.2
RegisterAdapter makes a persistence adapter available. If Register is called twice or if the adapter is nil, it panics.
func RegisterAuthScheme ¶
func RegisterAuthScheme(name string, handler auth.AuthHandler)
RegisterAuthScheme registers an authentication scheme handler. The 'name' must be the hardcoded name, NOT the logical name.
func RegisterMediaHandler ¶ added in v0.15.2
RegisterMediaHandler saves reference to a media handler (file upload-download handler).
func RegisterValidator ¶ added in v0.14.4
RegisterValidator registers validation scheme.
Types ¶
type DevicePersistenceInterface ¶ added in v0.18.0
type DevicePersistenceInterface interface { Update(uid types.Uid, oldDeviceID string, dev *types.DeviceDef) error GetAll(uid ...types.Uid) (map[types.Uid][]types.DeviceDef, int, error) Delete(uid types.Uid, deviceID string) error }
DevicePersistenceInterface is an interface which defines methods used for handling device IDs. Mostly used to generate push notifications.
var Devices DevicePersistenceInterface
Devices is a singleton instance of DevicePersistenceInterface to map methods to.
type FilePersistenceInterface ¶ added in v0.18.0
type FilePersistenceInterface interface { // StartUpload records that the given user initiated a file upload StartUpload(fd *types.FileDef) error // FinishUpload marks started upload as successfully finished. FinishUpload(fd *types.FileDef, success bool, size int64) (*types.FileDef, error) // Get fetches a file record for a unique file id. Get(fid string) (*types.FileDef, error) // DeleteUnused removes unused attachments. DeleteUnused(olderThan time.Time, limit int) error // LinkAttachments connects earlier uploaded attachments to a message or topic to prevent it // from being garbage collected. LinkAttachments(topic string, msgId types.Uid, attachments []string) error }
FilePersistenceInterface is an interface wchich defines methods used for file handling (records or uploaded files).
var Files FilePersistenceInterface
Files is a sigleton instance of FilePersistenceInterface to be used for handling file uploads.
type MessagesPersistenceInterface ¶ added in v0.18.0
type MessagesPersistenceInterface interface { Save(msg *types.Message, attachmentURLs []string, readBySender bool) error DeleteList(topic string, delID int, forUser types.Uid, ranges []types.Range) error GetAll(topic string, forUser types.Uid, opt *types.QueryOpt) ([]types.Message, error) GetDeleted(topic string, forUser types.Uid, opt *types.QueryOpt) ([]types.Range, int, error) }
MessagesPersistenceInterface is an interface which defines methods for persistent storage of messages.
var Messages MessagesPersistenceInterface
Messages is a singleton ancor object for exporting MessagesPersistenceInterface.
type PersistentStorageInterface ¶ added in v0.17.0
type PersistentStorageInterface interface { Open(workerId int, jsonconf json.RawMessage) error Close() error IsOpen() bool GetAdapter() adapter.Adapter GetAdapterName() string GetAdapterVersion() int GetDbVersion() int InitDb(jsonconf json.RawMessage, reset bool) error UpgradeDb(jsonconf json.RawMessage) error GetUid() types.Uid GetUidString() string DbStats() func() interface{} GetAuthNames() []string GetAuthHandler(name string) auth.AuthHandler GetLogicalAuthHandler(name string) auth.AuthHandler GetValidator(name string) validate.Validator GetMediaHandler() media.Handler UseMediaHandler(name, config string) error }
PersistentStorageInterface defines methods used for interation with persistent storage.
var Store PersistentStorageInterface
Store is the main object for interacting with persistent storage.
type SubsPersistenceInterface ¶ added in v0.18.0
type SubsPersistenceInterface interface { Create(subs ...*types.Subscription) error Get(topic string, user types.Uid, keepDeleted bool) (*types.Subscription, error) Update(topic string, user types.Uid, update map[string]interface{}) error Delete(topic string, user types.Uid) error }
SubsPersistenceInterface is an interface which defines methods for persistent storage of subscriptions.
var Subs SubsPersistenceInterface
Subs is a singleton ancor object exporting SubsPersistenceInterface.
type TopicsPersistenceInterface ¶ added in v0.18.0
type TopicsPersistenceInterface interface { Create(topic *types.Topic, owner types.Uid, private interface{}) error CreateP2P(initiator, invited *types.Subscription) error Get(topic string) (*types.Topic, error) GetUsers(topic string, opts *types.QueryOpt) ([]types.Subscription, error) GetUsersAny(topic string, opts *types.QueryOpt) ([]types.Subscription, error) GetSubs(topic string, opts *types.QueryOpt) ([]types.Subscription, error) GetSubsAny(topic string, opts *types.QueryOpt) ([]types.Subscription, error) Update(topic string, update map[string]interface{}) error OwnerChange(topic string, newOwner types.Uid) error Delete(topic string, hard bool) error }
TopicsPersistenceInterface is an interface which defines methods for persistent storage of topics.
var Topics TopicsPersistenceInterface
Topics is a singleton ancor object exporting TopicsPersistenceInterface methods.
type UsersPersistenceInterface ¶ added in v0.18.0
type UsersPersistenceInterface interface { Create(user *types.User, private interface{}) (*types.User, error) GetAuthRecord(user types.Uid, scheme string) (string, auth.Level, []byte, time.Time, error) GetAuthUniqueRecord(scheme, unique string) (types.Uid, auth.Level, []byte, time.Time, error) AddAuthRecord(uid types.Uid, authLvl auth.Level, scheme, unique string, secret []byte, expires time.Time) error UpdateAuthRecord(uid types.Uid, authLvl auth.Level, scheme, unique string, secret []byte, expires time.Time) error DelAuthRecords(uid types.Uid, scheme string) error Get(uid types.Uid) (*types.User, error) GetAll(uid ...types.Uid) ([]types.User, error) GetByCred(method, value string) (types.Uid, error) Delete(id types.Uid, hard bool) error UpdateLastSeen(uid types.Uid, userAgent string, when time.Time) error Update(uid types.Uid, update map[string]interface{}) error UpdateTags(uid types.Uid, add, remove, reset []string) ([]string, error) UpdateState(uid types.Uid, state types.ObjState) error GetSubs(id types.Uid) ([]types.Subscription, error) FindSubs(id types.Uid, required [][]string, optional []string) ([]types.Subscription, error) GetTopics(id types.Uid, opts *types.QueryOpt) ([]types.Subscription, error) GetTopicsAny(id types.Uid, opts *types.QueryOpt) ([]types.Subscription, error) GetOwnTopics(id types.Uid) ([]string, error) GetChannels(id types.Uid) ([]string, error) UpsertCred(cred *types.Credential) (bool, error) ConfirmCred(id types.Uid, method string) error FailCred(id types.Uid, method string) error GetActiveCred(id types.Uid, method string) (*types.Credential, error) GetAllCreds(id types.Uid, method string, validatedOnly bool) ([]types.Credential, error) DelCred(id types.Uid, method, value string) error GetUnreadCount(id types.Uid) (int, error) }
UsersPersistenceInterface is an interface which defines methods for persistent storage of user records.
var Users UsersPersistenceInterface
Users is a singleton ancor object exporting UsersPersistenceInterface methods.
Directories ¶
Path | Synopsis |
---|---|
Package mock_store is a generated GoMock package.
|
Package mock_store is a generated GoMock package. |
Package types provides data types for persisting objects in the databases.
|
Package types provides data types for persisting objects in the databases. |