store

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close terminates connection to persistent storage.

func DecodeUid

func DecodeUid(uid types.Uid) int64

func EncodeUid

func EncodeUid(id int64) types.Uid

func GetAuthHandler

func GetAuthHandler(name string) auth.AuthHandler

GetAuthHandler returns an auth handler by name.

func GetUid

func GetUid() types.Uid

GetUid generates a unique ID suitable for use as a primary key.

func GetUidString

func GetUidString() string

GetUidString generate unique ID as string

func InitDb

func InitDb(jsonconf string, reset bool) error

InitDb creates a new database instance. If 'reset' is true it will first attempt to drop existing database. If jsconf is nil it will assume that the connection is already open. If it's non-nil, it will use the config string to open the DB connection first.

func IsOpen

func IsOpen() bool

IsOpen checks if persistent storage connection has been initialized.

func Open

func Open(jsonconf string) error

Open initializes the persistence system. Adapter holds a connection pool for a database instance.

	 name - name of the adapter rquested in the config file
  jsonconf - configuration string

func RegisterAdapter

func RegisterAdapter(name string, a adapter.Adapter)

Register makes a persistence adapter available by the provided name. If Register is called twice 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)

RegisterAuthScheme registers an authentication scheme handler.

Types

type DeviceMapper

type DeviceMapper struct{}

DeviceMapper is a struct to map methods used for handling device IDs, used to generate push notifications.

var Devices DeviceMapper

Devices is an instance of DeviceMapper to map methods to.

func (DeviceMapper) Delete

func (DeviceMapper) Delete(uid types.Uid, deviceID string) error

Delete deletes device record for a given user.

func (DeviceMapper) GetAll

func (DeviceMapper) GetAll(uid ...types.Uid) (map[types.Uid][]types.DeviceDef, int, error)

GetAll returns all known device IDS for a given list of user IDs.

func (DeviceMapper) Update

func (DeviceMapper) Update(uid types.Uid, oldDeviceID string, dev *types.DeviceDef) error

Update updates a device record.

type MessagesObjMapper

type MessagesObjMapper struct{}

MessagesObjMapper is a struct to hold methods for persistence mapping for the Message object.

var Messages MessagesObjMapper

Messages is an instance of MessagesObjMapper to map methods to.

func (MessagesObjMapper) DeleteList

func (MessagesObjMapper) DeleteList(topic string, delID int, forUser types.Uid, ranges []types.Range) error

DeleteList deletes multiple messages defined by a list of ranges.

func (MessagesObjMapper) GetAll

func (MessagesObjMapper) GetAll(topic string, forUser types.Uid, opt *types.BrowseOpt) ([]types.Message, error)

GetAll returns multiple messages.

func (MessagesObjMapper) GetDeleted

func (MessagesObjMapper) GetDeleted(topic string, forUser types.Uid, opt *types.BrowseOpt) ([]types.Range, int, error)

GetDeleted returns the ranges of deleted messages and the largest DelId reported in the list.

func (MessagesObjMapper) Save

func (MessagesObjMapper) Save(msg *types.Message) error

Save message

type SubsObjMapper

type SubsObjMapper struct{}

SubsObjMapper is A struct to hold methods for persistence mapping for the Subscription object.

var Subs SubsObjMapper

Subs is an instance of SubsObjMapper to map methods to.

func (SubsObjMapper) Create

func (SubsObjMapper) Create(subs ...*types.Subscription) error

Create creates multiple subscriptions

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

func (SubsObjMapper) Update

func (SubsObjMapper) Update(topic string, user types.Uid, update map[string]interface{}) error

Update values of user's subscription.

type TopicsObjMapper

type TopicsObjMapper struct{}

TopicsObjMapper is a struct to hold methods for persistence mapping for the topic object.

var Topics TopicsObjMapper

Topics is an instance of TopicsObjMapper to map methods to.

func (TopicsObjMapper) Create

func (TopicsObjMapper) Create(topic *types.Topic, owner types.Uid, private interface{}) error

Create creates a topic and owner's subscription to it.

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

Delete deletes topic, messages and subscriptions.

func (TopicsObjMapper) Get

func (TopicsObjMapper) Get(topic string) (*types.Topic, error)

Get a single topic with a list of relevant 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.

func (TopicsObjMapper) Update

func (TopicsObjMapper) Update(topic string, update map[string]interface{}) error

Update is a generic topic update.

func (TopicsObjMapper) UpdateTags

func (u TopicsObjMapper) UpdateTags(topic string, unique, tags []string) error

UpdateTags updates indexable tags for the given topic.

type UsersObjMapper

type UsersObjMapper struct{}

UsersObjMapper is a 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) (bool, error)

AddAuthRecord creates a new authentication record for the given user.

func (UsersObjMapper) Create

func (u UsersObjMapper) Create(user *types.User, private interface{}) (*types.User, error)

Create inserts User object into a database, updates creation time and assigns UID

func (UsersObjMapper) Delete

func (UsersObjMapper) Delete(id types.Uid, soft bool) error

Delete deletes a user record (not implemented). TODO(gene): implement

func (UsersObjMapper) FindSubs

func (u UsersObjMapper) FindSubs(id types.Uid, query []string) ([]types.Subscription, error)

FindSubs loads a list of users for the given tags.

func (UsersObjMapper) Get

func (UsersObjMapper) Get(uid types.Uid) (*types.User, error)

Get returns a user object for the given user id

func (UsersObjMapper) GetAll

func (UsersObjMapper) GetAll(uid ...types.Uid) ([]types.User, error)

GetAll returns a slice of user objects for the given user ids

func (UsersObjMapper) GetAuthRecord

func (UsersObjMapper) GetAuthRecord(scheme, unique string) (types.Uid, int, []byte, time.Time, error)

GetAuthRecord takes a unique identifier and a authentication scheme name, fetches 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)

GetTopicsAny 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

Update is a generic user data update.

func (UsersObjMapper) UpdateAuthRecord

func (UsersObjMapper) UpdateAuthRecord(uid types.Uid, authLvl int, scheme, unique string,
	secret []byte, expires time.Time) (int, error)

UpdateAuthRecord updates authentication record with a new secret and expiration time.

func (UsersObjMapper) UpdateLastSeen

func (UsersObjMapper) UpdateLastSeen(uid types.Uid, userAgent string, when time.Time) error

UpdateLastSeen updates LastSeen and UserAgent.

func (UsersObjMapper) UpdateStatus

func (UsersObjMapper) UpdateStatus(id types.Uid, status interface{}) error

UpdateStatus updates user status (not implemented). TODO(gene): implement

func (UsersObjMapper) UpdateTags

func (u UsersObjMapper) UpdateTags(id types.Uid, unique, newTags []string) error

UpdateTags updates indexable tags for the given user.

Directories

Path Synopsis
Package adapter contains the interfaces to be implemented by the database adapter
Package adapter contains the interfaces to be implemented by the database adapter

Jump to

Keyboard shortcuts

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