http

package
v0.0.0-...-4afb59e Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrAdjustGlobalBuffer

func CreateOrAdjustGlobalBuffer(currentTgt *Target, newTgt *Target)

CreateOrAdjustGlobalBuffer will create or adjust the global log entry buffers which are used to migrate log entries between old and new targets.

Types

type Config

type Config struct {
	Enabled    bool              `json:"enabled"`
	Name       string            `json:"name"`
	UserAgent  string            `json:"userAgent"`
	Endpoint   *xnet.URL         `json:"endpoint"`
	AuthToken  string            `json:"authToken"`
	ClientCert string            `json:"clientCert"`
	ClientKey  string            `json:"clientKey"`
	BatchSize  int               `json:"batchSize"`
	QueueSize  int               `json:"queueSize"`
	QueueDir   string            `json:"queueDir"`
	Proxy      string            `json:"string"`
	Transport  http.RoundTripper `json:"-"`

	// Custom logger
	LogOnceIf func(ctx context.Context, err error, id string, errKind ...interface{}) `json:"-"`
}

Config http logger target

type Target

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

Target implements logger.Target and sends the json format of a log entry to the configured http endpoint. An internal buffer of logs is maintained but when the buffer is full, new logs are just ignored and an error is returned to the caller.

func New

func New(config Config) (*Target, error)

New initializes a new logger target which sends log over http to the specified endpoint

func (*Target) AssignMigrateTarget

func (h *Target) AssignMigrateTarget(migrateTgt *Target)

AssignMigrateTarget assigns a target which will eventually replace the current target.

func (*Target) Cancel

func (h *Target) Cancel()

Cancel - cancels the target. All queued messages are flushed and the function returns afterwards. All messages sent to the target after this function has been called will be dropped.

func (*Target) Endpoint

func (h *Target) Endpoint() string

Endpoint returns the backend endpoint

func (*Target) Init

func (h *Target) Init(ctx context.Context) (err error)

Init validate and initialize the http target

func (*Target) IsOnline

func (h *Target) IsOnline(ctx context.Context) bool

IsOnline returns true if the target is reachable using a cached value

func (*Target) Name

func (h *Target) Name() string

Name returns the name of the target

func (*Target) Send

func (h *Target) Send(ctx context.Context, entry interface{}) error

Send the log message 'entry' to the http target. Messages are queued in the disk if the store is enabled If Cancel has been called the message is ignored.

func (*Target) SendFromStore

func (h *Target) SendFromStore(key store.Key) (err error)

SendFromStore - reads the log from store and sends it to webhook.

func (*Target) Stats

func (h *Target) Stats() types.TargetStats

Stats returns the target statistics.

func (*Target) String

func (h *Target) String() string

func (*Target) Type

func (h *Target) Type() types.TargetType

Type - returns type of the target

Jump to

Keyboard shortcuts

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