config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package config implements command-line flag parsing and fer devices configuration from JSON files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Name    string   `json:"name"`
	Sockets []Socket `json:"sockets,omitempty"`

	Type        string `json:"type,omitempty"`    // Type is the type of a Socket (PUB/SUB/PUSH/PULL/...)
	Method      string `json:"method,omitempty"`  // Method to operate the socket (connect/bind)
	Address     string `json:"address,omitempty"` // Address is the socket end-point
	SendBufSize int    `json:"sndBufSize,omitempty"`
	RecvBufSize int    `json:"rcvBufSize,omitempty"`
	RateLogging int    `json:"rateLogging,omitempty"`
}

Channel holds the configuration of a channel.

func (*Channel) UnmarshalJSON

func (ch *Channel) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Config

type Config struct {
	Options   Options `json:"fairMQOptions"`
	ID        string  `json:"fer_id,omitempty"`
	Transport string  `json:"fer_transport,omitempty"` // zeromq, nanomsg, chan
	Control   string  `json:"fer_control,omitempty"`
}

Config holds the configuration of a Fer program.

func Parse

func Parse() (Config, error)

Parse parses the command-line flags from os.Args[1:]. Must be called after all flags are defined and before flags are accessed by the program.

type Device

type Device struct {
	Doc      string    `json:"_______COMMENT:,omitempty"`
	ID       string    `json:"id,omitempty"`
	Key      string    `json:"key,omitempty"`
	Channels []Channel `json:"channels"`
}

Device holds the configuration of a device.

func (Device) Name

func (dev Device) Name() string

Name returns the name of a device (either its key or its id).

func (*Device) UnmarshalJSON

func (dev *Device) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Options

type Options struct {
	Devices []Device `json:"devices"`
}

Options holds the configuration of a Fer MQ program.

func (Options) Device

func (opts Options) Device(name string) (Device, bool)

Device returns the configuration of a device by name.

func (*Options) UnmarshalJSON

func (opts *Options) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Socket

type Socket struct {
	Type        string `json:"type"`    // Type is the type of a Socket (PUB/SUB/PUSH/PULL/...)
	Method      string `json:"method"`  // Method to operate the socket (connect/bind)
	Address     string `json:"address"` // Address is the socket end-point
	SendBufSize int    `json:"sndBufSize"`
	RecvBufSize int    `json:"rcvBufSize"`
	RateLogging int    `json:"rateLogging"`
}

Socket holds the configuration of a socket.

func (*Socket) UnmarshalJSON

func (sck *Socket) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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