Documentation
¶
Overview ¶
Package jsobs provides simple storage for objects serializable to JSON.
Index ¶
- Variables
- func IsNotFound(err error) bool
- type Client
- func (c *Client) Count(prefix string) (int, error)
- func (c *Client) CountAll() (int, error)
- func (c *Client) Delete(path string) error
- func (c *Client) List(prefix string) ([]string, error)
- func (c *Client) ListDetail(prefix string) ([]backend.Detailer, error)
- func (c *Client) Load(path string, obj any) error
- func (c *Client) LoadDetail(path string) (backend.Detailer, error)
- func (c *Client) LoadRaw(path string) ([]byte, error)
- func (c *Client) Save(path string, obj any) error
- func (c *Client) SaveExpiry(path string, obj any, expiry time.Time) error
- func (c *Client) SaveRaw(path string, raw_obj []byte) error
- func (c *Client) SaveRawExpiry(path string, raw_obj []byte, expiry time.Time) error
- func (c *Client) Shutdown(code int)
Constants ¶
This section is empty.
Variables ¶
var ExitFunc = os.Exit
Functions ¶
func IsNotFound ¶
Types ¶
type Client ¶
type Client struct {
Backend backend.BackendClient
}
Client handles save, load, list and delete operations for its Backend.
func New ¶
func New(bc backend.BackendClient, err error) (*Client, error)
New returns a client with the provided backend. Any error returned from the backend creation function is returned here.
func NewPgClient ¶
NewPgClient returns a client with a connection pool to the PostgreSQL database specified at DATABASE_URL in the environment.
Configuration for pgx may be included in the URL.
func (*Client) Count ¶
Count returns the number of non-expired objects beginning with prefix. If none are found, zero is returned.
func (*Client) Delete ¶
Delete deletes the object at path. If the object does not exist, the error returned will be ErrNotFound.
func (*Client) List ¶
List returns an array of all objects beginning with prefix. An empty array is not considered an error.
For S3, this operation may be slow if paged results are returned!
func (*Client) ListDetail ¶
ListDetail returns an array of all Detailers describing all objects beginning with prefix. An empty array is not considered an error.
This operation may be slow for any backend returning paged results!
func (*Client) LoadDetail ¶
LoadDetail retrieves the object at path and returns its details, but not the actual data.
func (*Client) Save ¶
Save marshals obj to json and stores it at path with no expiry. Any existing object at path will be overwritten.
func (*Client) SaveExpiry ¶
SaveExpiry marshals obj to json and stores it at path with expiry set. Any existing object at path will be overwritten.
func (*Client) SaveRawExpiry ¶
SaveRawExpiry behaves like SaveExpiry but sends raw_obj directly.
Use with caution!