Documentation ¶
Overview ¶
Package chrysom provides a client in order to interact with argus.
Index ¶
- Constants
- Variables
- func Metrics() []xmetrics.Metric
- type Auth
- type Client
- func (c *Client) GetItems(ctx context.Context, owner string) (Items, error)
- func (c *Client) PushItem(ctx context.Context, owner string, item model.Item) (PushResult, error)
- func (c *Client) RemoveItem(ctx context.Context, id, owner string) (model.Item, error)
- func (c *Client) Start(ctx context.Context) error
- func (c *Client) Stop(ctx context.Context) error
- type ClientConfig
- type ConfigureListener
- type Items
- type Listener
- type ListenerConfig
- type ListenerFunc
- type Option
- type PushReader
- type PushResult
- type Pusher
- type Reader
Constants ¶
const ( SuccessOutcome = "success" FailureOutcome = "failure" )
Label Values
const (
OutcomeLabel = "outcome"
)
Labels
const (
PollCounter = "chrysom_polls_total"
)
Names
Variables ¶
var ( ErrAddressEmpty = errors.New("argus address is required") ErrBucketEmpty = errors.New("bucket name is required") ErrItemIDEmpty = errors.New("item ID is required") ErrItemDataEmpty = errors.New("data field in item is required") ErrUndefinedIntervalTicker = errors.New("interval ticker is nil. Can't listen for updates") ErrAuthAcquirerFailure = errors.New("failed acquiring auth token") ErrFailedAuthentication = errors.New("failed to authentication with argus") ErrBadRequest = errors.New("argus rejected the request as invalid") ErrListenerNotStopped = errors.New("listener is either running or starting") ErrListenerNotRunning = errors.New("listener is either stopped or stopping") )
Errors that can be returned by this package. Since some of these errors are returned wrapped, it is safest to use errors.Is() to check for them. Some internal errors might be unwrapped from output errors but unless these errors become exported, they are not part of the library API and may change in future versions.
Functions ¶
Types ¶
type Auth ¶
type Auth struct { JWT acquire.RemoteBearerTokenAcquirerOptions Basic string }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) PushItem ¶ added in v0.3.11
PushItem creates a new item if one doesn't already exist. If an item exists and the ownership matches, the item is simply updated.
func (*Client) RemoveItem ¶ added in v0.3.11
RemoveItem removes the item if it exists and returns the data associated to it.
type ClientConfig ¶
type ClientConfig struct { // Address is the Argus URL (i.e. https://example-argus.io:8090) Address string // Bucket partition to be used by this client. Bucket string // HTTPClient refers to the client that will be used to send requests. // (Optional) Defaults to http.DefaultClient. HTTPClient *http.Client // Auth provides the mechanism to add auth headers to outgoing requests. // (Optional) If not provided, no auth headers are added. Auth Auth // Logger to be used by the client. // (Optional). By default a no op logger will be used. Logger log.Logger // Listen helps enable and configure the listener feature of the client. // (Optional) If section is not provided with Listener, this // feature will be disabled for the client. Listen ListenerConfig }
type ConfigureListener ¶
type Listener ¶
type Listener interface { // Update is called when we get changes to our item listeners with either // additions, or updates. // // The list of hooks must contain only the current items. Update(items Items) }
type ListenerConfig ¶ added in v0.3.12
type ListenerConfig struct { // Listener provides a mechanism to fetch a copy of all items within a bucket on // an interval. // (Optional). If not provided, listening won't be enabled for this client. Listener Listener // PullInterval is how often listeners should get updates. // (Optional). Defaults to 5 seconds. PullInterval time.Duration // MetricsProvider helps initialize metrics collectors. // (Optional). By default a discard provider will be used. MetricsProvider provider.Provider }
ListenerConfig contains config data to enable listening for the Argus client.
type ListenerFunc ¶
type ListenerFunc func(items Items)
func (ListenerFunc) Update ¶
func (listener ListenerFunc) Update(items Items)
type Option ¶
type Option func(r *storeConfig)
Option is the function used to configure a store.
func WithListener ¶
WithListener sets a Listener to use for the store.
func WithLogger ¶
WithLogger sets a logger to use for the store.
func WithStorage ¶
WithStorage sets a Pusher to use for the store.
type PushReader ¶ added in v0.3.3
type PushResult ¶ added in v0.3.8
type PushResult string
PushResult is a simple type to indicate the result type for the PushItem operation.
const ( CreatedPushResult PushResult = "created" UpdatedPushResult PushResult = "ok" )
Types of pushItem successful results.
type Pusher ¶
type Pusher interface { // PushItem adds the item and establishes its link to the given owner in the store. PushItem(ctx context.Context, owner string, item model.Item) (PushResult, error) // Remove will remove the matching item from the store and return it. RemoveItem(ctx context.Context, id, owner string) (model.Item, error) }
type Reader ¶
type Reader interface { // GeItems returns all the items that belong to this owner. GetItems(ctx context.Context, owner string) (Items, error) // Start kicks off listening for snapshots of all items in the store. Start(ctx context.Context) error // Stop will stop the listener provided there was an active one. Stop(ctx context.Context) error }