store

package module
v0.0.0-...-ecf9d16 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	HaveURL(url string) bool
	AddURL(url string) error
	AddURLs(url []string) error
	MarkURL(url string) error
	GetRandomURL(unseenOnly bool) (string, error)
	Close()
}

Interface provides a standardized set of functions that can be performed on a data storage backend.

func NewStore

func NewStore(c *config.Config) Interface

NewStore creates the appropriate Store object for the user's configured data storage backend.

type SQLStore

type SQLStore struct {
	Store
	// contains filtered or unexported fields
}

SQLStore is a backend that supports SQL-based databases (but currently is only really useful for SQLite3 files).

func (*SQLStore) AddURL

func (s *SQLStore) AddURL(url string) error

AddURL inserts a new URL into the database.

func (*SQLStore) AddURLs

func (s *SQLStore) AddURLs(urls []string) error

AddURLs adds a set of new URLs into the database (using store.AddURL).

func (*SQLStore) Close

func (s *SQLStore) Close()

Close an established SQLStore connection.

func (*SQLStore) GetRandomURL

func (s *SQLStore) GetRandomURL(unseenOnly bool) (string, error)

GetRandomURL returns a single random URL from the database. If unseenOnly is true, it will exclude any URLs that have already been posted to the user's timeline.

func (*SQLStore) HaveURL

func (s *SQLStore) HaveURL(url string) bool

HaveURL reports whether a URL already exists in the database or not. This function may go away, since the database is expected to have a constraint that prohibits the addition of duplicate URLs.

func (*SQLStore) MarkURL

func (s *SQLStore) MarkURL(url string) error

MarkURL updates the database to indicate that a URL has been posted to the bot's timeline.

type Store

type Store struct {
	Interface
	// contains filtered or unexported fields
}

Store provides a base data storage object that maintains a link back to the store's configuration object.

Jump to

Keyboard shortcuts

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