persistence

package
v0.0.0-...-31789c7 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2016 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KeyNotFound = errors.New("Key does not exist")
)

Functions

This section is empty.

Types

type FriendRequest

type FriendRequest struct {
	PublicKey string
	Message   string
	IsIgnored bool
}

type Message

type Message struct {
	Message    string
	IsIncoming bool
	IsAction   bool
	Time       int64
}

type StorageConn

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

func Open

func Open(filename string) (*StorageConn, error)

Open creates a connection to the database always close the connection with `defer storageConn.Close()`

func (*StorageConn) Close

func (s *StorageConn) Close()

Close safely closes the connection to the database

func (*StorageConn) DeleteFriendRequest

func (s *StorageConn) DeleteFriendRequest(friendPublicKey string) error

DeleteFriendRequest deletes a stored friend request friendPublicKey the publicKey of the friend request

func (*StorageConn) GetFriendRequests

func (s *StorageConn) GetFriendRequests(limit int) []FriendRequest

GetFriendRequests returns previously stored friend requests. limit the number of friend requests that should be returned. Set limit to

-1 to get all messages

func (*StorageConn) GetKeyValue

func (s *StorageConn) GetKeyValue(key string) (string, error)

GetKeyValue returns the value corresponding to the given key or an empty string if the value could not be determined key the key (case sensitive)

func (*StorageConn) GetLastMessageRead

func (s *StorageConn) GetLastMessageRead(friendPublicKey string) (int64, error)

GetLastMessageRead returns the last message read time for a given friend friendPublicKey the publicKey of the friend

func (*StorageConn) GetMessages

func (s *StorageConn) GetMessages(friendPublicKey string, limit int) []Message

GetMessages returns previously stored messages of a friend. friendPublicKey the publicKey of the friend limit the number of messages that should be returned. Set limit

to -1 to get all messages

func (*StorageConn) SetLastMessageRead

func (s *StorageConn) SetLastMessageRead(friendPublicKey string) error

SetLastMessageRead sets the message read status for a given friend friendPublicKey the publicKey of the friend

func (*StorageConn) StoreFriendRequest

func (s *StorageConn) StoreFriendRequest(friendPublicKey string, message string) error

StoreFriendRequest stores a friend request friendPublicKey the publicKey of the friend request message the message send with the friend request

func (*StorageConn) StoreFriendRequestIgnoreStatus

func (s *StorageConn) StoreFriendRequestIgnoreStatus(friendPublicKey string, isIgnored bool) error

StoreFriendRequestIgnoreStatus updates the isIgnored attribute of a friend request friendPublicKey the publicKey of the friend request isIgnored the new value for the isIgnored attribute

func (*StorageConn) StoreKeyValue

func (s *StorageConn) StoreKeyValue(key string, value string) error

StoreKeyValue stores a key-value pair of strings key the key (case sensitive) value the value

func (*StorageConn) StoreMessage

func (s *StorageConn) StoreMessage(friendPublicKey string, isIncoming bool, isAction bool, message string) error

StoreMessage stores a message friendPublicKey the publicKey of the friend isIncoming specifies if the message is received (true) or sent (false) isAction specifies if the message is an action or not message the message

Jump to

Keyboard shortcuts

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