Documentation
¶
Index ¶
- type Client
- func (client *Client) Get(ctx context.Context, key string) (interface{}, *ResponseResult, error)
- func (client *Client) HGet(ctx context.Context, key, hkey string) (interface{}, *ResponseResult, error)
- func (client *Client) HSet(ctx context.Context, body HSetBody) (*ResponseResult, error)
- func (client *Client) Keys(ctx context.Context) ([]string, *ResponseResult, error)
- func (client *Client) LIndex(ctx context.Context, key string, index int) (interface{}, *ResponseResult, error)
- func (client *Client) RPush(ctx context.Context, body RPushBody) (*ResponseResult, error)
- func (client *Client) Remove(ctx context.Context, key string) (*ResponseResult, error)
- func (client *Client) Set(ctx context.Context, body SetBody) (*ResponseResult, error)
- type ErrGeneric
- type ErrNotFound
- type HSetBody
- type RPushBody
- type ResponseResult
- type SetBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // HTTPClient represents an initialized HTTP client that will be used to do requests. HTTPClient *http.Client // Endpoint represents an endpoint that will be used in all requests. Endpoint string }
Client stores details that are needed to work with bookish-spork.
func NewClientCustomHTTP ¶
NewClientCustomHTTP initializes a new client for bookish-spork API. using custom HTTP client. If customHTTPClient is nil - default HTTP client will be used.
func (*Client) HGet ¶
func (client *Client) HGet(ctx context.Context, key, hkey string) (interface{}, *ResponseResult, error)
HGet returns a value by hash map key.
func (*Client) LIndex ¶
func (client *Client) LIndex(ctx context.Context, key string, index int) (interface{}, *ResponseResult, error)
LIndex returns value by index in list.
type ErrGeneric ¶
type ErrGeneric struct {
Error string `json:"error"`
}
ErrGeneric represents a generic error of an HTTP response.
type ErrNotFound ¶
type ErrNotFound struct {
Error string `json:"error"`
}
ErrNotFound represents 404 status code error of an HTTP response.
type HSetBody ¶
type HSetBody struct { Key string `json:"key"` Value map[string]interface{} `json:"value"` TTL int `json:"ttl"` }
HSetBody represents hset request body.
type RPushBody ¶
type RPushBody struct { Key string `json:"key"` Value interface{} `json:"value"` TTL int `json:"ttl"` }
RPushBody represents rpush request body.
type ResponseResult ¶
type ResponseResult struct { *http.Response *ErrNotFound *ErrGeneric // Err contains an error that can be provided to a caller. Err error }
ResponseResult represents a result of an HTTP request. It embeds standard http.Response and adds custom API error representations.