logs

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LambdaResponse

func LambdaResponse(headers map[string]string) (func(interface{}, error), error)

LambdaResponse analyzes headers and redirects log to nats subject (if header defined). Returns function to be called with lambda response.

Types

type ConnectConfig

type ConnectConfig struct {
	// ServerURL is the URL of the NATS server endpoint
	ServerURL string `json:"u,omitempty"`
	// PublisherJWT contains the NATS listener credentials
	PublisherJWT string `json:"p,omitempty"`
	// ListenerJWT contains the NATS publisher credentials
	ListenerJWT string `json:"l,omitempty"`
	// Subject is the NATS subject
	Subject string `json:"s,omitempty"`
}

ConnectConfig contains various configuration options for establishing a NATS connection

func (*ConnectConfig) Listener

func (c *ConnectConfig) Listener() (*Listener, error)

Listener creates a NATS listener from the given config

func (*ConnectConfig) Marshal

func (c *ConnectConfig) Marshal() string

Marshal returns the JSON encoding of a ConnectConfig instance

func (*ConnectConfig) Publisher

func (c *ConnectConfig) Publisher() (*Publisher, error)

Publisher creates a NATS publisher from a given config

func (*ConnectConfig) Unmarshal

func (c *ConnectConfig) Unmarshal(buf string) error

Unmarshal parses a JSON-encoded ConnectConfig instance

type ErrRemoteError

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

ErrRemoteError represents a remote error

func (*ErrRemoteError) Error

func (e *ErrRemoteError) Error() string

type LambdaListener

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

LambdaListener cretes header for calling lambda. Listens for incoming log lines and response (or multiple) responses.

func NewLambdaListener

func NewLambdaListener(c ListenerConfig) (*LambdaListener, error)

NewLambdaListener creates a new LambdaListener with the given config

func (*LambdaListener) Done

func (l *LambdaListener) Done(ctx context.Context) error

Done blocks until either a response or error is available

func (*LambdaListener) Headers

func (l *LambdaListener) Headers() map[string]string

Headers marshals the NATS publisher config

type Listener

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

Listener represents a NATS listener

func (*Listener) Close

func (l *Listener) Close() error

Close closes the underlying NATS connection

type ListenerConfig

type ListenerConfig struct {
	// ServerURL is the URL of the NATS server endpoint
	ServerURL string
	// PublisherJWT contains the NATS publisher credentials
	PublisherJWT string
	// PublisherJWT contains the NATS listener credentials
	ListenerJWT string
	// Subject is the NATS subject to listen to
	Subject string
	// LogSink is a channel where logs are pushed
	LogSink func(chan []byte)
	// Rsp is the struct where response data will be written
	Rsp interface{}
}

ListenerConfig contains various configuration options for LambdaListener

type Publisher

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

Publisher represents a NATS publisher

func (*Publisher) Close

func (p *Publisher) Close() error

Close publishes an empty message to the subject, indicating that the subject is closed

func (*Publisher) Data

func (p *Publisher) Data(buf []byte) error

Data publishes a data message to the subject

func (*Publisher) Error

func (p *Publisher) Error(err error) error

Error publishes an error message to the subject

func (*Publisher) Log

func (p *Publisher) Log(buf []byte) error

Log publishes a log message to the subject

Jump to

Keyboard shortcuts

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