model

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer struct {
	// A Logger instance for debugging.  No logging is done if nil.
	Logger log.Logger
	// Handler receives events derived from the conversation.
	Handler EventHandler
	// ClientReader exposes data sent by the client to the server.
	ClientReader ConsumerSource
	// ServerReader exposes data send by the server to the client.
	ServerReader ConsumerSource
	// contains filtered or unexported fields
}

Consumer is a generic reader of a datastore conversation.

func (*Consumer) AddEvent

func (c *Consumer) AddEvent(evt Event)

func (*Consumer) FlushEvents

func (c *Consumer) FlushEvents()

type ConsumerSource

type ConsumerSource interface {
	Reader
	io.Closer
	tcpassembly.Stream
}

ConsumerSource buffers tcpassembly.Stream data and exposes it as a closeable Reader.

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 EventHandler

type EventHandler func(evts []Event)

EventHandler consumes a batch of events.

type EventType

type EventType int

EventType described what sort of event has occurred.

const (
	// EventUnknown is an unhandled event.
	EventUnknown EventType = iota
	// EventGetHit is a successful data retrieval that returned data.
	EventGetHit
	// EventGetMiss is a data retrieval that did not result in data.
	EventGetMiss
)

type Reader

type Reader interface {
	io.Reader

	// 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)

	// 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)
}

Reader represents a subset of the bufio.Reader interface.

Jump to

Keyboard shortcuts

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