store

package
v0.0.0-...-49f0b68 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 6

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

View Source
const (
	MAX_USERS_FOR_TOPIC = 32
)

Variables

This section is empty.

Functions

func Close

func Close() error

func InitDb

func InitDb(reset bool) error

func IsOpen

func IsOpen() bool

func Open

func Open(name, jsonconf string) error

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

func Register(name string, adapter adapter.Adapter)

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

func UidFromBytes(b []byte) types.Uid

func ZeroUid

func ZeroUid() types.Uid

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

func (MessagesObjMapper) DeleteAll

func (MessagesObjMapper) DeleteAll(appId uint32, user types.Uid, topic string) error

Soft-delete semmsages for the current user

func (MessagesObjMapper) GetAll

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

func (MessagesObjMapper) Save

func (MessagesObjMapper) Save(appid uint32, msg *types.Message) error

Save message

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) Delete

func (SubsObjMapper) Delete(appid uint32, topic string, user types.Uid) error

Delete deletes a subscription

func (SubsObjMapper) Get

func (SubsObjMapper) Get(appid uint32, topic string, user types.Uid) (*types.Subscription, error)

func (SubsObjMapper) Update

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

Update changes values of user's subscription.

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) Get

func (TopicsObjMapper) Get(appid uint32, 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(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

func (TopicsObjMapper) Update

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

func (TopicsObjMapper) UpdateLastSeen

func (TopicsObjMapper) UpdateLastSeen(appid uint32, topic string, id types.Uid, tag string, when time.Time) error

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) Delete

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

TODO(gene): implement

func (UsersObjMapper) Find

func (UsersObjMapper) Find(appId uint32, params map[string]interface{}) ([]types.User, error)

TODO(gene): implement

func (UsersObjMapper) Get

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

TODO(gene): implement

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

func (UsersObjMapper) Login(appid uint32, scheme, secret string) (types.Uid, error)

Process user login. TODO(gene): abstract out the authentication scheme

func (UsersObjMapper) Update

func (UsersObjMapper) Update(appid uint32, uid types.Uid, update map[string]interface{}) error

func (UsersObjMapper) UpdateStatus

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

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