Documentation
¶
Overview ¶
Package file implements file based memory for the Joe bot library. https://github.com/go-joe/joe
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Memory ¶
Memory is a joe.Option which is supposed to be passed to joe.New(…) to configure a new bot. The path indicates the destination file at which the memory will store its values encoded as JSON object. If there is already a JSON encoded file at the given path it will be loaded and decoded into memory to serve future requests. If the file exists but cannot be opened or does not contain a valid JSON object its error will be deferred until the bot is actually started via its Run() function.
Example usage:
b := joe.New("example", file.Memory("/tmp/joe.json"), … )
func NewMemory ¶
NewMemory creates a new Memory instance that persists all values to the given path. If there is already a JSON encoded file at the given path it is loaded and decoded into memory to serve future requests. An error is returned if the file exists but cannot be opened or does not contain a valid JSON object.
Types ¶
type Option ¶
type Option func(*memory) error
Option corresponds to a configuration setting of the file memory. All available options are the exported functions of this package that share the prefix "With" in their names.
func WithLogger ¶
WithLogger is a memory option that allows the caller to set a different logger. By default this option is not required because the file.Memory(…) function automatically uses the logger of the given joe.Config.