Documentation ¶
Index ¶
- Variables
- func Walk(ctx context.Context, sourceID string, v Visitor, r Reader, opts ...WalkOption)
- func Window(ctx context.Context, v Visitor, w Walker, opts ...WindowOption)
- type AlwaysDoneBackoff
- type AlwaysRetryBackoff
- type Backoff
- type Client
- func (c *Client) Meta(ctx context.Context) (map[string]*logcache_v1.MetaInfo, error)
- func (c *Client) PromQL(ctx context.Context, query string, opts ...PromQLOption) (*logcache_v1.PromQL_InstantQueryResult, error)
- func (c *Client) PromQLRange(ctx context.Context, query string, opts ...PromQLOption) (*logcache_v1.PromQL_RangeQueryResult, error)
- func (c *Client) PromQLRangeRaw(ctx context.Context, query string, opts ...PromQLOption) (*PromQLQueryResult, error)
- func (c *Client) PromQLRaw(ctx context.Context, query string, opts ...PromQLOption) (*PromQLQueryResult, error)
- func (c *Client) Read(ctx context.Context, sourceID string, start time.Time, opts ...ReadOption) ([]*loggregator_v2.Envelope, error)
- type ClientOption
- type HTTPClient
- type Oauth2HTTPClient
- type Oauth2Option
- type PromQLOption
- type PromQLQueryResult
- type PromQLResultData
- type ReadOption
- type Reader
- type RetryBackoff
- type Visitor
- type WalkOption
- func WithWalkBackoff(b Backoff) WalkOption
- func WithWalkDelay(delay time.Duration) WalkOption
- func WithWalkEndTime(t time.Time) WalkOption
- func WithWalkEnvelopeTypes(t ...logcache_v1.EnvelopeType) WalkOption
- func WithWalkLimit(limit int) WalkOption
- func WithWalkLogger(l *log.Logger) WalkOption
- func WithWalkStartTime(t time.Time) WalkOption
- type Walker
- type WindowOption
Constants ¶
This section is empty.
Variables ¶
var ( LAST_LOG_CACHE_VERSION_WITHOUT_INFO = semver.Version{ Major: 1, Minor: 4, Patch: 7, } FIRST_LOG_CACHE_VERSION_AFTER_API_MOVE = semver.Version{ Major: 2, Minor: 0, Patch: 0, } )
Functions ¶
func Window ¶
func Window(ctx context.Context, v Visitor, w Walker, opts ...WindowOption)
Window crawls a reader incrementally to give the Visitor a batch of envelopes. Each start time is incremented by the set increment duration if that window produced data or not. This is useful when looking for trends over time.
Types ¶
type AlwaysDoneBackoff ¶
type AlwaysDoneBackoff struct{}
AlwaysDoneBackoff returns false for both OnErr and OnEmpty.
func (AlwaysDoneBackoff) OnEmpty ¶
func (b AlwaysDoneBackoff) OnEmpty() bool
OnEmpty implements Backoff.
func (AlwaysDoneBackoff) OnErr ¶
func (b AlwaysDoneBackoff) OnErr(error) bool
OnErr implements Backoff.
type AlwaysRetryBackoff ¶
type AlwaysRetryBackoff struct {
// contains filtered or unexported fields
}
AlwaysRetryBackoff returns true for both OnErr and OnEmpty after sleeping the given interval.
func NewAlwaysRetryBackoff ¶
func NewAlwaysRetryBackoff(interval time.Duration) AlwaysRetryBackoff
NewAlwaysRetryBackoff returns a new AlwaysRetryBackoff.
func (AlwaysRetryBackoff) OnEmpty ¶
func (b AlwaysRetryBackoff) OnEmpty() bool
OnEmpty implements Backoff.
func (AlwaysRetryBackoff) OnErr ¶
func (b AlwaysRetryBackoff) OnErr(error) bool
OnErr implements Backoff.
type Backoff ¶
Backoff is used to determine what to do if there is an empty batch or error. If there is an error, it will be passed to the method OnErr. If there is not an error and just an empty batch, the method OnEmpty will be invoked. If the either method returns false, then Walk exits. On a successful read that has envelopes, Reset will be invoked.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client reads from LogCache via the RESTful or gRPC API.
func NewClient ¶
func NewClient(addr string, opts ...ClientOption) *Client
NewIngressClient creates a Client.
func (*Client) PromQL ¶
func (c *Client) PromQL( ctx context.Context, query string, opts ...PromQLOption, ) (*logcache_v1.PromQL_InstantQueryResult, error)
PromQL issues a PromQL instant query against Log Cache data.
func (*Client) PromQLRange ¶
func (c *Client) PromQLRange( ctx context.Context, query string, opts ...PromQLOption, ) (*logcache_v1.PromQL_RangeQueryResult, error)
PromQL issues a PromQL range query against Log Cache data.
func (*Client) PromQLRangeRaw ¶
func (c *Client) PromQLRangeRaw( ctx context.Context, query string, opts ...PromQLOption, ) (*PromQLQueryResult, error)
func (*Client) PromQLRaw ¶
func (c *Client) PromQLRaw( ctx context.Context, query string, opts ...PromQLOption, ) (*PromQLQueryResult, error)
type ClientOption ¶
type ClientOption interface {
// contains filtered or unexported methods
}
ClientOption configures the LogCache client.
func WithHTTPClient ¶
func WithHTTPClient(h HTTPClient) ClientOption
WithHTTPClient sets the HTTP client. It defaults to a client that timesout after 5 seconds.
func WithViaGRPC ¶
func WithViaGRPC(opts ...grpc.DialOption) ClientOption
WithViaGRPC enables gRPC instead of HTTP/1 for reading from LogCache.
type HTTPClient ¶
HTTPClient is an interface that represents a http.Client.
type Oauth2HTTPClient ¶
type Oauth2HTTPClient struct {
// contains filtered or unexported fields
}
Oauth2HTTPClient sets the "Authorization" header of any outgoing request. It gets a JWT from the configured Oauth2 server. It only gets a new JWT when a request comes back with a 401.
func NewOauth2HTTPClient ¶
func NewOauth2HTTPClient(oauth2Addr, client, clientSecret string, opts ...Oauth2Option) *Oauth2HTTPClient
NewOauth2HTTPClient creates a new Oauth2HTTPClient.
func (*Oauth2HTTPClient) Do ¶
Do implements HTTPClient. It adds the Authorization header to the request (unless the header already exists). If the token is expired, it will reach out the Oauth2 server and get a new one. The given error CAN be from the request to the Oauth2 server.
Do modifies the given Request. It is invalid to use the same Request instance on multiple go-routines.
type Oauth2Option ¶
type Oauth2Option interface {
// contains filtered or unexported methods
}
Oauth2Option configures the Oauth2HTTPClient.
func WithOauth2HTTPClient ¶
func WithOauth2HTTPClient(client HTTPClient) Oauth2Option
WithOauth2HTTPClient sets the HTTPClient for the Oauth2HTTPClient. It defaults to the same default as Client.
func WithOauth2HTTPUser ¶
func WithOauth2HTTPUser(username, password string) Oauth2Option
WithOauth2HTTPUser sets the username and password for user authentication.
type PromQLOption ¶
PromQLOption configures the URL that is used to submit the query. The RawQuery is set to the decoded query parameters after each option is invoked.
func WithPromQLEnd ¶
func WithPromQLEnd(t time.Time) PromQLOption
func WithPromQLStart ¶
func WithPromQLStart(t time.Time) PromQLOption
func WithPromQLStep ¶
func WithPromQLStep(step string) PromQLOption
func WithPromQLTime ¶
func WithPromQLTime(t time.Time) PromQLOption
WithPromQLTime returns a PromQLOption that configures the 'time' query parameter for a PromQL query.
type PromQLQueryResult ¶
type PromQLQueryResult struct { Status string `json:"status"` Data PromQLResultData `json:"data"` ErrorType string `json:"errorType,omitempty"` Error string `json:"error,omitempty"` }
type PromQLResultData ¶
type PromQLResultData struct { ResultType string `json:"resultType"` Result json.RawMessage `json:"result,omitempty"` }
type ReadOption ¶
ReadOption configures the URL that is used to submit the query. The RawQuery is set to the decoded query parameters after each option is invoked.
func WithDescending ¶
func WithDescending() ReadOption
WithDescending set the 'descending' query parameter to true. It defaults to false, yielding ascending order.
func WithEndTime ¶
func WithEndTime(t time.Time) ReadOption
WithEndTime sets the 'end_time' query parameter to the given time. It defaults to empty, and therefore the end of the cache.
func WithEnvelopeTypes ¶
func WithEnvelopeTypes(t ...logcache_v1.EnvelopeType) ReadOption
WithEnvelopeTypes sets the 'envelope_types' query parameter to the given value. It defaults to empty, and therefore any envelope type.
func WithLimit ¶
func WithLimit(limit int) ReadOption
WithLimit sets the 'limit' query parameter to the given value. It defaults to empty, and therefore 100 envelopes.
type Reader ¶
type Reader func( ctx context.Context, sourceID string, start time.Time, opts ...ReadOption, ) ([]*loggregator_v2.Envelope, error)
Reader reads envelopes from LogCache. It will be invoked by Walker several time to traverse the length of the cache.
type RetryBackoff ¶
type RetryBackoff struct {
// contains filtered or unexported fields
}
RetryBackoff returns true for both OnErr and OnEmpty after sleeping the given interval for a limited number of times.
func NewRetryBackoff ¶
func NewRetryBackoff(interval time.Duration, maxCount int) *RetryBackoff
NewRetryBackoff returns a new RetryBackoff.
func NewRetryBackoffOnErr ¶
func NewRetryBackoffOnErr(interval time.Duration, maxCount int) *RetryBackoff
NewRetryBackoffOnErr returns a new RetryBackoff that only backs off no errors.
type Visitor ¶
type Visitor func([]*loggregator_v2.Envelope) bool
Visitor is invoked for each envelope batch. If the function returns false, it doesn't make any more requests. Otherwise it reaches out for the next batch of envelopes.
type WalkOption ¶
type WalkOption interface {
// contains filtered or unexported methods
}
WalkOption overrides defaults for Walk.
func WithWalkBackoff ¶
func WithWalkBackoff(b Backoff) WalkOption
WithWalkBackoff sets the backoff strategy for an empty batch or error. It defaults to stopping on an error or empty batch via AlwaysDoneBackoff.
func WithWalkDelay ¶
func WithWalkDelay(delay time.Duration) WalkOption
WithWalkDelay sets the value that the walk algorithm will consider "old" enough. If an envelope has a timestamp that has a value that is greater than time.Now().Add(-delay), it will be considered too "new", and not included. This protects from distributed clocks causing data to be skipped. Defaults to 1 second.
func WithWalkEndTime ¶
func WithWalkEndTime(t time.Time) WalkOption
WithWalkEndTime sets the end time of the query. Once reached, Walk will exit.
func WithWalkEnvelopeTypes ¶
func WithWalkEnvelopeTypes(t ...logcache_v1.EnvelopeType) WalkOption
WithWalkEnvelopeType sets the envelope_types of the query.
func WithWalkLimit ¶
func WithWalkLimit(limit int) WalkOption
WithWalkLimit sets the limit of the query.
func WithWalkLogger ¶
func WithWalkLogger(l *log.Logger) WalkOption
WithWalkLogger is used to set the logger for the Walk. It defaults to not logging.
func WithWalkStartTime ¶
func WithWalkStartTime(t time.Time) WalkOption
WithWalkStartTime sets the start time of the query.
type Walker ¶
Walker walks a reader. It makes several calls to get all the data between a boundary of time.
func BuildWalker ¶
BuildWalker captures the sourceID and reader to be used with a Walker.
type WindowOption ¶
type WindowOption interface {
// contains filtered or unexported methods
}
WindowOption configures the Window algorithm.
func WithWindowInterval ¶
func WithWindowInterval(i time.Duration) WindowOption
WithWindowInterval sets the duration to advance the start and end of the query. It defaults to a minute.
func WithWindowLogger ¶
func WithWindowLogger(l *log.Logger) WindowOption
WithWindowLogger is used to set the logger for the Walk. It defaults to not logging.
func WithWindowStartTime ¶
func WithWindowStartTime(t time.Time) WindowOption
WithWindowStartTime sets the start time of the query. It defaults to Now-Width.
func WithWindowWidth ¶
func WithWindowWidth(w time.Duration) WindowOption
WithWindowWidth sets the width (end-start=width) of the query. It defaults to an hour.