Documentation ¶
Overview ¶
Package chrysom provides a client in order to interact with argus.
Index ¶
Constants ¶
const ( SuccessOutcome = "success" FailureOutcome = "failure" )
Label Values
const (
OutcomeLabel = "outcome"
)
Labels
const (
PollCounter = "chrysom_polls_total"
)
Names
Variables ¶
var ( ErrNilMeasures = errors.New("measures cannot be nil") 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") ErrBadRequest = errors.New("argus rejected the request as invalid") )
var ( ErrFailedAuthentication = errors.New("failed to authentication with argus") ErrListenerNotStopped = errors.New("listener is either running or starting") ErrListenerNotRunning = errors.New("listener is either stopped or stopping") ErrNoListenerProvided = errors.New("no listener provided") ErrNoReaderProvided = errors.New("no reader provided") )
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 ¶
func ProvideMetrics ¶ added in v0.5.0
Metrics returns the Metrics relevant to this package
Types ¶
type Auth ¶
type Auth struct { JWT acquire.RemoteBearerTokenAcquirerOptions Basic string }
Auth contains authorization data for requests to Argus.
type BasicClient ¶ added in v0.6.0
type BasicClient struct {
// contains filtered or unexported fields
}
BasicClient is the client used to make requests to Argus.
func NewBasicClient ¶ added in v0.6.0
func NewBasicClient(config BasicClientConfig, getLogger func(context.Context) *zap.Logger) (*BasicClient, error)
NewBasicClient creates a new BasicClient that can be used to make requests to Argus.
func (*BasicClient) GetItems ¶ added in v0.6.0
GetItems fetches all items that belong to a given owner.
func (*BasicClient) PushItem ¶ added in v0.6.0
func (c *BasicClient) PushItem(ctx context.Context, owner string, item model.Item) (PushResult, error)
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 (*BasicClient) RemoveItem ¶ added in v0.6.0
RemoveItem removes the item if it exists and returns the data associated to it.
type BasicClientConfig ¶ added in v0.6.0
type BasicClientConfig 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 }
BasicClientConfig contains config data for the client that will be used to make requests to the Argus client.
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 ListenerClient ¶ added in v0.6.0
type ListenerClient struct {
// contains filtered or unexported fields
}
ListenerClient is the client used to poll Argus for updates.
func NewListenerClient ¶ added in v0.6.0
func NewListenerClient(config ListenerClientConfig, setLogger func(context.Context, *zap.Logger) context.Context, measures *Measures, r Reader, ) (*ListenerClient, error)
NewListenerClient creates a new ListenerClient to be used to poll Argus for updates.
func (*ListenerClient) Start ¶ added in v0.6.0
func (c *ListenerClient) Start(ctx context.Context) error
Start begins listening for updates on an interval given that client configuration is setup correctly. If a listener process is already in progress, calling Start() is a NoOp. If you want to restart the current listener process, call Stop() first.
type ListenerClientConfig ¶ added in v0.6.0
type ListenerClientConfig 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 // Logger to be used by the client. // (Optional). By default a no op logger will be used. Logger *zap.Logger }
ListenerConfig contains config data for polling the Argus client.
type ListenerFunc ¶
type ListenerFunc func(items Items)
func (ListenerFunc) Update ¶
func (l ListenerFunc) Update(items Items)
type Measures ¶ added in v0.5.0
type Measures struct { fx.In Polls *prometheus.CounterVec `name:"chrysom_polls_total"` }
type PushReader ¶ added in v0.3.3
type PushResult ¶ added in v0.3.8
type PushResult int64
PushResult is a simple type to indicate the result type for the PushItem operation.
const ( UnknownPushResult PushResult = iota CreatedPushResult UpdatedPushResult NilPushResult )
Types of pushItem successful results.
func (PushResult) String ¶ added in v0.6.0
func (p PushResult) String() string
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) }