message

package
v0.0.0-...-70ad22e Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2014 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Internal message representation.

Index

Constants

View Source
const (
	HEADER_DELIMITER_SIZE = 2                         // record separator + len
	HEADER_FRAMING_SIZE   = HEADER_DELIMITER_SIZE + 1 // unit separator
	MAX_HEADER_SIZE       = 255
	MAX_MESSAGE_SIZE      = 64 * 1024
	MAX_RECORD_SIZE       = HEADER_FRAMING_SIZE + MAX_HEADER_SIZE + MAX_MESSAGE_SIZE
	RECORD_SEPARATOR      = uint8(0x1e)
	UNIT_SEPARATOR        = uint8(0x1f)
	UUID_SIZE             = 16
)
View Source
const Default_Message_Severity int32 = 7
View Source
const FALSE = 57370
View Source
const NUMERIC_VALUE = 57367
View Source
const OP_AND = 57355
View Source
const OP_EQ = 57346
View Source
const OP_GT = 57348
View Source
const OP_GTE = 57349
View Source
const OP_LT = 57350
View Source
const OP_LTE = 57351
View Source
const OP_NE = 57347
View Source
const OP_NRE = 57353
View Source
const OP_OR = 57354
View Source
const OP_RE = 57352
View Source
const REGEXP_VALUE = 57368
View Source
const STRING_VALUE = 57366
View Source
const TRUE = 57369
View Source
const VAR_ENVVERSION = 57360
View Source
const VAR_FIELDS = 57365
View Source
const VAR_HOSTNAME = 57361
View Source
const VAR_LOGGER = 57358
View Source
const VAR_PAYLOAD = 57359
View Source
const VAR_PID = 57364
View Source
const VAR_SEVERITY = 57363
View Source
const VAR_TIMESTAMP = 57362
View Source
const VAR_TYPE = 57357
View Source
const VAR_UUID = 57356

Variables

View Source
var Field_ValueType_name = map[int32]string{
	0: "STRING",
	1: "BYTES",
	2: "INTEGER",
	3: "DOUBLE",
	4: "BOOL",
}
View Source
var Field_ValueType_value = map[string]int32{
	"STRING":  0,
	"BYTES":   1,
	"INTEGER": 2,
	"DOUBLE":  3,
	"BOOL":    4,
}
View Source
var Header_HmacHashFunction_name = map[int32]string{
	0: "MD5",
	1: "SHA1",
}
View Source
var Header_HmacHashFunction_value = map[string]int32{
	"MD5":  0,
	"SHA1": 1,
}
View Source
var (

	// A mapping that returns a complex regular expression string for
	// a commonly matched portion rather than having to construct one.
	//
	// Currently HelperRegexSubs has the following keys upon startup that
	// may be used:
	//     TIMESTAMP  -  A complex regular expression string that matches
	//                   any of the Go time const layouts.
	HelperRegexSubs map[string]string
)

Functions

func ForgivingTimeParse

func ForgivingTimeParse(timeLayout, inputTime string, loc *time.Location) (
	parsedTime time.Time, err error)

Parse a time with the supplied timeLayout, falling back to all the basicTimeLayouts.

func NewInt64Field

func NewInt64Field(m *Message, name string, val int64, representation string)

Convenience function for creating a new int64 field on a message object.

func NewIntField

func NewIntField(m *Message, name string, val int, representation string) (err error)

Convenience function for creating a new integer field on a message object.

func NewStringField

func NewStringField(m *Message, name string, val string)

Convenience function for creating and setting a string field called "name" on a message object.

Types

type Field

