server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package server provides lumberjack server implementations. The Server implementation supports multiplexing different protocol versions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrListenerClosed indicates the multiplexing network listener being closed.
	ErrListenerClosed = errors.New("listener closed")
)
View Source
var (
	// ErrNoVersionEnabled indicates no lumberjack protocol version being enabled
	// when instantiating a server.
	ErrNoVersionEnabled = errors.New("No protocol version enabled")
)

Functions

This section is empty.

Types

type Option

type Option func(*options) error

Option type for configuring server run options.

func Channel

func Channel(c chan *lj.Batch) Option

Channel option is used to register custom channel received batches will be forwarded to.

func JSONDecoder

func JSONDecoder(decoder func([]byte, interface{}) error) Option

JSONDecoder sets an alternative json decoder for parsing events if protocol version 2 is enabled. The default is json.Unmarshal.

func Keepalive

func Keepalive(kl time.Duration) Option

Keepalive configures the keepalive interval returning an ACK of length 0 to lumberjack client, notifying clients the batch being still active.

func TLS

func TLS(tls *tls.Config) Option

TLS enables and configures TLS support in lumberjack server.

func Timeout

func Timeout(to time.Duration) Option

Timeout configures server network timeouts.

func V1

func V1(b bool) Option

V1 enables lumberjack protocol version 1.

func V2

func V2(b bool) Option

V2 enables lumberjack protocol version 2.

type Server

type Server interface {
	// ReceiveChan returns a channel all received batch requests will be made
	// available on. Batches read from channel must be ACKed.
	ReceiveChan() <-chan *lj.Batch

	// Receive returns the next received batch from the receiver channel.
	// Batches returned by Receive must be ACKed.
	Receive() *lj.Batch

	// Close stops the listener, closes all active connections and closes the
	// receiver channel returned from ReceiveChan().
	Close() error
}

Server serves multiple lumberjack clients.

func ListenAndServe

func ListenAndServe(addr string, opts ...Option) (Server, error)

ListenAndServe listens on the TCP network address addr and handles batch requests from accepted lumberjack clients. Use options V1 and V2 to enable wanted protocol versions.

func ListenAndServeWith

func ListenAndServeWith(
	binder func(network, addr string) (net.Listener, error),
	addr string,
	opts ...Option,
) (Server, error)

ListenAndServeWith uses binder to create a listener for establishing a lumberjack endpoint. Use options V1 and V2 to enable wanted protocol versions.

func NewWithListener

func NewWithListener(l net.Listener, opts ...Option) (Server, error)

NewWithListener creates a new Server using an existing net.Listener. Use options V1 and V2 to enable wanted protocol versions.

Directories

Path Synopsis
Package v1 implements the lumberjack server supporting protocol version 1.
Package v1 implements the lumberjack server supporting protocol version 1.
Package v2 implements the lumberjack server supporting protocol version 2.
Package v2 implements the lumberjack server supporting protocol version 2.

Jump to

Keyboard shortcuts

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