Documentation ¶
Index ¶
- Constants
- func GetChunk(b []byte) (string, error)
- func ValidatePingDigest(p *Ping, key, nonce []byte) error
- func ValidatePongDigest(p *Pong, key, nonce, salt []byte) error
- type AckMessage
- type ChunkEncoder
- type ChunkReader
- type Entry
- type EntryExt
- type EntryList
- func (z *EntryList) DecodeMsg(dc *msgp.Reader) (err error)
- func (z EntryList) EncodeMsg(en *msgp.Writer) (err error)
- func (el EntryList) Equal(e2 EntryList) bool
- func (z EntryList) MarshalMsg(b []byte) (o []byte, err error)
- func (el EntryList) MarshalPacked() ([]byte, error)
- func (z EntryList) Msgsize() (s int)
- func (z *EntryList) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (el *EntryList) UnmarshalPacked(bits []byte) ([]byte, error)
- type EventTime
- func (z *EventTime) DecodeMsg(dc *msgp.Reader) (err error)
- func (z EventTime) EncodeMsg(en *msgp.Writer) (err error)
- func (et *EventTime) ExtensionType() int8
- func (et *EventTime) Len() int
- func (et *EventTime) MarshalBinaryTo(b []byte) error
- func (z EventTime) MarshalMsg(b []byte) (o []byte, err error)
- func (z EventTime) Msgsize() (s int)
- func (et *EventTime) UnmarshalBinary(timeBytes []byte) error
- func (z *EventTime) UnmarshalMsg(bts []byte) (o []byte, err error)
- type ForwardMessage
- func (fm *ForwardMessage) Chunk() (string, error)
- func (fm *ForwardMessage) DecodeMsg(dc *msgp.Reader) error
- func (fm *ForwardMessage) EncodeMsg(dc *msgp.Writer) error
- func (fm *ForwardMessage) MarshalMsg(bits []byte) ([]byte, error)
- func (fm *ForwardMessage) Msgsize() (s int)
- func (fm *ForwardMessage) UnmarshalMsg(bits []byte) ([]byte, error)
- type GzipCompressor
- type Helo
- type HeloOpts
- type Message
- func (msg *Message) Chunk() (string, error)
- func (msg *Message) DecodeMsg(dc *msgp.Reader) error
- func (z *Message) EncodeMsg(en *msgp.Writer) (err error)
- func (z *Message) MarshalMsg(b []byte) (o []byte, err error)
- func (msg *Message) Msgsize() (s int)
- func (msg *Message) UnmarshalMsg(bits []byte) ([]byte, error)
- type MessageExt
- func (msg *MessageExt) Chunk() (string, error)
- func (msg *MessageExt) DecodeMsg(dc *msgp.Reader) error
- func (z *MessageExt) EncodeMsg(en *msgp.Writer) (err error)
- func (z *MessageExt) MarshalMsg(b []byte) (o []byte, err error)
- func (msg *MessageExt) Msgsize() (s int)
- func (msg *MessageExt) UnmarshalMsg(bits []byte) ([]byte, error)
- type MessageOptions
- func (z *MessageOptions) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *MessageOptions) EncodeMsg(en *msgp.Writer) (err error)
- func (z *MessageOptions) MarshalMsg(b []byte) (o []byte, err error)
- func (z *MessageOptions) Msgsize() (s int)
- func (z *MessageOptions) UnmarshalMsg(bts []byte) (o []byte, err error)
- type PackedForwardMessage
- func NewCompressedPackedForwardMessage(tag string, entries []EntryExt) (*PackedForwardMessage, error)
- func NewCompressedPackedForwardMessageFromBytes(tag string, entries []byte) (*PackedForwardMessage, error)
- func NewPackedForwardMessage(tag string, entries EntryList) (*PackedForwardMessage, error)
- func NewPackedForwardMessageFromBytes(tag string, entries []byte) *PackedForwardMessage
- func (msg *PackedForwardMessage) Chunk() (string, error)
- func (msg *PackedForwardMessage) DecodeMsg(dc *msgp.Reader) error
- func (z *PackedForwardMessage) EncodeMsg(en *msgp.Writer) (err error)
- func (z *PackedForwardMessage) MarshalMsg(b []byte) (o []byte, err error)
- func (msg *PackedForwardMessage) Msgsize() (s int)
- func (msg *PackedForwardMessage) UnmarshalMsg(bits []byte) ([]byte, error)
- type Ping
- type Pong
- type RawMessage
- func (rm RawMessage) Chunk() (string, error)
- func (z *RawMessage) DecodeMsg(dc *msgp.Reader) (err error)
- func (rm RawMessage) EncodeMsg(w *msgp.Writer) error
- func (z RawMessage) MarshalMsg(b []byte) (o []byte, err error)
- func (z RawMessage) Msgsize() (s int)
- func (z *RawMessage) UnmarshalMsg(bts []byte) (o []byte, err error)
Constants ¶
const ( MsgTypeHelo = "HELO" MsgTypePing = "PING" MsgTypePong = "PONG" )
const ( OptSize string = "size" OptChunk string = "chunk" OptCompressed string = "compressed" OptValGZIP string = "gzip" )
Variables ¶
This section is empty.
Functions ¶
func GetChunk ¶
GetChunk searches a marshaled message for the "chunk" option value and returns it. The chunk can be used for ack checks without the overhead of unmarshalling. GetChunk returns an error if no value is found.
func ValidatePingDigest ¶
ValidatePingDigest validates that the digest contained in the PING message is valid for the client hostname (as contained in the PING). Returns a non-nil error if validation fails, nil otherwise.
func ValidatePongDigest ¶
ValidatePongDigest validates that the digest contained in the PONG message is valid for the server hostname (as contained in the PONG). Returns a non-nil error if validation fails, nil otherwise.
Types ¶
type AckMessage ¶
type AckMessage struct {
Ack string `msg:"ack"`
}
func (*AckMessage) DecodeMsg ¶
func (z *AckMessage) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (AckMessage) EncodeMsg ¶
func (z AckMessage) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (AckMessage) MarshalMsg ¶
func (z AckMessage) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (AckMessage) Msgsize ¶
func (z AckMessage) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*AckMessage) UnmarshalMsg ¶
func (z *AckMessage) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type ChunkEncoder ¶
ChunkEncoder wraps methods to encode a message and generate "chunk" IDs for use with Fluent's chunk-ack protocol. See https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1#response for more information.
type ChunkReader ¶
func (*ChunkReader) Reset ¶
func (cr *ChunkReader) Reset(b []byte)
type Entry ¶
type Entry struct { // Timestamp can contain the timestamp in either seconds or nanoseconds Timestamp int64 // Record is the actual event record. Record interface{} }
EntryExt is the basic representation of an individual event. The timestamp is an int64 representing seconds since the epoch (UTC). The initial creator of the entry is responsible for converting to UTC.
func (Entry) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type EntryExt ¶
type EntryExt struct { // Timestamp can contain the timestamp in either seconds or nanoseconds Timestamp EventTime `msg:"eventTime,extension"` // Record is the actual event record. The object must be a map or // struct. Objects that implement the msgp.Encodable interface will // be the most performant. Record interface{} }
EntryExt is the basic representation of an individual event, but using the msgpack extension format for the timestamp.
func (EntryExt) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type EntryList ¶
type EntryList []EntryExt
func (EntryList) Equal ¶
Equal compares two EntryList objects and returns true if they have exactly the same elements, false otherwise.
func (EntryList) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (EntryList) MarshalPacked ¶
func (EntryList) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*EntryList) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
type EventTime ¶
EventTime is the fluent-forward representation of a timestamp
func EventTimeNow ¶
func EventTimeNow() EventTime
EventTimeNow returns an EventTime set to time.Now().UTC().
func (*EventTime) ExtensionType ¶
func (*EventTime) MarshalBinaryTo ¶
MarshalBinaryTo implements the Extension interface for marshaling an EventTime into a byte slice.
func (EventTime) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (EventTime) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*EventTime) UnmarshalBinary ¶
UnmarshalBinary implements the Extension interface for unmarshaling into an EventTime object.
type ForwardMessage ¶
type ForwardMessage struct { // Tag is a dot-delimted string used to categorize events Tag string // Entries is the set of event objects to be carried in this message Entries EntryList // Options - used to control server behavior. Same as above, may need to // switch to interface{} or similar at some point. Options *MessageOptions }
ForwardMessage is used in Forward mode to send multiple events in a single msgpack array within a single request.
func NewForwardMessage ¶
func NewForwardMessage( tag string, entries EntryList, ) *ForwardMessage
NewForwardMessage creates a ForwardMessage from the supplied tag, EntryList, and MessageOptions. this function will set Options.Size to the length of the entry list.
func (*ForwardMessage) Chunk ¶
func (fm *ForwardMessage) Chunk() (string, error)
func (*ForwardMessage) MarshalMsg ¶
func (fm *ForwardMessage) MarshalMsg(bits []byte) ([]byte, error)
func (*ForwardMessage) Msgsize ¶
func (fm *ForwardMessage) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*ForwardMessage) UnmarshalMsg ¶
func (fm *ForwardMessage) UnmarshalMsg(bits []byte) ([]byte, error)
type GzipCompressor ¶
func (*GzipCompressor) Bytes ¶
func (mc *GzipCompressor) Bytes() []byte
Bytes returns the gzip-compressed byte stream.
func (*GzipCompressor) Reset ¶
func (mc *GzipCompressor) Reset()
Reset resets the buffer to be empty, but it retains the underlying storage for use by future writes.
func (*GzipCompressor) Write ¶
func (mc *GzipCompressor) Write(bits []byte) error
Write writes to the compression stream.
type Helo ¶
Helo is the initial handshake message, sent by the server and received by the client. Client will respond with a Ping.
func NewHelo ¶
NewHelo returns a Helo message with the specified options. if opts is nil, then a nonce is generated, auth is left empty, and keepalive is true.
func (*Helo) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type HeloOpts ¶
type HeloOpts struct { Nonce []byte `msg:"nonce"` Auth []byte `msg:"auth"` Keepalive bool `msg:"keepalive"` }
func (*HeloOpts) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type Message ¶
type Message struct { // Tag is a dot-delimited string used to categorize events Tag string Timestamp int64 Record interface{} // Options - used to control server behavior. Options *MessageOptions }
Message is used to send a single event at a time
func NewMessage ¶
NewMessage creates a Message from the supplied tag and record. The record object must be a map or struct. Objects that implement the msgp.Encodable interface will be the most performant. Timestamp is set to time.Now().UTC() and marshaled with second precision.
func (*Message) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type MessageExt ¶
type MessageExt struct { Tag string Timestamp EventTime `msg:"eventTime,extension"` Record interface{} Options *MessageOptions }
MessageExt
func NewMessageExt ¶
func NewMessageExt( tag string, record interface{}, ) *MessageExt
NewMessageExt creates a MessageExt from the supplied tag and record. The record object must be a map or struct. Objects that implement the msgp.Encodable interface will be the most performant. Timestamp is set to time.Now().UTC() and marshaled with subsecond precision.
func (*MessageExt) Chunk ¶
func (msg *MessageExt) Chunk() (string, error)
func (*MessageExt) EncodeMsg ¶
func (z *MessageExt) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*MessageExt) MarshalMsg ¶
func (z *MessageExt) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*MessageExt) Msgsize ¶
func (msg *MessageExt) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*MessageExt) UnmarshalMsg ¶
func (msg *MessageExt) UnmarshalMsg(bits []byte) ([]byte, error)
type MessageOptions ¶
type MessageOptions struct { Size *int `msg:"size,omitempty"` Chunk string `msg:"chunk,omitempty"` Compressed string `msg:"compressed,omitempty"` }
func (*MessageOptions) DecodeMsg ¶
func (z *MessageOptions) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*MessageOptions) EncodeMsg ¶
func (z *MessageOptions) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*MessageOptions) MarshalMsg ¶
func (z *MessageOptions) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*MessageOptions) Msgsize ¶
func (z *MessageOptions) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*MessageOptions) UnmarshalMsg ¶
func (z *MessageOptions) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type PackedForwardMessage ¶
type PackedForwardMessage struct { // Tag is a dot-delimited string used to categorize events Tag string // EventStream is the set of events (entries in Fluent-speak) serialized // into a msgpack byte stream EventStream []byte // Options - used to control server behavior. Same as above, may need to // switch to interface{} or similar at some point. Options *MessageOptions }
PackedForwardMessage is just like ForwardMessage, except that the events are carried as a msgpack binary stream
func NewCompressedPackedForwardMessage ¶
func NewCompressedPackedForwardMessage( tag string, entries []EntryExt, ) (*PackedForwardMessage, error)
NewCompressedPackedForwardMessage returns a PackedForwardMessage with a gzip-compressed byte stream.
func NewCompressedPackedForwardMessageFromBytes ¶
func NewCompressedPackedForwardMessageFromBytes( tag string, entries []byte, ) (*PackedForwardMessage, error)
NewCompressedPackedForwardMessageFromBytes returns a PackedForwardMessage with a gzip-compressed byte stream.
func NewPackedForwardMessage ¶
func NewPackedForwardMessage( tag string, entries EntryList, ) (*PackedForwardMessage, error)
NewPackedForwardMessage creates a PackedForwardMessage from the supplied tag, EntryList, and MessageOptions. Regardless of the options supplied, this function will set Options.Size to the length of the entry list.
func NewPackedForwardMessageFromBytes ¶
func NewPackedForwardMessageFromBytes( tag string, entries []byte, ) *PackedForwardMessage
NewPackedForwardMessageFromBytes creates a PackedForwardMessage from the supplied tag, bytes, and MessageOptions. This function does not set Options.Size to the length of the entry list.
func (*PackedForwardMessage) Chunk ¶
func (msg *PackedForwardMessage) Chunk() (string, error)
func (*PackedForwardMessage) DecodeMsg ¶
func (msg *PackedForwardMessage) DecodeMsg(dc *msgp.Reader) error
func (*PackedForwardMessage) EncodeMsg ¶
func (z *PackedForwardMessage) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*PackedForwardMessage) MarshalMsg ¶
func (z *PackedForwardMessage) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*PackedForwardMessage) Msgsize ¶
func (msg *PackedForwardMessage) Msgsize() (s int)
func (*PackedForwardMessage) UnmarshalMsg ¶
func (msg *PackedForwardMessage) UnmarshalMsg(bits []byte) ([]byte, error)
type Ping ¶
Ping is the response message sent by the client after receiving a Helo from the server. Server will respond with a Pong.
func NewPing ¶
NewPing returns a PING message. The digest is computed from the hostname, key, salt, and nonce using SHA512.
func NewPingWithAuth ¶
func NewPingWithAuth(hostname string, sharedKey, salt, nonce []byte, username, password string) (*Ping, error)
NewPingWithAuth returns a PING message containing the username and password to be used for authentication. The digest is computed from the hostname, key, salt, and nonce using SHA512.
func (*Ping) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type Pong ¶
Pong is the response message sent by the server after receiving a Ping from the client. A Pong concludes the handshake.
func NewPong ¶
func NewPong(authResult bool, reason string, hostname string, sharedKey []byte, helo *Helo, ping *Ping) (*Pong, error)
NewPong returns a PONG message. AuthResult indicates whether the credentials presented by the client were accepted and therefore whether the client can continue using the connection, switching from handshake mode to sending events. As with the PING, the digest is computed from the hostname, key, salt, and nonce using SHA512. Server implementations must use the nonce created for the initial Helo and the salt sent by the client in the Ping.
func (*Pong) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type RawMessage ¶
type RawMessage []byte
RawMessage is a ChunkEncoder wrapper for []byte.
func (RawMessage) Chunk ¶
func (rm RawMessage) Chunk() (string, error)
Chunk searches the message for the chunk ID. In the case of RawMessage, Chunk is read-only. It returns an error if the chunk is not found.
func (*RawMessage) DecodeMsg ¶
func (z *RawMessage) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (RawMessage) MarshalMsg ¶
func (z RawMessage) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (RawMessage) Msgsize ¶
func (z RawMessage) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*RawMessage) UnmarshalMsg ¶
func (z *RawMessage) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler