format

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base64Decode

type Base64Decode struct {
	// contains filtered or unexported fields
}

Base64Decode is a formatter that decodes a base64 message. If a message is not or only partly base64 encoded an error will be logged and the decoded part is returned. RFC 4648 is expected. Configuration example

  • "<producer|stream>": Formatter: "format.Base64Decode" Dictionary: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890+/"

Dictionary defines the 64-character base64 lookup dictionary to use. When left empty a dictionary as defined by RFC4648 is used. This is the default.

func (*Base64Decode) Configure

func (format *Base64Decode) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Base64Decode) Format

func (format *Base64Decode) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format returns the original message payload

type Base64Encode

type Base64Encode struct {
	// contains filtered or unexported fields
}

Base64Encode is a formatter that encodes a message as base64. Configuration example

  • "<producer|stream>": Formatter: "format.Base64Encode" Dictionary: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890+/"

Dictionary defines the 64-character base64 lookup dictionary to use. When left empty a dictionary as defined by RFC4648 is used. This is the default.

Base64DataFormatter defines a formatter that is applied before the base64 encoding takes place. By default this is set to "format.Forward"

func (*Base64Encode) Configure

func (format *Base64Encode) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Base64Encode) Format

func (format *Base64Encode) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format returns the original message payload

type Envelope

type Envelope struct {
	// contains filtered or unexported fields
}

Envelope is a formatter that allows prefixing and/or postfixing a message with configurable strings. Configuration example

  • "<producer|stream>": Formatter: "format.Envelope" EnvelopeFormatter: "format.Forward" Prefix: "<data>" Postfix: "</data>\n"

Prefix defines the message prefix. By default this is set to "". Special characters like \n \r \t will be transformed into the actual control characters.

Postfix defines the message postfix. By default this is set to "\n". Special characters like \n \r \t will be transformed into the actual control characters.

EnvelopeDataFormatter defines the formatter for the data transferred as message. By default this is set to "format.Forward"

func (*Envelope) Configure

func (format *Envelope) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Envelope) Format

func (format *Envelope) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format adds prefix and postfix to the message formatted by the base formatter

type Forward

type Forward struct {
}

Forward is a formatter that passes a message as is Configuration example

  • "<producer|stream>": Formatter: "format.Forward"

func (*Forward) Configure

func (format *Forward) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Forward) Format

func (format *Forward) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format returns the original message payload

type Hostname

type Hostname struct {
	// contains filtered or unexported fields
}

Hostname is a formatter that prefixes a message with the hostname. Configuration example

  • "<producer|stream>": Formatter: "format.Hostname" HostnameFormatter: "format.Envelope"

HostnameDataFormatter defines the formatter for the data transferred as message. By default this is set to "format.Envelope"

func (*Hostname) Configure

func (format *Hostname) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Hostname) Format

func (format *Hostname) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format prepends the Hostname of the message to the message.

type Identifier

type Identifier struct {
	// contains filtered or unexported fields
}

Identifier is a formatter that will generate a (mostly) unique 64 bit identifier number from the message timestamp and sequence number. The message payload will not be encoded.

  • "<producer|stream>": Formatter: "format.Identifier" IdentifierType: "hash"

IdentifierType defines the algorithm used to generate the message id. This my be one of the following: "hash", "time", "seq", "seqhex". By default this is set to "time".

  • When using "hash" the message payload will be hashed using fnv1a and returned

as hex.

  • When using "time" the id will be formatted YYMMDDHHmmSSxxxxxxx where x

denotes the sequence number modulo 10.000.000. I.e. 10mil messages per second are possible before there is a collision.

  • When using "seq" the id will be returned as the integer representation of

the sequence number.

  • When using "seqhex" the id will be returned as the hex representation of

the sequence number.

IdentifierDataFormatter defines the formatter for the data that is used to build the identifier from. By default this is set to "format.Forward"

func (*Identifier) Configure

func (format *Identifier) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Identifier) Format

func (format *Identifier) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format generates a unique identifier from the message contents or metadata.

type JSON

type JSON struct {
	// contains filtered or unexported fields
}

JSON is a formatter that passes a message encapsulated as JSON in the form {"message":"..."}. The actual message is formatted by a nested formatter and HTML escaped. Configuration example

  • "<producer|stream>": Formatter: "format.JSON" JSONStartState: "findKey" JSONDirectives:
  • 'findKey :": key ::'
  • 'findKey :}: : pop : end'
  • 'key :": findVal : : key'
  • 'findVal :\:: value ::'

JSONStartState defines the initial parser state when parsing a message. By default this is set to "" which will fall back to the first state used in the JSONDirectives array.

