{"modulePath":"github.com/oopcode/gollum","version":"v0.3.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package format\n\n## Types\n\n```go\ntype Base64Decode struct {\n\t// contains filtered or unexported fields\n}\n```\nBase64Decode 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\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Base64Decode\" Dictionary: \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890+/\"\n\nDictionary defines the 64-character base64 lookup dictionary to use. When left empty a dictionary as defined by RFC4648 is used. This is the default.\n\n```go\nfunc (format *Base64Decode) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Base64Decode) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat returns the original message payload\n\n```go\ntype Base64Encode struct {\n\t// contains filtered or unexported fields\n}\n```\nBase64Encode is a formatter that encodes a message as base64. Configuration example\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Base64Encode\" Dictionary: \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890+/\"\n\nDictionary defines the 64-character base64 lookup dictionary to use. When left empty a dictionary as defined by RFC4648 is used. This is the default.\n\nBase64DataFormatter defines a formatter that is applied before the base64 encoding takes place. By default this is set to \"format.Forward\"\n\n```go\nfunc (format *Base64Encode) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Base64Encode) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat returns the original message payload\n\n```go\ntype Envelope struct {\n\t// contains filtered or unexported fields\n}\n```\nEnvelope is a formatter that allows prefixing and/or postfixing a message with configurable strings. Configuration example\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Envelope\" EnvelopeFormatter: \"format.Forward\" Prefix: \"\\\u003cdata\u003e\" Postfix: \"\\\u003c/data\u003e\\\\n\"\n\nPrefix defines the message prefix. By default this is set to \"\". Special characters like \\\\n \\\\r \\\\t will be transformed into the actual control characters.\n\nPostfix 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.\n\nEnvelopeDataFormatter defines the formatter for the data transferred as message. By default this is set to \"format.Forward\"\n\n```go\nfunc (format *Envelope) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Envelope) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat adds prefix and postfix to the message formatted by the base formatter\n\n```go\ntype Forward struct {\n}\n```\nForward is a formatter that passes a message as is Configuration example\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Forward\"\n\n```go\nfunc (format *Forward) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Forward) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat returns the original message payload\n\n```go\ntype Hostname struct {\n\t// contains filtered or unexported fields\n}\n```\nHostname is a formatter that prefixes a message with the hostname. Configuration example\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Hostname\" HostnameFormatter: \"format.Envelope\"\n\nHostnameDataFormatter defines the formatter for the data transferred as message. By default this is set to \"format.Envelope\"\n\n```go\nfunc (format *Hostname) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Hostname) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat prepends the Hostname of the message to the message.\n\n```go\ntype Identifier struct {\n\t// contains filtered or unexported fields\n}\n```\nIdentifier 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.\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Identifier\" IdentifierType: \"hash\"\n\nIdentifierType 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\".\n\n  - When using \"hash\" the message payload will be hashed using fnv1a and returned\n\nas hex.\n\n  - When using \"time\" the id will be formatted YYMMDDHHmmSSxxxxxxx where x\n\ndenotes the sequence number modulo 10.000.000. I.e. 10mil messages per second are possible before there is a collision.\n\n  - When using \"seq\" the id will be returned as the integer representation of\n\nthe sequence number.\n\n  - When using \"seqhex\" the id will be returned as the hex representation of\n\nthe sequence number.\n\nIdentifierDataFormatter defines the formatter for the data that is used to build the identifier from. By default this is set to \"format.Forward\"\n\n```go\nfunc (format *Identifier) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Identifier) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat generates a unique identifier from the message contents or metadata.\n\n```go\ntype JSON struct {\n\t// contains filtered or unexported fields\n}\n```\nJSON 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\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.JSON\" JSONStartState: \"findKey\" JSONDirectives:\n  - 'findKey :\":  key     ::'\n  - 'findKey :}:          : pop  : end'\n  - 'key     :\":  findVal :      : key'\n  - 'findVal :\\\\:: value   ::'\n\nJSONStartState 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.\n\nJSONTimestampRead defines the go timestamp format expected from fields that are parsed as \"dat\". By default this is set to \"20060102150405\"\n\nJSONTimestampWrite 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\"\n\nJSONDirectives defines an array of parser directives. This setting is mandatory and has no default value. Each string must be of the following format:\n\nState:Token:NextState:Flag,Flag,...:Function\n\nSpaces 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\n\n  - continue -\u003e Prepend the token to the next match\n  - append   -\u003e Append the token to the current match and continue reading\n  - include  -\u003e Append the token to the current match\n  - push     -\u003e Push the current state to the stack\n  - pop      -\u003e Pop the stack and use the returned state if possible\n\nThe following names are allowed in the Function field:\n\n  - key     -\u003e Write the current match as a key\n  - val     -\u003e Write the current match as a value without quotes\n  - esc     -\u003e Write the current match as a escaped string value\n  - dat     -\u003e Write the current match as a timestamp value\n  - arr     -\u003e Start a new array\n  - obj     -\u003e Start a new object\n  - end     -\u003e Close an array or object\n  - arr+val -\u003e arr followed by val\n  - arr+esc -\u003e arr followed by esc\n  - arr+dat -\u003e arr followed by dat\n  - val+end -\u003e val followed by end\n  - esc+end -\u003e esc followed by end\n  - dat+end -\u003e dat followed by end\n\nIf 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.\n\n```go\nfunc (format *JSON) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *JSON) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat parses the incoming message and generates JSON from it. This function is mutex locked.\n\n```go\ntype Runlength struct {\n\t// contains filtered or unexported fields\n}\n```\nRunlength is a formatter that prepends the length of the message, followed by a \":\". The actual message is formatted by a nested formatter. Configuration example\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Runlength\" RunlengthFormatter: \"format.Envelope\"\n\nRunlengthDataFormatter defines the formatter for the data transferred as message. By default this is set to \"format.Forward\"\n\n```go\nfunc (format *Runlength) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Runlength) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat prepends the length of the message (followed by \":\") to the message.\n\n```go\ntype Sequence struct {\n\t// contains filtered or unexported fields\n}\n```\nSequence is a formatter that allows prefixing a message with the message's sequence number Configuration example\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Sequence\" SequenceFormatter: \"format.Envelope\"\n\nSequenceDataFormatter defines the formatter for the data transferred as message. By default this is set to \"format.Forward\"\n\n```go\nfunc (format *Sequence) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Sequence) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat prepends the sequence number of the message (followed by \":\") to the message.\n\n```go\ntype StreamMod struct {\n\t// contains filtered or unexported fields\n}\n```\nStreamMod 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\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.StreamMod\" StreamModFormatter: \"format.Forward\" StreamModDelimiter: \"$\"\n\nStreamModFormatter defines the formatter for the data transferred as message. By default this is set to \"format.Forward\"\n\nStreamModDelimiter defines the delimiter to search when extracting the stream name. By default this is set to \":\".\n\n```go\nfunc (format *StreamMod) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *StreamMod) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat adds prefix and postfix to the message formatted by the base formatter\n\n```go\ntype Timestamp struct {\n\t// contains filtered or unexported fields\n}\n```\nTimestamp 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\n\n  - \"\\\u003cproducer|stream\u003e\": Formatter: \"format.Timestamp\" TimestampFormatter: \"format.Envelope\" Timestamp: \"2006-01-02T15:04:05.000 MST | \"\n\nTimestamp 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 | \"\n\nTimestampDataFormatter defines the formatter for the data transferred as message. By default this is set to \"format.Forward\"\n\n```go\nfunc (format *Timestamp) Configure(conf core.PluginConfig) error\n```\nConfigure initializes this formatter with values from a plugin config.\n\n```go\nfunc (format *Timestamp) Format(msg core.Message) ([]byte, core.MessageStreamID)\n```\nFormat prepends the timestamp of the message to the message.\n\n","path":"github.com/oopcode/gollum/format","name":"format","synopsis":"","isRedistributable":true}
