event

package
v0.0.0-...-bb87f3e Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2017 License: BSD-3-Clause Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const EventIDByteSz = 8
View Source
const EventIDMax = EventID(math.MaxUint64)
View Source
const FlatEventValueBaseByteSz = ObjectHeaderByteSz
View Source
const FullEventHeaderByteSz = ObjectHeaderByteSz + TopicEventHeaderByteSz
View Source
const ObjectHeaderByteSz = 8
View Source
const TopicEventEventKeyByteSz = 16
View Source
const TopicEventHeaderByteSz = TopicIDByteSz + EventIDByteSz
View Source
const TopicIDByteSz = 8
View Source
const TopicIDMax = TopicID(math.MaxInt64)

Variables

This section is empty.

Functions

func EventIDsToFixedKeys

func EventIDsToFixedKeys(eventIDs []EventID) (keys [][]byte)

Types

type BaseEventData

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

BaseEventData holds a FullEventHeader and the events data separately.

func BaseEventDataCreate

func BaseEventDataCreate(topicID TopicID, eventID EventID, objectHeader ObjectHeader, data []byte) (self BaseEventData)

func (*BaseEventData) Data

func (self *BaseEventData) Data() []byte

func (*BaseEventData) EventID

func (self *BaseEventData) EventID() (eventID EventID)

func (*BaseEventData) FullEventHeader

func (self *BaseEventData) FullEventHeader() FullEventHeader

func (*BaseEventData) ObjectHeader

func (self *BaseEventData) ObjectHeader() ObjectHeader

func (*BaseEventData) SetEventID

func (self *BaseEventData) SetEventID(eventID EventID)

func (*BaseEventData) SetObjectHeader

func (self *BaseEventData) SetObjectHeader(objectHeader ObjectHeader)

func (*BaseEventData) SetTopicID

func (self *BaseEventData) SetTopicID(topicID TopicID)

func (*BaseEventData) TopicID

func (self *BaseEventData) TopicID() (topicID TopicID)

type BaseEventDataRing

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

BaseEventDataRing is a ring of EventData

func BaseEventDataRingCreate

func BaseEventDataRingCreate(cap int) (self BaseEventDataRing)

func (*BaseEventDataRing) At

func (self *BaseEventDataRing) At() *BaseEventData

func (*BaseEventDataRing) Cnt

func (self *BaseEventDataRing) Cnt() uint64

Cnt returns the cnt of the elements in the ring.

func (*BaseEventDataRing) Empty

func (self *BaseEventDataRing) Empty() bool

Empty returns whether the ring is empty.

func (*BaseEventDataRing) Free

func (self *BaseEventDataRing) Free() uint64

Free returns the freespace in the ring.

func (*BaseEventDataRing) Get

func (self *BaseEventDataRing) Get(ed *BaseEventData) (hasEvent bool)

Get returns the element at the current readPos if self.Empty() == false

func (*BaseEventDataRing) IncReadPos

func (self *BaseEventDataRing) IncReadPos(cnt uint64)

IncReadPos pops cnt events. (adds cnt to self.readPos) panics if self.Cnt() < cnt

func (*BaseEventDataRing) Offer

func (self *BaseEventDataRing) Offer(data BaseEventData) (isIn bool)

Offer puts data in the ring at current writePos if self.Free() > 0 and increses the writePos.

func (*BaseEventDataRing) Pop

func (self *BaseEventDataRing) Pop(ed *BaseEventData) (hasEvent bool)

Pop returns the element at the current readPos if self.Empty() == false and increases the readPos.

func (*BaseEventDataRing) Reset

func (self *BaseEventDataRing) Reset()

Reset sets writePos and readPos to zero and sets all element of its datas to nil.

type Event

type Event interface {
	EventID() EventID
	Time() int64
	EventType() uint64
}

type EventID

type EventID uint64

EventID is used to identify a unique event of a topic.

func EventIDFromBuf

func EventIDFromBuf(data []byte) EventID

func (*EventID) AddTimeUsec

func (self *EventID) AddTimeUsec(val uint64)

func (*EventID) Atomic

func (self *EventID) Atomic(tid *uint64) uint64

func (*EventID) AtomicAddTimeUsec

func (self *EventID) AtomicAddTimeUsec(val uint64)

func (*EventID) AtomicSet

func (self *EventID) AtomicSet(val uint64)

func (*EventID) AtomicSetSeq

func (self *EventID) AtomicSetSeq(val uint64)

func (*EventID) AtomicSetTimeUsec

func (self *EventID) AtomicSetTimeUsec(val uint64)

func (*EventID) FromSlice

func (self *EventID) FromSlice(data []byte)

FromSlice copies the data from data to EventID.

func (*EventID) Next

func (self *EventID) Next(timeMicros uint64)

func (*EventID) Seq

func (self *EventID) Seq() uint64

func (*EventID) SetSeq

func (self *EventID) SetSeq(val uint64)

func (*EventID) SetSeqNext

func (self *EventID) SetSeqNext()

func (*EventID) SetTimeUsec

func (self *EventID) SetTimeUsec(val uint64)

func (*EventID) SetTimeUsecMax

func (self *EventID) SetTimeUsecMax()

func (*EventID) String

func (self *EventID) String() string

func (EventID) TimeUsec

func (self EventID) TimeUsec() uint64

type EventIDKey

type EventIDKey [EventIDByteSz]byte

func EventIDKeyFromEventID

func EventIDKeyFromEventID(eid EventID) (eik EventIDKey)

func (*EventIDKey) EventID

func (self *EventIDKey) EventID() EventID

func (*EventIDKey) SetEventID

func (self *EventIDKey) SetEventID(eid EventID)

type FlatEventValue

type FlatEventValue []byte

FlatEventValue holds a single event prefixed by its ObjectHeader. It can be used to send and receive a single event

func FlatEventValueCreate

func FlatEventValueCreate(cap uint64) FlatEventValue

FlatEventValueCreate returns a new FlatEventValue with the byte capacity of ObjectHeaderByteSz + cap.

func FlatEventValueFromSlice

func FlatEventValueFromSlice(data []byte) FlatEventValue

func FlatEventValueFromSliceWithPrefix

func FlatEventValueFromSliceWithPrefix(data []byte, dataPrefixSize uint64) FlatEventValue

FlatEventValueFromSliceWithPrefix can be used to create a larger object header dataPrefixSize must be calculated without ObjectHeaderByteSz ObjectHeader.ExtensionByteSize must reflect dataPrefixSize

func (FlatEventValue) CopyData

func (self FlatEventValue) CopyData(src []byte)

CopyData just copies data to the Data() of this FlatEventValue, thats all

func (FlatEventValue) Data

func (self FlatEventValue) Data() []byte

Data returns the data without ObjectHeader.

func (FlatEventValue) ObjectHeader

func (self FlatEventValue) ObjectHeader() ObjectHeader

func (FlatEventValue) SetObjectHeader

func (self FlatEventValue) SetObjectHeader(eh ObjectHeader)

type FlatEventValueBuffer

type FlatEventValueBuffer struct {
	FixedPrefixSizeBuffer
}

func FlatEventValueBufferCreate

func FlatEventValueBufferCreate(cnt uint64) FlatEventValueBuffer

type FnBaseEventDataToTopicEvent

type FnBaseEventDataToTopicEvent func(bed *BaseEventData) (te TopicEvent)

type FnDataToTopicEvent

type FnDataToTopicEvent func(data []byte) (te TopicEvent)

type FnDataToTopicEvents

type FnDataToTopicEvents func(data []byte) (tes []TopicEvent)

type FullDataTopicEvent

type FullDataTopicEvent interface {
	TopicEvent
	Data() []byte
}

type FullEventHeader

type FullEventHeader struct {
	ObjectHeader     ObjectHeader
	TopicEventHeader TopicEventHeader
}

FullEventHeader. The order of fields matters here, for example to change from Flat- to FullEventValue.

type FullEventHeaderKey

type FullEventHeaderKey [FullEventHeaderByteSz]byte

func FullEventHeaderToKey

func FullEventHeaderToKey(teh FullEventHeader) FullEventHeaderKey

func (*FullEventHeaderKey) ObjectHeader

func (self *FullEventHeaderKey) ObjectHeader() ObjectHeader

func (*FullEventHeaderKey) SetObjectHeader

func (self *FullEventHeaderKey) SetObjectHeader(oh ObjectHeader)

func (*FullEventHeaderKey) SetTopicEventHeader

func (self *FullEventHeaderKey) SetTopicEventHeader(tid TopicEventHeader)

func (*FullEventHeaderKey) TopicEventHeader

func (self *FullEventHeaderKey) TopicEventHeader() TopicEventHeader

type FullEventValue

type FullEventValue []byte

FlatEventValue holds a single event prefixed by its FullEventHeader. It can be used to send and receive a single event

func FullEventValueByFlatEventValue

func FullEventValueByFlatEventValue(fev FlatEventValue) FullEventValue

func FullEventValueCreate

func FullEventValueCreate(cap uint64) FullEventValue

func FullEventValueFromBaseEventData

func FullEventValueFromBaseEventData(bed *BaseEventData) FullEventValue

func FullEventValueFromSlice

func FullEventValueFromSlice(data []byte) FullEventValue

func (FullEventValue) Data

func (self FullEventValue) Data() []byte

func (FullEventValue) FullEventHeader

func (self FullEventValue) FullEventHeader() FullEventHeader

func (FullEventValue) SetFullEventHeader

func (self FullEventValue) SetFullEventHeader(eh FullEventHeader)

type FullEventValueBuffer

