logs

package
v0.0.0-...-505e376 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHttpListenerPort = "3000"

DefaultHttpListenerPort is used to set the URL where the logs will be sent by Logs API

Variables

This section is empty.

Functions

func Run

func Run(handler Handler, events ...EventType)

func Subscribe

func Subscribe(types []EventType, bufferingCfg BufferingCfg, destinationURL string, extensionID string) error

Subscribe calls the Logs API to subscribe for the log events.

Types

type BufferingCfg

type BufferingCfg struct {
	// MaxItems is the maximum number of events to be buffered in memory. (default: 10000, minimum: 1000, maximum: 10000)
	MaxItems uint32 `json:"maxItems"`
	// MaxBytes is the maximum size in bytes of the logs to be buffered in memory. (default: 262144, minimum: 262144, maximum: 1048576)
	MaxBytes uint32 `json:"maxBytes"`
	// TimeoutMS is the maximum time (in milliseconds) for a batch to be buffered. (default: 1000, minimum: 100, maximum: 30000)
	TimeoutMS uint32 `json:"timeoutMs"`
}

BufferingCfg is the configuration set for receiving logs from Logs API. Whichever of the conditions below is met first, the logs will be sent

type Client

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

Client has the listener that receives the logs and the logger that handles the received logs

func NewClient

func NewClient(cb Handler) *Client

NewClient returns an agent to listen and handle logs coming from Logs API for HTTP Make sure the agent is initialized by calling Init(agentId) before subscription for the Logs API.

func (Client) Init

func (a Client) Init(extensionID string, events ...EventType) error

Init initializes the configuration for the Logs API and subscribes to the Logs API for HTTP

func (*Client) Shutdown

func (a *Client) Shutdown()

Shutdown finalizes the logging and terminates the listener

type Destination

type Destination struct {
	Protocol   string `json:"protocol"`
	URI        string `json:"URI"`
	HttpMethod string `json:"method"`
	Encoding   string `json:"encoding"`
}

Destination is the configuration for listeners who would like to receive logs with HTTP

type EventType

type EventType string

EventType represents the type of logs in Lambda

const (
	Platform  EventType = "platform"  // Platform is to receive logs emitted by the platform
	Function  EventType = "function"  // Function is to receive logs emitted by the function
	Extension EventType = "extension" // Extension is to receive logs emitted by the extension
)

type Handler

type Handler interface {
	Init(*extension.Register) error
	Line([]byte) error
	BatchEnd()
	Shutdown(*extension.Event) error
}

type SubscribeRequest

type SubscribeRequest struct {
	SchemaVersion string       `json:"schemaVersion"`
	EventTypes    []EventType  `json:"types"`
	BufferingCfg  BufferingCfg `json:"buffering"`
	Destination   Destination  `json:"destination"`
}

SubscribeRequest is the request body that is sent to Logs API on subscribe

Jump to

Keyboard shortcuts

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