service

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPort       = 17106
	DefaultFeatureDir = "/etc/nameq/features"
	DefaultStateDir   = "/run/nameq/state"
)

Default values for some Params.

Variables

View Source
var (
	// Preset dictionary used for compressing UDP packets with DEFLATE.
	PacketCompressionDict = []byte("{\"ip_addr\":\",\"time_ns\":,\"names\":[\",\"],\"features\":{\":true,\"}}}")
)

Functions

func GuessAddr

func GuessAddr() string

GuessAddr tries to find a local interface suitable for the Addr parameter.

func HandleSignals

func HandleSignals(cancel context.CancelFunc)

HandleSignals cancels on termination or interrupt.

func Serve

func Serve(ctx context.Context, p *Params) (err error)

Serve indefinitely.

Types

type Log

type Log struct {
	ErrorLogger Logger
	InfoLogger  Logger
	DebugLogger Logger
}

Log configures optional loggers.

func (*Log) Debug

func (l *Log) Debug(args ...interface{})

func (*Log) Debugf

func (l *Log) Debugf(fmt string, args ...interface{})

func (*Log) DefaultInit

func (l *Log) DefaultInit(network, addr, tag string, debug bool) (err error)

DefaultInit configures at least the error and info loggers, targetting stderr or syslog.

func (*Log) Error

func (l *Log) Error(args ...interface{})

func (*Log) Errorf

func (l *Log) Errorf(fmt string, args ...interface{})

func (*Log) Info

func (l *Log) Info(args ...interface{})

func (*Log) Infof

func (l *Log) Infof(fmt string, args ...interface{})

type Logger

type Logger interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
}

Logger is a subset of the standard log.Logger.

type Node

type Node struct {
	IPAddr   string                      `json:"ip_addr,omitempty"`
	TimeNs   int64                       `json:"time_ns,omitempty"`
	Features map[string]*json.RawMessage `json:"features,omitempty"`
}

Node is a JSON-compatible representation of a host. IPAddr and TimeNs are used when sending via UDP, but not when stored in S3.

type PacketMode

type PacketMode struct {
	Id     int    // Identifies the configuration.  Must be in range [0..255].
	Secret []byte // The shared HMAC-SHA1 key.
}

PacketMode specifies a shared UDP packet configuration.

type Params

type Params struct {
	Addr         string // Required.
	Port         int
	Features     string
	FeatureDir   string
	StateDir     string
	SendMode     *PacketMode         // Required.
	ReceiveModes map[int]*PacketMode // Defaults to SendMode.
	S3Creds      []byte
	S3Region     string // Required unless S3DryRun is set.
	S3Bucket     string // Required unless S3DryRun is set.
	S3Prefix     string
	S3DryRun     bool
	Log          Log
}

Params of the service.

func DefaultParams

func DefaultParams() *Params

DefaultParams fills in some values. Log is not initialized.

Jump to

Keyboard shortcuts

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