client

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

type Backoff struct {
	// contains filtered or unexported fields
}

Backoff implements exponential backoff with randomized wait times

func NewBackoff

func NewBackoff(ctx context.Context, cfg BackoffConfig) *Backoff

NewBackoff creates a Backoff object. Pass a Context that can also terminate the operation.

func (*Backoff) Err

func (b *Backoff) Err() error

Err returns the reason for terminating the backoff, or nil if it didn't terminate

func (*Backoff) NumRetries

func (b *Backoff) NumRetries() int

NumRetries returns the number of retries so far

func (*Backoff) Ongoing

func (b *Backoff) Ongoing() bool

Ongoing returns true if caller should keep going

func (*Backoff) Reset

func (b *Backoff) Reset()

Reset the Backoff back to its initial condition

func (*Backoff) Wait

func (b *Backoff) Wait()

Wait sleeps for the backoff time then increases the retry count and backoff time Returns immediately if Context is terminated

type BackoffConfig

type BackoffConfig struct {
	MinBackoff time.Duration // start backoff at this level
	MaxBackoff time.Duration // increase exponentially to this level
	MaxRetries int           // give up after this many; zero means infinite retries
}

BackoffConfig configures a Backoff

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for pushing logs in snappy-compressed protos over HTTP.

func New

func New(cfg Config, logger Logger) (*Client, error)

New makes a new Client.

func NewWithDefaults

func NewWithDefaults(url string, externalLabels model.LabelSet, logger Logger) (*Client, error)

NewWithDefaults makes a new Client with default config.

func (*Client) Handle

func (c *Client) Handle(ls model.LabelSet, t time.Time, s string) error

Handle implement EntryHandler; adds a new line to the next batch; send is async.

func (*Client) Stop

func (c *Client) Stop()

Stop the client.

type Config

type Config struct {
	URL       string
	BatchWait time.Duration
	BatchSize int

	BackoffConfig  BackoffConfig  `yaml:"backoff_config"`
	ExternalLabels model.LabelSet `yaml:"external_labels,omitempty"`
	Timeout        time.Duration  `yaml:"timeout"`
}

Config describes configuration for a HTTP pusher client.

type Logger

type Logger func(...interface{})

Logger function to send logs of errors to

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL