Documentation
¶
Index ¶
- Constants
- type ClientStream
- type Consumer
- type ConsumerSource
- type DummySource
- func (s *DummySource) Close() error
- func (s *DummySource) Discard(n int) (discarded int, err error)
- func (s *DummySource) IndexAny(chars string) (int, error)
- func (s *DummySource) PeekN(n int) ([]byte, error)
- func (s *DummySource) Read(p []byte) (int, error)
- func (s *DummySource) ReadLine() ([]byte, error)
- func (s *DummySource) ReadN(n int) ([]byte, error)
- func (s *DummySource) Reassembled(rs []tcpassembly.Reassembly)
- func (s *DummySource) ReassemblyComplete()
- func (s *DummySource) Reset()
- func (s *DummySource) Truncate()
- type Event
- type EventFieldMask
- type EventHandler
- type EventType
- type Fsm
- type ProtocolType
- type Reader
- type ServerStream
Constants ¶
const ( // IntFields is a mask identifying the set of fields that can be viewed as integers, // and are viable targets for aggregation. IntFields = FieldSize )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientStream ¶ added in v1.5.0
type ClientStream Consumer
ClientStream is a view on a Consumer that consumes tcpassembly data from the client
func (*ClientStream) Reassembled ¶ added in v1.5.0
func (cs *ClientStream) Reassembled(rs []tcpassembly.Reassembly)
func (*ClientStream) ReassemblyComplete ¶ added in v1.5.0
func (cs *ClientStream) ReassemblyComplete()
type Consumer ¶
type Consumer struct { // Handler receives events derived from the conversation. Handler EventHandler // ClientReader exposes data sent by the client to the server. ClientReader *reader.Reader // ServerReader exposes data send by the server to the client. ServerReader *reader.Reader Fsm Fsm // contains filtered or unexported fields }
Consumer is a generic reader of a datastore conversation.
func New ¶ added in v1.5.0
func New(handler EventHandler, fsm Fsm) *Consumer
func (*Consumer) ClientStream ¶ added in v1.5.0
func (c *Consumer) ClientStream() tcpassembly.Stream
func (*Consumer) FlushEvents ¶
func (c *Consumer) FlushEvents()
func (*Consumer) ServerStream ¶ added in v1.5.0
func (c *Consumer) ServerStream() tcpassembly.Stream
type ConsumerSource ¶
type ConsumerSource interface { Reader io.Closer tcpassembly.Stream }
ConsumerSource buffers tcpassembly.Stream data and exposes it as a closeable Reader.
type DummySource ¶ added in v1.5.0
type DummySource struct{}
func (*DummySource) Close ¶ added in v1.5.0
func (s *DummySource) Close() error
func (*DummySource) Discard ¶ added in v1.5.0
func (s *DummySource) Discard(n int) (discarded int, err error)
func (*DummySource) IndexAny ¶ added in v1.5.0
func (s *DummySource) IndexAny(chars string) (int, error)
func (*DummySource) ReadLine ¶ added in v1.5.0
func (s *DummySource) ReadLine() ([]byte, error)
func (*DummySource) Reassembled ¶ added in v1.5.0
func (s *DummySource) Reassembled(rs []tcpassembly.Reassembly)
func (*DummySource) ReassemblyComplete ¶ added in v1.5.0
func (s *DummySource) ReassemblyComplete()
func (*DummySource) Reset ¶ added in v1.5.0
func (s *DummySource) Reset()
func (*DummySource) Truncate ¶ added in v1.5.0
func (s *DummySource) Truncate()
type Event ¶
type Event struct { // Type of the event. Type EventType // Datastore key affected by this event. Key string // Size of the datastore value affected by this event. Size int }
Event is a single event in a datastore conversation
type EventFieldMask ¶ added in v1.5.0
type EventFieldMask int
EventFieldMask efficiently identifies a field or set of fields in an Event. Each value is a power-of-2, and can be OR-ed together to express a set.
const ( // FieldNone is a mask representing the empty set of Event fields. FieldNone EventFieldMask = 0 FieldKey EventFieldMask = 1 << iota FieldSize // FieldEndOfFields is a dummy value to use as the endpoint of an iteration. FieldEndOfFields )
type Fsm ¶ added in v1.5.0
type Fsm interface { SetConsumer(consumer *Consumer) Run() }
Fsm is a finite-state machine that parses network traffic from a Consumer and produces events to that Consumer.
type ProtocolType ¶ added in v1.5.0
type ProtocolType uint8
const ( ProtocolUnknown ProtocolType = iota ProtocolInfer ProtocolMemcacheText ProtocolRedis )
func GetProtocolType ¶ added in v1.5.0
func GetProtocolType(protocol string) ProtocolType
type Reader ¶
type Reader interface { // Discard skips the next n bytes, returning the number of bytes discarded. // If Discard skips fewer than n bytes, it also returns an error. Discard(n int) (discarded int, err error) // ReadN returns the next n bytes. // // If EOF is encountered before reading n bytes, the available bytes are returned // along with ErrUnexpectedEOF. // // The returned buffer is only valid until the next call to ReadN or ReadLine. ReadN(n int) ([]byte, error) // IndexAny returns the result of bytes.IndexAny invoked on the available buffer. // If the delimiters are not found and the stream is at its end, returns io.UnexpectedEOF. IndexAny(chars string) (int, error) // PeekN returns the next n bytes, not advancing the read cursor. // // If EOF is encountered before reading n bytes, the available bytes are returned // along with ErrUnexpectedEOF. // // The returned buffer is only valid until the next call to ReadN or ReadLine. PeekN(n int) ([]byte, error) // ReadLine returns a single line, not including the end-of-line bytes. // The returned buffer is only valid until the next call to ReadN or ReadLine. // ReadLine either returns a non-nil line or it returns an error, never both. // // The text returned from ReadLine does not include the line end ("\r\n" or "\n"). // No indication or error is given if the input ends without a final line end. ReadLine() ([]byte, error) // Reset discards all state, preparing the Reader to receive data from a new connection. Reset() // Truncate discards all buffered data from the reader, leaving other state intact. Truncate() }
Reader represents a subset of the bufio.Reader interface.
type ServerStream ¶ added in v1.5.0
type ServerStream Consumer
ServerStream is a view on a Consumer that consumes tcpassembly data from the server
func (*ServerStream) Reassembled ¶ added in v1.5.0
func (ss *ServerStream) Reassembled(rs []tcpassembly.Reassembly)
func (*ServerStream) ReassemblyComplete ¶ added in v1.5.0
func (ss *ServerStream) ReassemblyComplete()