JSONTimestampRead defines the go timestamp format expected from fields that are parsed as "dat". By default this is set to "20060102150405"

JSONTimestampWrite defines the go timestamp format that "dat" fields will be converted to. By default this is set to "2006-01-02 15:04:05 MST"

JSONDirectives defines an array of parser directives. This setting is mandatory and has no default value. Each string must be of the following format:

State:Token:NextState:Flag,Flag,...:Function

Spaces will be stripped from all fields but Token. If a fields requires a colon it has to be escaped with a backslash. Other escape characters supported are \n, \r and \t. Flag can be a set of the following flags

  • continue -> Prepend the token to the next match
  • append -> Append the token to the current match and continue reading
  • include -> Append the token to the current match
  • push -> Push the current state to the stack
  • pop -> Pop the stack and use the returned state if possible

The following names are allowed in the Function field:

  • key -> Write the current match as a key
  • val -> Write the current match as a value without quotes
  • esc -> Write the current match as a escaped string value
  • dat -> Write the current match as a timestamp value
  • arr -> Start a new array
  • obj -> Start a new object
  • end -> Close an array or object
  • arr+val -> arr followed by val
  • arr+esc -> arr followed by esc
  • arr+dat -> arr followed by dat
  • val+end -> val followed by end
  • esc+end -> esc followed by end
  • dat+end -> dat followed by end

If num or str is written without a previous key write, a key will be auto generated from the current parser state name. This does not happen when inside an array. If key is written without a previous value write, a null value will be written. This does not happen after an object has been started. A key write inside an array will cause the array to be closed. If the array is nested, all arrays will be closed.

func (*JSON) Configure

func (format *JSON) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*JSON) Format

func (format *JSON) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format parses the incoming message and generates JSON from it. This function is mutex locked.

type Runlength

type Runlength struct {
	// contains filtered or unexported fields
}

Runlength is a formatter that prepends the length of the message, followed by a ":". The actual message is formatted by a nested formatter. Configuration example

  • "<producer|stream>": Formatter: "format.Runlength" RunlengthFormatter: "format.Envelope"

RunlengthDataFormatter defines the formatter for the data transferred as message. By default this is set to "format.Forward"

func (*Runlength) Configure

func (format *Runlength) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Runlength) Format

func (format *Runlength) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format prepends the length of the message (followed by ":") to the message.

type Sequence

type Sequence struct {
	// contains filtered or unexported fields
}

Sequence is a formatter that allows prefixing a message with the message's sequence number Configuration example

  • "<producer|stream>": Formatter: "format.Sequence" SequenceFormatter: "format.Envelope"

SequenceDataFormatter defines the formatter for the data transferred as message. By default this is set to "format.Forward"

func (*Sequence) Configure

func (format *Sequence) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Sequence) Format

func (format *Sequence) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format prepends the sequence number of the message (followed by ":") to the message.

type StreamMod

type StreamMod struct {
	// contains filtered or unexported fields
}

StreamMod is a formatter that modifies a message's stream by reading a prefix from the message's data (and discarding it). The prefix is defined by everything before a given delimiter in the message. If no delimiter is found or the prefix is empty the message stream is not changed. Configuration example

  • "<producer|stream>": Formatter: "format.StreamMod" StreamModFormatter: "format.Forward" StreamModDelimiter: "$"

StreamModFormatter defines the formatter for the data transferred as message. By default this is set to "format.Forward"

StreamModDelimiter defines the delimiter to search when extracting the stream name. By default this is set to ":".

func (*StreamMod) Configure

func (format *StreamMod) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*StreamMod) Format

func (format *StreamMod) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format adds prefix and postfix to the message formatted by the base formatter

type Timestamp

type Timestamp struct {
	// contains filtered or unexported fields
}

Timestamp is a formatter that allows prefixing a message with a timestamp (time of arrival at gollum) as well as postfixing it with a delimiter string. Configuration example

  • "<producer|stream>": Formatter: "format.Timestamp" TimestampFormatter: "format.Envelope" Timestamp: "2006-01-02T15:04:05.000 MST | "

Timestamp defines a Go time format string that is used to format the actual timestamp that prefixes the message. By default this is set to "2006-01-02 15:04:05 MST | "

TimestampDataFormatter defines the formatter for the data transferred as message. By default this is set to "format.Forward"

func (*Timestamp) Configure

func (format *Timestamp) Configure(conf core.PluginConfig) error

Configure initializes this formatter with values from a plugin config.

func (*Timestamp) Format

func (format *Timestamp) Format(msg core.Message) ([]byte, core.MessageStreamID)

Format prepends the timestamp of the message to the message.

Jump to

Keyboard shortcuts

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