Documentation
¶
Overview ¶
Package store handles interaction with the backing store.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidStoreConfig = errors.New("invalid store config")
ErrInvalidStoreConfig is returned if the bot is started with a store config name it doesn't recognise.
View Source
var ErrNoBackingStore = errors.New("no backing store set")
ErrNoBackingStore is returned if no backing store is set on the Locking store.
Functions ¶
This section is empty.
Types ¶
type JSONStore ¶ added in v0.1.5
type JSONStore struct {
BackingStore GetSetter
}
JSONStore stores JSON documents, converting them to strings for the backing store.
func (*JSONStore) Get ¶ added in v0.1.5
Get data from JSON stored in the backing store, marshalling the JSON into the given pointer.
Example ¶
package main
import (
"fmt"
"bitbucket.org/idomdavis/gobot/store"
)
func main() {
var (
out string
zero int
)
s := store.JSONStore{BackingStore: &store.Memory{}}
_ = s.Set("k", "in")
_ = s.Get("k", &out)
if err := s.Get("unset", &zero); err != nil {
fmt.Println(err)
}
fmt.Println(out)
fmt.Println(zero)
}
Output: in 0
type Locking ¶ added in v0.1.5
type Locking struct {
BackingStore GetSetter
// contains filtered or unexported fields
}
Locking store single threads access to a store.
func (*Locking) Get ¶ added in v0.1.5
Get data from the store. The store is locked while being accessed.
Example ¶
package main
import (
"fmt"
"bitbucket.org/idomdavis/gobot/store"
)
func main() {
s := store.Locking{BackingStore: &store.Memory{}}
_ = s.Set("k", "v")
v, _ := s.Get("k")
fmt.Println(v)
}
Output: v
type Memory ¶ added in v0.1.5
type Memory struct {
// contains filtered or unexported fields
}
Memory store primarily used for testing.
Click to show internal directories.
Click to hide internal directories.