events

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultFlushInterval = time.Second * 30
	DefaultBatchSize     = 50
	DefaultQueueSize     = 4080
)

Variables

View Source
var (
	// The timeout duration to push events.
	PushTimeout = time.Second * 10
)

Functions

This section is empty.

Types

type Event

type Event any

Event represents an event to send.

type Logger

type Logger struct {
	// The pusher to send events.
	Pusher *Pusher

	// The type of the SDK.
	SDKType string

	// The SDK version family.
	SDKVersionFamily string

	// The printer to print on console. Default is fmt.Println.
	Printer func(format string, v ...any)
}

A logger that logs on the console and generate log events.

func (Logger) Log

func (l Logger) Log(e logs.Entry)

type Pusher

type Pusher struct {
	// The endpoint where events are sent.
	Endpoint string

	// The duration between each event flush.
	FlushInterval time.Duration

	// The maximum number of event sent at once. Default is 50.
	BatchSize int

	// The size of the queue where events are stored. Default is 4080.
	QueueSize int

	// The HTTP transport to send events. Default is http.DefaultTransport.
	Transport http.RoundTripper

	// The function to encode events. Default is json.Marshal.
	Encode func(any) ([]byte, error)
	// contains filtered or unexported fields
}

A Pusher that pushes events to a remote endpoint.

func (*Pusher) Close

func (l *Pusher) Close()

Close ensures all events had been flushed and release allocated resources.

func (*Pusher) NewEvent

func (l *Pusher) NewEvent(e Event)

NewEvent logs the given event.

func (*Pusher) Start

func (l *Pusher) Start()

Start starts logging events asynchronously.

Jump to

Keyboard shortcuts

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