type FullEventValueBuffer struct {
	FixedPrefixSizeBuffer
}

func FullEventValueBufferCreateFixed

func FullEventValueBufferCreateFixed(cnt uint64) FullEventValueBuffer

func FullEventValueBufferCreateFixedWithValueSize

func FullEventValueBufferCreateFixedWithValueSize(valueSize, cnt uint64) FullEventValueBuffer

valueSize is the size of the values

type ObjectHeader

type ObjectHeader struct {
	ObjectDataType     uint16
	UnderlyingDataType uint16
	Format             uint8
	Format2            uint8
	// ExtensionByteSize defines the bytes after this header
	// which belong to an implementation specific header
	ExtensionByteSize uint16
}

ObjectHeader holds description of the type of an object or event.

func ObjectHeaderFromUint64

func ObjectHeaderFromUint64(val uint64) ObjectHeader

type TopicEvent

type TopicEvent interface {
	Event
	TopicID() TopicID
	CopyTo(other TopicEvent)
}

type TopicEventData

type TopicEventData interface {
	TopicID() TopicID
	EventID() EventID
	ObjectHeader() ObjectHeader
	Data() []byte
}

type TopicEventEventKey

type TopicEventEventKey struct {
	TopicID TopicID
	EventID EventID
}

TopicEventEventKey defines a 16 byte unique event identification. first 8 byte is TopicID, second 8 byte is EventID

func TopicEventEventKeyMax

func TopicEventEventKeyMax(topicID TopicID) (self TopicEventEventKey)

TopicEventEventKeyMax return a TopicEventEventKey for topicID with a maximum EventID.

func (*TopicEventEventKey) AsSlice

func (self *TopicEventEventKey) AsSlice() (data []byte)

AsSlice returns the TopicEventEventKey as a byte slice but unsafe!

func (*TopicEventEventKey) FromSlice

func (self *TopicEventEventKey) FromSlice(data []byte)

FromSlice copies the data from data to TopicEventEventKey.

func (*TopicEventEventKey) Marshal

func (self *TopicEventEventKey) Marshal() (data []byte, err error)

Marshal implements the marshaler interface.

func (*TopicEventEventKey) MarshalTo

func (self *TopicEventEventKey) MarshalTo(data []byte) (err error)

MarshalTo implements the marshaler interface.

func (*TopicEventEventKey) Size

func (self *TopicEventEventKey) Size() int

Size implements the marshaler interface.

func (*TopicEventEventKey) Slice

func (self *TopicEventEventKey) Slice() (data []byte)

Slice returns the TopicEventEventKey as a freshly allocated byte slice.

func (*TopicEventEventKey) Unmarshal

func (self *TopicEventEventKey) Unmarshal(data []byte) (err error)

Unmarshal implements the unmarshaler interface.

type TopicEventHeader

type TopicEventHeader struct {
	TopicID TopicID
	EventID EventID
}

TopicEventHeader holds the TopicID and the EventID of an event.

func TopicEventHeaderFromBuf

func TopicEventHeaderFromBuf(data []byte) TopicEventHeader

func (*TopicEventHeader) AsSlice

func (self *TopicEventHeader) AsSlice() []byte

func (*TopicEventHeader) Slice

func (self *TopicEventHeader) Slice() []byte

type TopicID

type TopicID uint64

TopicID is used to identify a unique topic. It contains a ContextType(), Time() in ms and a sequence Seq()

func TopicIDCreate

func TopicIDCreate(contextType uint8, contextSubType uint16, seq uint64) (topicID TopicID)

func (*TopicID) AsSlice

func (self *TopicID) AsSlice() []byte

func (*TopicID) Atomic

func (self *TopicID) Atomic() TopicID

func (*TopicID) AtomicNext

func (self *TopicID) AtomicNext() (cur, next TopicID)

func (*TopicID) AtomicSet

func (self *TopicID) AtomicSet(val TopicID)

func (*TopicID) AtomicSetSeq

func (self *TopicID) AtomicSetSeq(val uint64)

func (*TopicID) ContextSubType

func (self *TopicID) ContextSubType() uint64

func (*TopicID) ContextType

func (self *TopicID) ContextType() uint64

func (*TopicID) FromSlice

func (self *TopicID) FromSlice(data []byte)

FromSlice copies the data from data to TopicID.

func (*TopicID) Next

func (self *TopicID) Next()

func (*TopicID) Seq

func (self *TopicID) Seq() uint64

func (*TopicID) SetContextSubType

func (self *TopicID) SetContextSubType(val uint64)

func (*TopicID) SetContextType

func (self *TopicID) SetContextType(val uint64)

func (*TopicID) SetSeq

func (self *TopicID) SetSeq(val uint64)

func (*TopicID) SetSeqNext

func (self *TopicID) SetSeqNext()

func (*TopicID) String

func (self *TopicID) String() string

Jump to

Keyboard shortcuts

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