Documentation ¶
Index ¶
- type Config
- type MemStore
- func (m *MemStore) AddTitle(t *title.Title) (*title.Title, error)
- func (m *MemStore) Disconnect()
- func (m *MemStore) GetTitle(id string) (*title.Title, error)
- func (m *MemStore) ListTitles(pageSize int, page int) ([]*title.Title, error)
- func (m *MemStore) RandomTitle(filters ...title.Filter) (*title.Title, error)
- func (m *MemStore) UpdateTitle(t *title.Title) (*title.Title, error)
- type MongoStore
- func (m *MongoStore) AddTitle(t *title.Title) (*title.Title, error)
- func (m *MongoStore) Disconnect()
- func (m *MongoStore) GetTitle(id string) (*title.Title, error)
- func (m *MongoStore) ListTitles(pageSize int, page int) ([]*title.Title, error)
- func (m *MongoStore) RandomTitle(titleFilters ...title.Filter) (*title.Title, error)
- func (m *MongoStore) UpdateTitle(t *title.Title) (*title.Title, error)
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config encapsulates config.StorageConfig, so that we can define methods on it in this package
func (*Config) NewMemStore ¶
NewMemStore creates a new empty MemStore
func (*Config) NewMongoStore ¶
NewMongoStore creates a new mongodb client, based on the config passed in
func (*Config) ProcessStorageConfig ¶
ProcessStorageConfig parses environment variables to a particular storage config interface we use the prefix <appname>_<storagekind> e.g. RANDFLIX_MONGOSTORE storageConfig must be a pointer to a struct
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
MemStore is in-memory storage
func (*MemStore) Disconnect ¶
func (m *MemStore) Disconnect()
Disconnect disconnects from storage (in this case it does nothing)
func (*MemStore) ListTitles ¶
ListTitles retrieves all titles from storage, given the pageSize and page note: page is zero indexed
func (*MemStore) RandomTitle ¶
RandomTitle chooese a random title from storage (filtered by the filters)
type MongoStore ¶
type MongoStore struct {
// contains filtered or unexported fields
}
MongoStore is storage using mongodb
func (*MongoStore) Disconnect ¶
func (m *MongoStore) Disconnect()
Disconnect disconnects from the mongodb
func (*MongoStore) GetTitle ¶
func (m *MongoStore) GetTitle(id string) (*title.Title, error)
GetTitle gets a single title by id, if it doesn't exist, it returns nil
func (*MongoStore) ListTitles ¶
ListTitles lists all elements in the mongo store, by page and pageSize
func (*MongoStore) RandomTitle ¶
RandomTitle picks a random title based on the filters passed in
func (*MongoStore) UpdateTitle ¶
UpdateTitle updates the title passed in
type Storage ¶
type Storage interface { // Disconnect disconnects from the storage Disconnect() // RandomTitle gets a random title from storage RandomTitle(filters ...title.Filter) (*title.Title, error) // AddTitle adds a title to storage AddTitle(t *title.Title) (*title.Title, error) // UpdateTitle replaces a title in storage UpdateTitle(t *title.Title) (*title.Title, error) // GetTitle retrieves a title from storage by id GetTitle(id string) (*title.Title, error) // ListTitles retrieves all titles from storage ListTitles(pageSize int, page int) ([]*title.Title, error) }
Storage provides storage functions for the api