type Field struct {
	Name             *string          `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
	ValueType        *Field_ValueType `protobuf:"varint,2,opt,name=value_type,enum=message.Field_ValueType,def=0" json:"value_type,omitempty"`
	Representation   *string          `protobuf:"bytes,3,opt,name=representation" json:"representation,omitempty"`
	ValueString      []string         `protobuf:"bytes,4,rep,name=value_string" json:"value_string,omitempty"`
	ValueBytes       [][]byte         `protobuf:"bytes,5,rep,name=value_bytes" json:"value_bytes,omitempty"`
	ValueInteger     []int64          `protobuf:"varint,6,rep,packed,name=value_integer" json:"value_integer,omitempty"`
	ValueDouble      []float64        `protobuf:"fixed64,7,rep,packed,name=value_double" json:"value_double,omitempty"`
	ValueBool        []bool           `protobuf:"varint,8,rep,packed,name=value_bool" json:"value_bool,omitempty"`
	XXX_unrecognized []byte           `json:"-"`
}

func CopyField

func CopyField(src *Field) *Field

Field copy constructor

func NewField

func NewField(name string, value interface{}, representation string) (f *Field, err error)

Field constructor

func NewFieldInit

func NewFieldInit(name string, valueType Field_ValueType, representation string) *Field

Field initializer sets up the key, value type, and format but does not actually add a value

func (*Field) AddValue

func (f *Field) AddValue(value interface{}) error

Creates an array of values in this field, of the same type, in the order they were added

func (*Field) GetName

func (m *Field) GetName() string

func (*Field) GetRepresentation

func (m *Field) GetRepresentation() string

func (*Field) GetValue

func (f *Field) GetValue() (value interface{})

Helper function that returns the appropriate value object.

func (*Field) GetValueBool

func (m *Field) GetValueBool() []bool

func (*Field) GetValueBytes

func (m *Field) GetValueBytes() [][]byte

func (*Field) GetValueDouble

func (m *Field) GetValueDouble() []float64

func (*Field) GetValueInteger

func (m *Field) GetValueInteger() []int64

func (*Field) GetValueString

func (m *Field) GetValueString() []string

func (*Field) GetValueType

func (m *Field) GetValueType() Field_ValueType

func (*Field) ProtoMessage

func (*Field) ProtoMessage()

func (*Field) Reset

func (m *Field) Reset()

func (*Field) String

func (m *Field) String() string

type Field_ValueType

type Field_ValueType int32
const (
	Field_STRING  Field_ValueType = 0
	Field_BYTES   Field_ValueType = 1
	Field_INTEGER Field_ValueType = 2
	Field_DOUBLE  Field_ValueType = 3
	Field_BOOL    Field_ValueType = 4
)
const Default_Field_ValueType Field_ValueType = Field_STRING

func (Field_ValueType) Enum

func (x Field_ValueType) Enum() *Field_ValueType

func (Field_ValueType) String

func (x Field_ValueType) String() string

func (*Field_ValueType) UnmarshalJSON

func (x *Field_ValueType) UnmarshalJSON(data []byte) error
type Header struct {
	MessageLength    *uint32                  `protobuf:"varint,1,req,name=message_length" json:"message_length,omitempty"`
	HmacHashFunction *Header_HmacHashFunction `` /* 126-byte string literal not displayed */
	HmacSigner       *string                  `protobuf:"bytes,4,opt,name=hmac_signer" json:"hmac_signer,omitempty"`
	HmacKeyVersion   *uint32                  `protobuf:"varint,5,opt,name=hmac_key_version" json:"hmac_key_version,omitempty"`
	Hmac             []byte                   `protobuf:"bytes,6,opt,name=hmac" json:"hmac,omitempty"`
	XXX_unrecognized []byte                   `json:"-"`
}

func (*Header) GetHmac

func (m *Header) GetHmac() []byte

func (*Header) GetHmacHashFunction

func (m *Header) GetHmacHashFunction() Header_HmacHashFunction

func (*Header) GetHmacKeyVersion

func (m *Header) GetHmacKeyVersion() uint32

func (*Header) GetHmacSigner

func (m *Header) GetHmacSigner() string

func (*Header) GetMessageLength

func (m *Header) GetMessageLength() uint32

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) Reset

func (m *Header) Reset()

func (*Header) SetHmac

func (h *Header) SetHmac(v []byte)

func (*Header) SetHmacHashFunction

func (h *Header) SetHmacHashFunction(v Header_HmacHashFunction)

func (*Header) SetHmacKeyVersion

func (h *Header) SetHmacKeyVersion(v uint32)

func (*Header) SetHmacSigner

func (h *Header) SetHmacSigner(v string)

func (*Header) SetMessageLength

func (h *Header) SetMessageLength(v uint32)

func (*Header) String

func (m *Header) String() string

type Header_HmacHashFunction

type Header_HmacHashFunction int32
const (
	Header_MD5  Header_HmacHashFunction = 0
	Header_SHA1 Header_HmacHashFunction = 1
)
const Default_Header_HmacHashFunction Header_HmacHashFunction = Header_MD5

func (Header_HmacHashFunction) Enum

func (Header_HmacHashFunction) String

func (x Header_HmacHashFunction) String() string

func (*Header_HmacHashFunction) UnmarshalJSON

func (x *Header_HmacHashFunction) UnmarshalJSON(data []byte) error

type MatcherSpecification

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

MatcherSpecification used by the message router to distribute messages

func CreateMatcherSpecification

func CreateMatcherSpecification(spec string) (*MatcherSpecification, error)

CreateMatcherSpecification compiles the spec string into a simple virtual machine for execution

func (*MatcherSpecification) Match

func (m *MatcherSpecification) Match(message *Message) bool

Match compares the message against the matcher spec and return the match result

func (*MatcherSpecification) String

func (m *MatcherSpecification) String() string

String outputs the spec as text

type MatcherSpecificationParser

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

func (*MatcherSpecificationParser) Error

func (m *MatcherSpecificationParser) Error(s string)

func (*MatcherSpecificationParser) Lex

func (m *MatcherSpecificationParser) Lex(yylval *yySymType) int

type Message

type Message struct {
	Uuid             []byte   `protobuf:"bytes,1,req,name=uuid" json:"uuid,omitempty"`
	Timestamp        *int64   `protobuf:"varint,2,req,name=timestamp" json:"timestamp,omitempty"`
	Type             *string  `protobuf:"bytes,3,opt,name=type" json:"type,omitempty"`
	Logger           *string  `protobuf:"bytes,4,opt,name=logger" json:"logger,omitempty"`
	Severity         *int32   `protobuf:"varint,5,opt,name=severity,def=7" json:"severity,omitempty"`
	Payload          *string  `protobuf:"bytes,6,opt,name=payload" json:"payload,omitempty"`
	EnvVersion       *string  `protobuf:"bytes,7,opt,name=env_version" json:"env_version,omitempty"`
	Pid              *int32   `protobuf:"varint,8,opt,name=pid" json:"pid,omitempty"`
	Hostname         *string  `protobuf:"bytes,9,opt,name=hostname" json:"hostname,omitempty"`
	Fields           []*Field `protobuf:"bytes,10,rep,name=fields" json:"fields,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func CopyMessage

func CopyMessage(src *Message) *Message

Message copy constructor

func (*Message) AddField

func (m *Message) AddField(f *Field)

Adds a Field (name/value) pair to the message

func (*Message) Copy

func (src *Message) Copy(dst *Message)

Message assignment operator

func (*Message) Equals

func (m *Message) Equals(other interface{}) bool

Test for message equality, for use in tests.

func (*Message) FindAllFields

func (m *Message) FindAllFields(name string) (all []*Field)

FindAllFields finds and returns all the fields with the specified name if not found a nil slice is returned

func (*Message) FindFirstField

func (m *Message) FindFirstField(name string) *Field

FindFirstField finds and returns the first field with the specified name if not found nil is returned

func (*Message) GetEnvVersion

func (m *Message) GetEnvVersion() string

func (*Message) GetFieldValue

func (m *Message) GetFieldValue(name string) (value interface{}, ok bool)

GetFieldValue helper function to simplify extracting single value fields

func (*Message) GetFields

func (m *Message) GetFields() []*Field

func (*Message) GetHostname

func (m *Message) GetHostname() string

func (*Message) GetLogger

func (m *Message) GetLogger() string

func (*Message) GetPayload

func (m *Message) GetPayload() string

func (*Message) GetPid

func (m *Message) GetPid() int32

func (*Message) GetSeverity

func (m *Message) GetSeverity() int32

func (*Message) GetTimestamp

func (m *Message) GetTimestamp() int64

func (*Message) GetType

func (m *Message) GetType() string

func (*Message) GetUuid

func (m *Message) GetUuid() []byte

func (*Message) GetUuidString

func (m *Message) GetUuidString() string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) SetEnvVersion

func (m *Message) SetEnvVersion(v string)

func (*Message) SetHostname

func (m *Message) SetHostname(v string)

func (*Message) SetLogger

func (m *Message) SetLogger(v string)

func (*Message) SetPayload

func (m *Message) SetPayload(v string)

func (*Message) SetPid

func (m *Message) SetPid(v int32)

func (*Message) SetSeverity

func (m *Message) SetSeverity(v int32)

func (*Message) SetTimestamp

func (m *Message) SetTimestamp(v int64)

func (*Message) SetType

func (m *Message) SetType(v string)

func (*Message) SetUuid

func (m *Message) SetUuid(v []byte)

func (*Message) String

func (m *Message) String() string

type MessageSigningConfig

type MessageSigningConfig struct {
	Name    string `toml:"name"`
	Hash    string `toml:"hmac_hash"`
	Key     string `toml:"hmac_key"`
	Version uint32 `toml:"version"`
}

type Statement

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

Jump to

Keyboard shortcuts

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