Documentation ¶
Index ¶
- Variables
- func ErrorFull(err error) bool
- func ErrorOverfull(err error) bool
- func ErrorRetry(err error) bool
- func SetDebug(debug int)
- type Container
- type ContainerConfig
- type Enum
- type IO
- func (io *IO) AddInput(i Input) error
- func (io *IO) AddInputChannel(channel string) error
- func (io *IO) AddInputSockSpec(sockspec string) error
- func (io *IO) AddOutput(o Output) error
- func (io *IO) Break()
- func (io *IO) Run() error
- func (io *IO) SetDebug(debug int)
- func (io *IO) SetMirrored(mirrored bool)
- type Input
- type InputFunc
- func (i InputFunc) Read() (*Message, error)
- func (i InputFunc) SetFilterGroup(group uint32)
- func (i InputFunc) SetFilterMsgtype(vendor, msgtype uint32)
- func (i InputFunc) SetFilterMsgtypeByname(vendor, msgtype string)
- func (i InputFunc) SetFilterOperator(operator uint32)
- func (i InputFunc) SetFilterSource(source uint32)
- type Message
- func (msg *Message) GetBytesField(name string, idx int) ([]byte, error)
- func (msg *Message) GetDoubleField(name string, idx int) (float64, error)
- func (msg *Message) GetEnumField(name string, idx int) (string, error)
- func (msg *Message) GetIPField(name string, idx int) (net.IP, error)
- func (msg *Message) GetIntField(name string, idx int) (int64, error)
- func (msg *Message) GetMsgtype() (vendor, msgtype uint32)
- func (msg *Message) GetStringField(name string, idx int) (string, error)
- func (msg *Message) GetUintField(name string, idx int) (uint64, error)
- func (msg *Message) Group() uint32
- func (msg *Message) MarshalJSON() ([]byte, error)
- func (msg *Message) MarshalText() ([]byte, error)
- func (msg *Message) Operator() uint32
- func (msg *Message) SetBytesField(name string, idx int, val []byte) error
- func (msg *Message) SetDoubleField(name string, idx int, val float64) error
- func (msg *Message) SetEnumField(name string, idx int, vname string) error
- func (msg *Message) SetGroup(group uint32)
- func (msg *Message) SetIPField(name string, idx int, val net.IP) error
- func (msg *Message) SetIntField(name string, idx, bitsize int, val int64) error
- func (msg *Message) SetOperator(operator uint32)
- func (msg *Message) SetSource(source uint32)
- func (msg *Message) SetStringField(name string, idx int, val string) error
- func (msg *Message) SetUintField(name string, idx, bitsize int, val uint64) error
- func (msg *Message) Source() uint32
- func (msg *Message) UnmarshalJSON(b []byte) error
- type MessageMod
- type Output
- type OutputFunc
- func (o OutputFunc) Flush() error
- func (o OutputFunc) SetBuffered(bool)
- func (o OutputFunc) SetCompression(bool)
- func (o OutputFunc) SetFilterMsgtype(vendor, msgtype uint32)
- func (o OutputFunc) SetFilterMsgtypeByname(vendor, msgtype string)
- func (o OutputFunc) SetGroup(group uint32)
- func (o OutputFunc) SetOperator(group uint32)
- func (o OutputFunc) SetRate(r *Rate)
- func (o OutputFunc) SetSource(source uint32)
- func (o OutputFunc) Write(m *Message) error
- type Rate
Constants ¶
This section is empty.
Variables ¶
var ( BufferSizeMax = int(C.nmsg_wbufsiz_max) BufferSizeMin = int(C.nmsg_wbufsiz_min) BufferSizeEther = int(C.nmsg_wbufsiz_ether) BufferSizeJumbo = int(C.nmsg_wbufsiz_jumbo) )
Buffer Size constants from libnmsg
Functions ¶
func ErrorFull ¶
ErrorFull returns true if the container is full. If the Container Add() method returns such an error, the message will need to be added to the next container.
func ErrorOverfull ¶
ErrorOverfull returns true if the container contains a single payload and its size is greater than the target size.
func ErrorRetry ¶
ErrorRetry returns true if the error indicates that the nmsg operation should be retried.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
A Container is a collection of NMSG payloads with a target size.
func NewContainer ¶
func NewContainer(conf *ContainerConfig) *Container
NewContainer creates a container with the given target size.
type ContainerConfig ¶
ContainerConfig contains
type Enum ¶
Enum contains both the numeric Value and the string Description of an enumerated NMSG field value.
type IO ¶
type IO struct {
// contains filtered or unexported fields
}
IO is a handle to a libnmsg io loop connecting one or more Inputs with one ore more Outputs.
func (*IO) AddInputChannel ¶
AddInputChannel opens an NMSG channel and adds it as an Input to the IO.
func (*IO) AddInputSockSpec ¶
AddInputSockSpec opens one or more sockets based on the sockspec (add/port ,or addr/lowport..highport) and adds it to the IO as an input.
func (*IO) SetDebug ¶
SetDebug sets the debug print level of the underlying io. Larger numbers are more verbose.
func (*IO) SetMirrored ¶
SetMirrored controls whether the IO mirrors output to all outputs (mirrored = true) or stripes its output across all outputs.
type Input ¶
type Input interface { // Read returns a Message or nil, and an error if any. Read() (*Message, error) // SetFilterMsgtype instructs the input to discard all Messages // not of the given vendor id and msgtype, specified by number. SetFilterMsgtype(vendor, msgtype uint32) // SetFilterMsgtypeByname instructs the input to discard all Messages // not of the given vendor id and msgtype, specified by name. SetFilterMsgtypeByname(vendor, msgtype string) // SetFilterSource instructs the input to discard all Messages not // from the supplied source. SetFilterSource(source uint32) // SetFilterOperator instructs the input to discard all Messages not // from the supplied operator. SetFilterOperator(operator uint32) // SetFilterGroup instructs the input to discard all Messages not // in the supplied group. SetFilterGroup(group uint32) }
An Input is a source of NMSG payloads (Messages).
func NewCallbackInput ¶
NewCallbackInput creates an NmsgInput which calls the supplied InputFunc.
type InputFunc ¶
An InputFunc is a function with the same signature as Input.Read(), usable directly as an Input.
When used directly as an Input, only the Read() method is implemented. All others are no-ops. If the functionality of the other methods is desired, the InputFunc can be passed to NewCallbackInput.
func (InputFunc) SetFilterGroup ¶
SetFilterGroup satisfies the Input interface with a no-op
func (InputFunc) SetFilterMsgtype ¶
SetFilterMsgtype satisfies the Input interface with a no-op
func (InputFunc) SetFilterMsgtypeByname ¶
SetFilterMsgtypeByname satisfies the Input interface with a no-op
func (InputFunc) SetFilterOperator ¶
SetFilterOperator satisfies the Input interface with a no-op
func (InputFunc) SetFilterSource ¶
SetFilterSource satisfies the Input interface with a no-op
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
A Message is a unit of NMSG data.
func NewMessage ¶
func NewMessage(mod *MessageMod) *Message
NewMessage initializes a message of a type given by the supplied MessageMod
func NewMessageFromPayload ¶
NewMessageFromPayload encapsulates a byte buffer in a payload with the supplied vendor and message type.
func UnpackContainer ¶
UnpackContainer returns the messages the container contains.
func (*Message) GetBytesField ¶
GetBytesField retrieves a field of type bytes from a Message.
func (*Message) GetDoubleField ¶
GetDoubleField retrieves the value of a double field in a Message
func (*Message) GetEnumField ¶
GetEnumField returns the string description of a Message field with an enumerated type.
func (*Message) GetIPField ¶
GetIPField retrieves the value of an IP field in a Message
func (*Message) GetIntField ¶
GetIntField retrieves the value of a named field of integer type from a Message.
func (*Message) GetMsgtype ¶
GetMsgtype returns the vendor and payload type of the message.
func (*Message) GetStringField ¶
GetStringField retrieves the value of a string field in a Message
func (*Message) GetUintField ¶
GetUintField retrieves the named field of a unsigned int type from a Message. If the field has an enumerated type, the numeric value is retrieved.
func (*Message) Group ¶
Group returns the group id of the message, or zero if the group id is not set.
func (*Message) MarshalJSON ¶
MarshalJSON formats a JSON representation of the Message
func (*Message) MarshalText ¶
MarshalText converts a Message to presentation format.
func (*Message) Operator ¶
Operator returns the operator id of the message, or zero if the operator id is not set.
func (*Message) SetBytesField ¶
SetBytesField sets the value of a bytes field in a Message
func (*Message) SetDoubleField ¶
SetDoubleField sets the value of a double field in a Message
func (*Message) SetEnumField ¶
SetEnumField sets the value of the named Message field to the value corresponding to the supplied description.
func (*Message) SetIPField ¶
SetIPField sets the value of an IP field in a Message
func (*Message) SetIntField ¶
SetIntField sets the value of an int16, int32, or int64 field in the message. The bitsize field specifies which size, and must by 16, 32, or 64
func (*Message) SetOperator ¶
SetOperator sets the operator id of the message.
func (*Message) SetStringField ¶
SetStringField sets the value of a string field in a Message
func (*Message) SetUintField ¶
SetUintField sets the value of a field of type uint16, uint32, or uint64. The bitsize parameter specifies which type, and must be 16, 32, or 64
func (*Message) Source ¶
Source returns the source id of the message, or zero if the source id is not set.
func (*Message) UnmarshalJSON ¶
UnmarshalJSON parses a JSON representation of the Message
type MessageMod ¶
type MessageMod struct {
// contains filtered or unexported fields
}
MessageMod something something
func MessageModLookup ¶
func MessageModLookup(v, m uint32) *MessageMod
MessageModLookup something something
func MessageModLookupByName ¶
func MessageModLookupByName(vname, mname string) *MessageMod
MessageModLookupByName something something
type Output ¶
type Output interface { // Write sends the supplied message to the Output. Write(*Message) error // SetBuffered controls whether the output buffers Messages into containers // before sending them. NmsgOutputs are buffered by default, but low volume // sources may choose to turn this off to reduce latency. SetBuffered(bool) // SetCompression controls whether the output compresses // the container data prior to sending. SetCompression(bool) // Flush writes any buffered data to the Output. Flush() error // SetFilterMsgtype instructs the output to discard all Messages // not of the supplied vendor and type, specified by number. SetFilterMsgtype(vendor, msgtype uint32) // SetFilterMsgtypeByname instructs the output to discard all Messages // not of the supplied vendor and type, specified by name. SetFilterMsgtypeByname(vendor, msgtype string) // SetRate sets an output rate limit. The rate is specified // in containers per second, and is checked every freq pauses. // The freq parameter should be about 10-15% of the rate. SetRate(rate *Rate) // SetSource instructs the output to set the source parameter // of all outbound messages to the supplied value. SetSource(source uint32) // SetOperator instructs the output to set the operator parameter // of all outbound messages to the supplied value. SetOperator(group uint32) // SetGroup instructs the output to set the group parameter // of all outbound messages to the supplied value. SetGroup(group uint32) }
An Output is a destination for NMSG data (Messages)
func NewCallbackOutput ¶
func NewCallbackOutput(o OutputFunc) Output
NewCallbackOutput creates an NmsgOutput which calls o.Send() on every message.
type OutputFunc ¶
An OutputFunc is a function with the same signature as Output.Write, usable directly as an Output.
When used directly as an Output, only the Write() method is defined. All others are no-ops.
func (OutputFunc) Flush ¶
func (o OutputFunc) Flush() error
Flush satisfies the Output interface with a no-op
func (OutputFunc) SetBuffered ¶
func (o OutputFunc) SetBuffered(bool)
SetBuffered satisfies the Output interface with a no-op
func (OutputFunc) SetCompression ¶
func (o OutputFunc) SetCompression(bool)
SetCompression satisfies the Output interface with a no-op
func (OutputFunc) SetFilterMsgtype ¶
func (o OutputFunc) SetFilterMsgtype(vendor, msgtype uint32)
SetFilterMsgtype satisfies the Output interface with a no-op
func (OutputFunc) SetFilterMsgtypeByname ¶
func (o OutputFunc) SetFilterMsgtypeByname(vendor, msgtype string)
SetFilterMsgtypeByname satisfies the Output interface with a no-op
func (OutputFunc) SetGroup ¶
func (o OutputFunc) SetGroup(group uint32)
SetGroup satisfies the Output interface with a no-op
func (OutputFunc) SetOperator ¶
func (o OutputFunc) SetOperator(group uint32)
SetOperator satisfies the Output interface with a no-op
func (OutputFunc) SetRate ¶
func (o OutputFunc) SetRate(r *Rate)
SetRate satisfies the Output interface with a no-op
func (OutputFunc) SetSource ¶
func (o OutputFunc) SetSource(source uint32)
SetSource satisfies the Output interface with a no-op
func (OutputFunc) Write ¶
func (o OutputFunc) Write(m *Message) error
Write calls the underlying function with the supplied message
type Rate ¶
type Rate struct {
// contains filtered or unexported fields
}
A Rate provides Rate limiting across one or more outputs.