storage

package
v0.0.0-...-e797cc8 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePostgresConnection

func CreatePostgresConnection(config PostgresConfig) *pgx.ConnPool

CreatePostgresConnection creates postgres connections pool

Types

type Interface

type Interface interface {
	AddTopic(TopicInterface) (result TopicInterface, err error)
	UpdateTopic(TopicInterface) (result TopicInterface, err error)
	GetUserTopics(userID int64) (result []TopicInterface, err error)
	GetTopic(topicID int64) (topic TopicInterface, err error)
	GetTopicStreams(topicID int64) (streams []StreamInterface, err error)
	GetTopicTweets(topicID int64) (tweets []TweetInterface, err error)
	GetActiveStreams() (streams []StreamInterface, err error)
	DeleteTopic(streamID int64) error
	AddTweetStreams(tweetStreams TweetStreamsInterface) (id int64, err error)
	SignUp(email string, password string) (id *int64, err error)
	Login(email string, password string) (id *int64, err error)
	AddStream(streamInterface StreamInterface) (result StreamInterface, err error)
	UpdateStream(streamInterface StreamInterface) (result StreamInterface, err error)
	DeleteStream(streamID int64) error
}

Interface must be implemented by DBMS based storage.

func NewStorage

func NewStorage(connPool *pgx.ConnPool) Interface

NewStorage creates new Storage instance

type PostgresConfig

type PostgresConfig struct {
	DSN string
}

PostgresConfig contains options for the Postgres connections pool

type Storage

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

Storage provides ability to store and to retrieve twits and other entities

func (*Storage) AddStream

func (storage *Storage) AddStream(streamInterface entity.StreamInterface) (createdStream entity.StreamInterface, err error)

func (*Storage) AddTopic

func (storage *Storage) AddTopic(topic entity.TopicInterface) (result entity.TopicInterface, err error)

AddTopic inserts topic into database

func (*Storage) AddTweetStreams

func (storage *Storage) AddTweetStreams(tweetStreams entity.TweetStreamsInterface) (id int64, err error)

func (*Storage) DeleteStream

func (storage *Storage) DeleteStream(streamID int64) (err error)

func (*Storage) DeleteTopic

func (storage *Storage) DeleteTopic(topicID int64) (err error)

func (*Storage) GetActiveStreams

func (storage *Storage) GetActiveStreams() (streams []entity.StreamInterface, err error)

GetStreams returns all existing streams

func (*Storage) GetTopic

func (storage *Storage) GetTopic(topicID int64) (topic entity.TopicInterface, err error)

func (*Storage) GetTopicStreams

func (storage *Storage) GetTopicStreams(topicID int64) (streams []entity.StreamInterface, err error)

GetStreams returns all existing streams

func (*Storage) GetTopicTweets

func (storage *Storage) GetTopicTweets(topicID int64) (tweets []entity.TweetInterface, err error)

func (*Storage) GetUserTopics

func (storage *Storage) GetUserTopics(userId int64) (result []entity.TopicInterface, err error)

func (*Storage) Login

func (storage *Storage) Login(email string, password string) (id *int64, err error)

Login authenticate user, set temp token for him and returns token

func (*Storage) SignUp

func (storage *Storage) SignUp(email string, password string) (id *int64, err error)

SignUpHandler registers new user in system

func (*Storage) UpdateStream

func (storage *Storage) UpdateStream(streamInterface entity.StreamInterface) (updatedStream entity.StreamInterface, err error)

UpdateStream just update stream

func (*Storage) UpdateTopic

func (storage *Storage) UpdateTopic(topic entity.TopicInterface) (result entity.TopicInterface, err error)

AddTopic inserts topic into database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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