lanz

package
v0.0.0-...-a8d7af0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package lanz implements a LANZ client that will listen to notofications from LANZ streaming server and will decode them and send them as a protobuf over a channel to a receiver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Run is the main loop of the client.
	// It connects to the LANZ server and reads the notifications, decodes them
	// and sends them to the channel.
	// In case of disconnect, it will reconnect automatically.
	Run(ch chan<- *pb.LanzRecord)
	// Stops the client.
	Stop()
}

Client is the LANZ client interface.

func New

func New(opts ...Option) Client

New creates a new client with default TCP connection to the LANZ server.

type ConnectReadCloser

type ConnectReadCloser interface {
	io.ReadCloser
	// Connect connects to the address, returning an error if it fails.
	Connect() error
}

ConnectReadCloser extends the io.ReadCloser interface with a Connect method.

type Option

type Option func(c *client)

Option is a LANZ client factory option.

func WithAddr

func WithAddr(addr string) Option

WithAddr specifies the address of the LANZ server. If WithConnector is not used, then WithAddr must be used. When WithConnector is used, WithAddr can be used to pass the address string for displaying.

func WithBackoff

func WithBackoff(d time.Duration) Option

WithBackoff specifies the backoff time after failed connection to LANZ server. It only takes effect for default connector.

func WithConnector

func WithConnector(conn ConnectReadCloser) Option

WithConnector specifies a connector used to communicate with LANZ server.

func WithLogger

func WithLogger(l logger.Logger) Option

WithLogger sets the logger to be used by this lanz client.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout specifies the timeout for connecting to LANZ server. It only takes effect for default connector.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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