Documentation
¶
Overview ¶
Package store stores a text.Text collection somewhere. Typically, use the github.com/lukasschwab/tiir/pkg/tir.Interface provided by github.com/lukasschwab/tiir/pkg/config.Load, rather than constructing a store directly, to use the user-configured store.
An initialized store must be closed: call Close when you're done writing to the Interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { // Mutex for file handle operations. sync.Mutex // contains filtered or unexported fields }
File implements Interface; see UseFile.
Loads all texts from the underlying os.File into a memory store as an intermediate form for each operation; most of the store logic is delegated to the memory implementation.
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP implements Interface for a remote cmd/server process. See UseHTTP.
NOTE: if we had a proto-defined service, this would probably wrap that (and the generated code would determine the inner values necessary to specify and connect). As it is, this mirrors the routes and renderers exposed by github.com/lukasschwab/tiir/cmd/server; these are hidden dependencies!
type Interface ¶
type Interface interface { // Close the Store, rendering it unusable for future operations. io.Closer // Read a text by ID. Read(id string) (*text.Text, error) // Delete a text by ID and return the deleted text. Delete(id string) (*text.Text, error) // Upsert a text by t.ID and return the resulting text. Assumes t.ID is set // and t is valid; see (*text.Text).Validate(...). Upsert(t *text.Text) (*text.Text, error) // List all texts in the store in order. List(c text.Comparator, d text.Direction) ([]*text.Text, error) }
Interface for storing texts somewhere. An initialized store must be closed: call Close when you're done writing to the store.
func UseFile ¶
UseFile at path as a JSON store. If the file doesn't exist, it's created and initialized to an empty store.
If you don't call File.Close, the underlying os.File won't be closed.
func UseHTTP ¶
UseHTTP requests to a remote github.com/lukasschwab/tiir/cmd/server instance (hosted at baseURL, accepting secret apiSecret) to read and write texts.