sql

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string `yaml:"host"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Database string `yaml:"database"`
	PoolSize int    `yaml:"pool_size"`
}

Config represents SQL storage configuration.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage represents a SQL storage sub system.

func New

func New(cfg *Config) *Storage

New returns a SQL storage instance.

func NewMock

func NewMock() (*Storage, sqlmock.Sqlmock)

NewMock returns a mocked SQL storage instance.

func (*Storage) Close added in v0.3.4

func (s *Storage) Close() error

Close shuts down SQL storage sub system.

func (*Storage) CountOfflineMessages

func (s *Storage) CountOfflineMessages(username string) (int, error)

CountOfflineMessages returns current length of user's offline queue.

func (*Storage) DeleteBlockListItems

func (s *Storage) DeleteBlockListItems(items []model.BlockListItem) error

DeleteBlockListItems deletes a set of block list item entities from storage.

func (*Storage) DeleteOfflineMessages

func (s *Storage) DeleteOfflineMessages(username string) error

DeleteOfflineMessages clears a user offline queue.

func (*Storage) DeleteRosterItem

func (s *Storage) DeleteRosterItem(username, jid string) (rostermodel.Version, error)

DeleteRosterItem deletes a roster item entity from storage.

func (*Storage) DeleteRosterNotification

func (s *Storage) DeleteRosterNotification(contact, jid string) error

DeleteRosterNotification deletes a roster notification entity from storage.

func (*Storage) DeleteUser

func (s *Storage) DeleteUser(username string) error

DeleteUser deletes a user entity from storage.

func (*Storage) FetchBlockListItems

func (s *Storage) FetchBlockListItems(username string) ([]model.BlockListItem, error)

FetchBlockListItems retrieves from storage all block list item entities associated to a given user.

func (*Storage) FetchOfflineMessages

func (s *Storage) FetchOfflineMessages(username string) ([]*xmpp.Message, error)

FetchOfflineMessages retrieves from storage current user offline queue.

func (*Storage) FetchPrivateXML

func (s *Storage) FetchPrivateXML(namespace string, username string) ([]xmpp.XElement, error)

FetchPrivateXML retrieves from storage a private element.

func (*Storage) FetchRosterItem

func (s *Storage) FetchRosterItem(username, jid string) (*rostermodel.Item, error)

FetchRosterItem retrieves from storage a roster item entity.

func (*Storage) FetchRosterItems

func (s *Storage) FetchRosterItems(username string) ([]rostermodel.Item, rostermodel.Version, error)

FetchRosterItems retrieves from storage all roster item entities associated to a given user.

func (*Storage) FetchRosterNotification added in v0.3.0

func (s *Storage) FetchRosterNotification(contact string, jid string) (*rostermodel.Notification, error)

FetchRosterNotification retrieves from storage a roster notification entity.

func (*Storage) FetchRosterNotifications

func (s *Storage) FetchRosterNotifications(contact string) ([]rostermodel.Notification, error)

FetchRosterNotifications retrieves from storage all roster notifications associated to a given user.

func (*Storage) FetchUser

func (s *Storage) FetchUser(username string) (*model.User, error)

FetchUser retrieves from storage a user entity.

func (*Storage) FetchVCard

func (s *Storage) FetchVCard(username string) (xmpp.XElement, error)

FetchVCard retrieves from storage a vCard element associated to a given user.

func (*Storage) InsertBlockListItems

func (s *Storage) InsertBlockListItems(items []model.BlockListItem) error

InsertBlockListItems inserts a set of block list item entities into storage, only in case they haven't been previously inserted.

func (*Storage) InsertOfflineMessage

func (s *Storage) InsertOfflineMessage(message *xmpp.Message, username string) error

InsertOfflineMessage inserts a new message element into user's offline queue.

func (*Storage) InsertOrUpdatePrivateXML

func (s *Storage) InsertOrUpdatePrivateXML(privateXML []xmpp.XElement, namespace string, username string) error

InsertOrUpdatePrivateXML inserts a new private element into storage, or updates it in case it's been previously inserted.

func (*Storage) InsertOrUpdateRosterItem

func (s *Storage) InsertOrUpdateRosterItem(ri *rostermodel.Item) (rostermodel.Version, error)

InsertOrUpdateRosterItem inserts a new roster item entity into storage, or updates it in case it's been previously inserted.

func (*Storage) InsertOrUpdateRosterNotification

func (s *Storage) InsertOrUpdateRosterNotification(rn *rostermodel.Notification) error

InsertOrUpdateRosterNotification inserts a new roster notification entity into storage, or updates it in case it's been previously inserted.

func (*Storage) InsertOrUpdateUser

func (s *Storage) InsertOrUpdateUser(u *model.User) error

InsertOrUpdateUser inserts a new user entity into storage, or updates it in case it's been previously inserted.

func (*Storage) InsertOrUpdateVCard

func (s *Storage) InsertOrUpdateVCard(vCard xmpp.XElement, username string) error

InsertOrUpdateVCard inserts a new vCard element into storage, or updates it in case it's been previously inserted.

func (*Storage) UserExists

func (s *Storage) UserExists(username string) (bool, error)

UserExists returns whether or not a user exists within storage.

Jump to

Keyboard shortcuts

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