entry

package
v3.8.31 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: BSD-2-Clause, BSD-2-Clause, BSD-2-Clause Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultTagId  EntryTag = 0
	GravwellTagId EntryTag = 0xFFFF

	MaxDataSize   uint32 = 0x3FFFFFFF
	MaxSliceCount uint32 = 0x3FFFFFFF
)
View Source
const (
	/* 34 = 4 + 8 + 8 + 2 + 16

	 */
	ENTRY_HEADER_SIZE int = 34
	SRC_SIZE          int = 16
	IPV4_SRC_SIZE     int = 4
)
View Source
const (
	MaxEvNameLength = 1024                        // absolutely bonkers for a name, but constants are scary
	MaxEvDataLength = (63*1024 - evHeaderLen - 1) // are you attaching a NOVEL?
	MaxEvSize       = 0xFFFF                      // this so we can fit the EV header which contains a uint16 length

)
View Source
const (
	EVBlockHeaderLen = 8
	MaxEvBlockCount  = 0xffff           //bonkers, but we need to be safe
	MaxEvBlockSize   = 1024 * 1024 * 32 //not too lean, but let's remove opportunity for crazy memory pressure

)
View Source
const (
	EntryBlockHeaderSize = 4 + 4 + 8
)
View Source
const (
	TS_SIZE int = 12
)

Variables

View Source
var (
	ErrNilEntry          error = errors.New("Cannot add nil entry")
	ErrInvalidKey        error = errors.New("Entry key does not match block")
	ErrBadKey            error = errors.New("EntryBlock key is invalid")
	ErrKeyAlreadySet     error = errors.New("Entry key for block already set")
	ErrInvalidEntryBlock error = errors.New("EntryBlock is invalid")
	ErrBlockTooLarge     error = errors.New("EntryBlock is too large to encode")
	ErrInvalidDestBuff   error = errors.New("EntryBlock buffer is too small")
	ErrInvalidSrcBuff    error = errors.New("Buffer is invalid for an EntryBlock")
	ErrPartialDecode     error = errors.New("Buffer is short/invalid for EntryBlock decode")
)
View Source
var (
	// park these as variables so they can be overriden at build time
	DefaultTagName  string = `default`
	GravwellTagName string = `gravwell`
)
View Source
var (
	ErrInvalidHeader     = errors.New("Invalid Entry header in decode")
	ErrInvalidBufferSize = errors.New("Invalid buffer size, too small")
	ErrFailedHeaderWrite = errors.New("Failed to write header while encoding")
	ErrFailedBodyWrite   = errors.New("Failed to write body while encoding")
	ErrFailedBodyRead    = errors.New("Failed to read body while decoding")
	ErrSliceLenTooLarge  = errors.New("Slice length is too large for encoding")
	ErrSliceSizeTooLarge = errors.New("Slice size is too large for encoding")
	ErrDataSizeTooLarge  = errors.New("Entry data size is too large, must be < 1GB")
)
View Source
var (
	ErrInvalidName              = errors.New("invalid enumerated value name")
	ErrInvalid                  = errors.New("invalid enumerated value")
	ErrCorruptedEnumeratedValue = errors.New("enumerated value buffer is corrupt")
	ErrTruncatedEnumeratedValue = errors.New("enumerated value buffer is truncated")
)
View Source
var (
	ErrUnknownType           = errors.New("unknown native type")
	ErrInvalidEnumeratedData = errors.New("invalid enumerated data type or data package")
)
View Source
var (
	ErrEnumeratedValueBlockInvalidCount = errors.New("enumerated value block has too many evs")
	ErrEnumeratedValueBlockInvalidSize  = errors.New("enumerated value block is too large")
	ErrEnumeratedValueBlockCorrupt      = errors.New("enumerated value block buffer is corrupted")
)
View Source
var (
	ErrTSDataSizeInvalid = errors.New("byte slice size invalid")
)

Functions

func DecodeHeader added in v3.8.17

func DecodeHeader(buff []byte) (ts Timestamp, src net.IP, tag EntryTag, hasEvs bool, datasize uint32)

DecodeHeader hands back a completely decoded header with direct references to the underlying data.

func DecodePartialHeader added in v3.8.17

func DecodePartialHeader(buff []byte) (ts Timestamp, tag EntryTag, ipv4, hasEvs bool, datasize uint32)

DecodePartialHeader decodes only the timestamp second, tag, hasEvs, and DataSize. This function is used for quickly scanning through entries in their encoded form.

func EntrySize added in v3.8.17

func EntrySize(buff []byte) (n int, err error)

EntrySize just decodes enough of the header to decide the actual encoded size of an entry this function is typically used for rapidly skipping an entry.

func Since

func Since(tt Timestamp) time.Duration

Since returns the time since the Timestamp tt in as the golang datatype time.Duration

Types

type EVBlock added in v3.8.30

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

EVBlock is a block of enumerated values, this is used to help with transporting enumerated values over the wire and to guard against users of the API doing wonky things that become expensive to encode/decode.

func (*EVBlock) Add added in v3.8.30

func (eb *EVBlock) Add(ev EnumeratedValue)

Add adds an enumerated value to an evbloc, this function keeps a running tally of size for fast query.

func (*EVBlock) AddSet added in v3.8.30

func (eb *EVBlock) AddSet(evs []EnumeratedValue)

AddSet adds a slice of enumerated value to an evbloc, this function keeps a running tally of size for fast query.

func (*EVBlock) Append added in v3.8.30

func (eb *EVBlock) Append(seb EVBlock)

Append appends one evblock to another. This function DOES NOT de-duplicate enumerated values if the src block already has foobar and so does the destination it will be duplicated

func (EVBlock) Compare added in v3.8.30

func (eb EVBlock) Compare(eb2 EVBlock) error

Compare compares two evblocks and returns an error describing the differences if there are any.

func (EVBlock) Count added in v3.8.30

func (eb EVBlock) Count() int

Count is just a helper accessor to spit out the number of EVs in the block.

func (*EVBlock) Decode added in v3.8.30

func (eb *EVBlock) Decode(b []byte) (int, error)

Decode decodes an evblock directly from a buffer and returns the number of bytes consumed. This function will copy all referenced memory so the underlying buffer can be re-used.

func (*EVBlock) DecodeAlt added in v3.8.30

func (eb *EVBlock) DecodeAlt(b []byte) (int, error)

DecodeAlt decodes an evblock directly from a buffer and returns the number of bytes consumed. All data is directly referenced to the provided buffer, the buffer cannot be re-used while any numerated value is still in use.

func (*EVBlock) DecodeReader added in v3.8.30

func (eb *EVBlock) DecodeReader(r io.Reader) (int, error)

DecodeReader decodes an evblock directly from a buffer and returns the number of bytes read and a potential error.

func (EVBlock) DeepCopy added in v3.8.30

func (eb EVBlock) DeepCopy() (r EVBlock)

DeepCopy performs a deep copy of an evblock so that any handles on underlying bytes are discarded. This function is expensive, use sparingly.

func (EVBlock) Encode added in v3.8.30

func (eb EVBlock) Encode() (bts []byte, err error)

Encode encodes an evblock into a byte buffer.

func (EVBlock) EncodeBuffer added in v3.8.30

func (eb EVBlock) EncodeBuffer(bts []byte) (r int, err error)

EncodeBuffer encodes an evblock into a caller provided byte buffer and returns the number of bytes consumed and a potential error.

func (EVBlock) EncodeWriter added in v3.8.30

func (eb EVBlock) EncodeWriter(w io.Writer) (r int, err error)

EncodeWriter encodes an evblock directly into a writer and returns the number of bytes consumed and a potential error.

func (EVBlock) Get added in v3.8.30

func (eb EVBlock) Get(name string) (ev EnumeratedValue, ok bool)

Get retrieves an enumerated value from the set using a name if the name does not exist an empty EnumeratedValue and ok = false will be returned

func (*EVBlock) GobDecode added in v3.8.30

func (eb *EVBlock) GobDecode(b []byte) error

func (EVBlock) GobEncode added in v3.8.30

func (eb EVBlock) GobEncode() ([]byte, error)

func (EVBlock) Populated added in v3.8.30

func (eb EVBlock) Populated() bool

Populated is a helper to check if there are any EVs.

func (*EVBlock) Reset added in v3.8.30

func (eb *EVBlock) Reset()

Reset resets the entry block, the underlying slice is not freed.

func (EVBlock) Size added in v3.8.30

func (eb EVBlock) Size() uint64

Size is just a helper accessor to help with encoding efficiency.

func (EVBlock) Valid added in v3.8.30

func (eb EVBlock) Valid() error

Valid is a helper to determine if an evblock is valid for transport this means that the max ev count hasn't been exceeded nor has the max size. If an evblock is empty, it IS valid. So transports should check Populated in addition to valid, when deciding which Entry encoder to use.

func (EVBlock) Values added in v3.8.30

func (eb EVBlock) Values() []EnumeratedValue

Values is an accessor to actualy get the set of enumerated values out of the evblock this returns the slice directly, so callers COULD mess with the slice and break the size tracker. Basically don't re-use or assign to this slice, if you do the evblock you pulled it from is no longer valid.

type EVBlockHeader added in v3.8.17

type EVBlockHeader struct {
	Size  uint32 //this is the complete size, including the header
	Count uint16
	// contains filtered or unexported fields
}

EVBlockHeader type expressed for documentation, defines transport header for evlocks.

func DecodeEVBlockHeader added in v3.8.17

func DecodeEVBlockHeader(buff []byte) (h EVBlockHeader, err error)

DecodeEVBlockHeader decodes an EVBlockHeader from a buffer and validates it. An empty EVBlockHeader and error is returned if the buffer or resulting EVBlockHeader is invalid.

type Entry

type Entry struct {
	TS   Timestamp
	SRC  net.IP
	Tag  EntryTag
	Data []byte
	EVB  EVBlock
}

func (*Entry) AddEnumeratedValue added in v3.8.17

func (ent *Entry) AddEnumeratedValue(ev EnumeratedValue) (err error)

AddEnumeratedValue will attach a natively typed enumerated value to an entry. An error is returned if the enumerated value is invalid or adding it would cause the entry to exceed the maximum entry size.

func (*Entry) AddEnumeratedValueEx added in v3.8.17

func (ent *Entry) AddEnumeratedValueEx(name string, val interface{}) error

AddEnumeratedValueEx will attach a natively typed enumerated value to an entry. An error is returned if the enumerated value is invalid or adding it would cause the entry to exceed the maximum entry size. An error is also returned if the the provided value type is not natively supported.

func (*Entry) AddEnumeratedValues added in v3.8.23

func (ent *Entry) AddEnumeratedValues(evs []EnumeratedValue) (err error)

AddEnumeratedValues will attach a slice of natively typed enumerated value to an entry. An error is returned if the set of enumerated values contain an invalid enumerated value or adding the set would would cause the entry to exceed the maximum entry size.

func (*Entry) ClearEnumeratedValues added in v3.8.17

func (ent *Entry) ClearEnumeratedValues()

ClearEnumeratedValues is a convenience function to remove all enumerated values

func (*Entry) Compare added in v3.8.17

func (ent *Entry) Compare(v *Entry) error

Compare will perform a deep compare between to entries, used for testing. An error is returned if describing how entries do not match if they do not match.

func (*Entry) CopyEnumeratedBlock added in v3.8.19

func (ent *Entry) CopyEnumeratedBlock(sent *Entry)

func (*Entry) Decode added in v3.8.17

func (ent *Entry) Decode(buff []byte) (int, error)

Decode completely decodes an entry and returns the number of bytes consumed from a buffer This is useful for iterating over entries in a raw buffer. Decode will decode the entire entry and all of its EVs, copying all bytes so that the caller can re-use the underlying buffer. The function returns the number of bytes consumed by the decode and a potential error.

func (*Entry) DecodeAlt added in v3.8.17

func (ent *Entry) DecodeAlt(buff []byte) (int, error)

DecodeAlt completely decodes an entry and returns the number of bytes consumed from a buffer This is useful for iterating over entries in a raw buffer. This decode method directly references the underlying buffer, callers cannot re-use the buffer if the entry and/or its EVs will be used. The function returns the number of bytes consumed by the decode and a potential error.

func (*Entry) DecodeEntry

func (ent *Entry) DecodeEntry(buff []byte) (err error)

DecodeEntry will copy values out of the buffer to generate an entry with its own copies of data. This ensures that entries don't maintain ties to blocks DecodeEntry assumes that a size check has already happened. You probably want Decode.

func (*Entry) DecodeEntryAlt

func (ent *Entry) DecodeEntryAlt(buff []byte) (err error)

DecodeEntryAlt doesn't copy the SRC or data out, it just references the slice handed in it also assumes a size check for the entry header size has occurred by the caller. You probably want DecodeAlt.

func (*Entry) DecodeHeader

func (ent *Entry) DecodeHeader(buff []byte) (int, bool, error)

DecodeHeader will decode an entry header from the provided buffer and return the data size, whether there are EVs, and potentially an error.

func (*Entry) DecodeReader

func (ent *Entry) DecodeReader(rdr io.Reader) error

DecodeReader decodes a slice of entries from an io.Reader.

func (*Entry) DeepCopy

func (ent *Entry) DeepCopy() (c Entry)

DeepCopy provides a complete copy of an entry, this is REALLY expensive, so make sure its worth it.

func (*Entry) EVCount added in v3.8.17

func (ent *Entry) EVCount() int

EVCount is a helper function that ruturns the number of EVs attached to the entry.

func (*Entry) EVEncodeWriter added in v3.8.17

func (ent *Entry) EVEncodeWriter(wtr io.Writer) (int, error)

EVEncodeWriter is a helper function for writing just the EVs to a provided io.writer, the function also returns the number of bytes written and a potential error.

func (*Entry) EVSize added in v3.8.17

func (ent *Entry) EVSize() int

EVSize is a helper function that ruturns the number of bytes consumed by the EVs on an entry.

func (*Entry) Encode

func (ent *Entry) Encode(buff []byte) (int, error)

Encode encodes an entry into the provided buffer. The function returns the number of bytes consumed in the buffer as well as any potential errors.

func (*Entry) EncodeHeader

func (ent *Entry) EncodeHeader(buff []byte) (bool, error)

EncodeHeader encodes the header into the buffer for the transport, the function only encodes the header. The function returns a boolean indicating if EVs are marked and a potential error.

func (*Entry) EncodeWriter

func (ent *Entry) EncodeWriter(wtr io.Writer) (int, error)

EncodeWriter will fully encode an entry to an io.Writer, it returns the number of bytes written and a potential error.

func (Entry) EnumeratedValues added in v3.8.17

func (ent Entry) EnumeratedValues() []EnumeratedValue

EnumeratedValues returns the slice of enumerated values, this is an accessor to prevent direct assignment

func (*Entry) GetEnumeratedValue added in v3.8.19

func (ent *Entry) GetEnumeratedValue(name string) (val interface{}, ok bool)

GetEnumeratedValue looks up an enumerated value by name and returns it as a native type if the value is not present the function returns nil and false

func (*Entry) Key

func (ent *Entry) Key() EntryKey

func (*Entry) MarshallBytes

func (ent *Entry) MarshallBytes() ([]byte, error)

MarshallBytes implements a gob encoder, the function is deprecated.

func (*Entry) ReadEVs added in v3.8.17

func (ent *Entry) ReadEVs(rdr io.Reader) error

ReadEVs is a deprecated function, use DecodeReader instead.

func (*Entry) Size

func (ent *Entry) Size() uint64

Size returns the size of an entry as if it were encoded.

type EntryBlock

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

standard entry block, primarily used in ingesters

func NewDeepCopyEntryBlock

func NewDeepCopyEntryBlock(set []*Entry, sz uint64) (neb EntryBlock)

NewDeepCopyEntryBlock creates a new EntryBlock with a deep copy on all data in the provided set the sz size parameter is used as a hint for allocation, provide zero if unknown

func NewEntryBlock

func NewEntryBlock(set []*Entry, size uint64) EntryBlock

NewEntryBlock creates a new entry block from the set and size parameters the size is taken at face value and should represent the storage size needed to encode the given set

func NewEntryBlockNP

func NewEntryBlockNP(set []Entry, size uint64) (eb EntryBlock)

NewEntryBlock creates a new entry block from the set and size parameters the size is taken at face value and should represent the storage size needed to encode the given set. The slice of Entry handed in is NOT copied, caller should not modify the slice until the block is done

func (*EntryBlock) Add

func (eb *EntryBlock) Add(e *Entry)

Add adds an entry to the entry block, if no key is currently set, the entries TS is used

func (*EntryBlock) Count

func (eb *EntryBlock) Count() int

Count returns the number of entries held in the block

func (*EntryBlock) Decode

func (eb *EntryBlock) Decode(b []byte) error

Decode will decode an EntryBlock from a buffer, with error checking

func (EntryBlock) DeepCopy

func (eb EntryBlock) DeepCopy() EntryBlock

Deep copy performs an agressive deep copy of the entire block, all entries, and any underlying buffers this is useful when you are pulling entries out of a RO memory reagion and want to ensure your block is entirely orthogonal to the backing memory region. WARNING: this will hammer the memory allocator, only use when you know what you are doing

func (*EntryBlock) Encode

func (eb *EntryBlock) Encode() ([]byte, error)

Encode encodes the EntryBlock to a buffer suitable for transmitting across a network or storing to a file

func (*EntryBlock) EncodeAppend

func (eb *EntryBlock) EncodeAppend(buff []byte) ([]byte, error)

EncodeAppend takes the current buffer, and appends addional entries to the buffer we also update the header

func (*EntryBlock) EncodeEntries

func (eb *EntryBlock) EncodeEntries(buff []byte) (int, error)

EncodeEntries encodes just the set of entries into the provided buffer

func (*EntryBlock) EncodeInto

func (eb *EntryBlock) EncodeInto(buff []byte) (int, error)

EncodeInto encodes the entry block into the given buffer. The buffer MUST be large enough to hold the entire block, an encoded size and nil is returned on success 0 and an error is returned if the buffer is too small the size checks are performed on the actual entries as well as the block size

func (EntryBlock) EncodedSize

func (eb EntryBlock) EncodedSize() uint64

EncodedSize returns the size of an entry block as would be encoded to disk without compression

func (*EntryBlock) Entries

func (eb *EntryBlock) Entries() []*Entry

Entries returns the underlying entry slice

func (*EntryBlock) Entry

func (eb *EntryBlock) Entry(i int) *Entry

Entry returns the ith entry from the block. If i is an invalid index nil is returned

func (EntryBlock) EntryKey

func (eb EntryBlock) EntryKey(i int) (int64, error)

EntryKey returns the key associated with an entry in the block and an error if the entry doesn't exist

func (EntryBlock) Key

func (eb EntryBlock) Key() int64

Key returns the timestamp associated with the block, There is no garuntee that all entries are part of this key, if the construction of the block didn't adhere to grouping the key means little The key is basically a hint

func (EntryBlock) Len

func (eb EntryBlock) Len() int

Len returns the number of entries allocated, there is no garuntee the entries are all non-nil

func (*EntryBlock) Merge

func (eb *EntryBlock) Merge(neb *EntryBlock) error

Merge merges a provided entry block into the given entry block, the keys for the two blocks must match

func (*EntryBlock) Peel

func (eb *EntryBlock) Peel(cnt int, sz uint64) (neb EntryBlock)

Peel splits off a set of entries from the EntryBlock, returning a new EntryBlock and updating the state of the current EntryBlock, the count and size are used as barrier we peel until we hit either the count or the size

func (*EntryBlock) SetKey

func (eb *EntryBlock) SetKey(k EntryKey) error

SetKey manually sets the key of a block, this is not an override, if the key is already set an error is returned

func (EntryBlock) Size

func (eb EntryBlock) Size() uint64

Size returns the size of the entry block (without encoding header)

type EntryKey

type EntryKey int64

type EntrySlice

type EntrySlice []Entry

func (*EntrySlice) DecodeReader

func (es *EntrySlice) DecodeReader(rdr io.Reader) error

DecodeReader decodes a slice of entries from an io.Reader.

func (EntrySlice) EncodeWriter

func (es EntrySlice) EncodeWriter(wtr io.Writer) error

EncodeWriter encodes a slice of entries to an io.Writer.

func (*EntrySlice) Size

func (es *EntrySlice) Size() uint64

Size eturns the encoded size of a slice of entries.

type EntryTag

type EntryTag uint16

func DecodeHeaderTagSec added in v3.8.17

func DecodeHeaderTagSec(buff []byte) (tag EntryTag, sec int64)

DecodeHeaderTagSec checks that the buffer is big enough for a header then ONLY extracts the tag and second component of the timestamp. This function is used for rapidly scanning an entry header to decide if we want to decode it, we assume the caller has already ensured that the buffer is large enough to at least contain a header.

type EnumeratedData added in v3.8.17

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

func BoolEnumData added in v3.8.17

func BoolEnumData(v bool) EnumeratedData

func ByteEnumData added in v3.8.17

func ByteEnumData(v byte) EnumeratedData

func DurationEnumData added in v3.8.17

func DurationEnumData(v time.Duration) EnumeratedData

func Float32EnumData added in v3.8.17

func Float32EnumData(v float32) EnumeratedData

func Float64EnumData added in v3.8.17

func Float64EnumData(v float64) EnumeratedData

func IPEnumData added in v3.8.17

func IPEnumData(addr net.IP) EnumeratedData

func InferEnumeratedData added in v3.8.17

func InferEnumeratedData(val interface{}) (EnumeratedData, error)

InverEnumeratedData takes a native type and creates a properly annotated enumerated value data section. The function returns an empty EnumeratedData if the type provided type is invalid.

func Int16EnumData added in v3.8.17

func Int16EnumData(v int16) EnumeratedData

func Int32EnumData added in v3.8.17

func Int32EnumData(v int32) EnumeratedData

func Int64EnumData added in v3.8.17

func Int64EnumData(v int64) EnumeratedData

func Int8EnumData added in v3.8.17

func Int8EnumData(v int8) EnumeratedData

func IntEnumData added in v3.8.17

func IntEnumData(v int) EnumeratedData

func MACEnumData added in v3.8.17

func MACEnumData(addr net.HardwareAddr) EnumeratedData

func NewEnumeratedData added in v3.8.21

func NewEnumeratedData(evtype uint8, data []byte) (ed EnumeratedData, err error)

NewEnumeratedValueRaw takes an EV type ID and byte slice, validates it, and then creates a new ingest EV. This is primarily used when reimporting data from a query that has a github.com/gravwell/gravwell/client/types.EnumeratedPair. This should not be called by hand.

func RawEnumeratedData added in v3.8.19

func RawEnumeratedData(id uint8, data []byte) (ed EnumeratedData, err error)

RawEnumeratedData allows for creating a new EnumeratedData directly using a byte buffer and type this is useful when converting between types.StringTagEntry and an ingest.Entry

func SliceEnumData added in v3.8.17

func SliceEnumData(v []byte) EnumeratedData

func StringEnumData added in v3.8.17

func StringEnumData(v string) EnumeratedData

func StringEnumDataTail added in v3.8.17

func StringEnumDataTail(v string) EnumeratedData

StringEnumDataTrimmed will create a Unicode enumerated value with leading characters trimmed off if and only if the provided string is too long. This function is commonly used in the file follower. This function is UTF-8 aware and will respect entire unicode characters.

func TSEnumData added in v3.8.17

func TSEnumData(v Timestamp) EnumeratedData

func Uint16EnumData added in v3.8.17

func Uint16EnumData(v uint16) EnumeratedData

func Uint32EnumData added in v3.8.17

func Uint32EnumData(v uint32) EnumeratedData

func Uint64EnumData added in v3.8.17

func Uint64EnumData(v uint64) EnumeratedData

func UintEnumData added in v3.8.17

func UintEnumData(v uint) EnumeratedData

func (EnumeratedData) Interface added in v3.8.17

func (ev EnumeratedData) Interface() (v interface{})

Interface is a helper function that will return an interface populated with the native type.

func (EnumeratedData) String added in v3.8.17

func (ev EnumeratedData) String() string

func (EnumeratedData) Valid added in v3.8.17

func (ev EnumeratedData) Valid() bool

Valid is a helper function that declares if an enumerated data item is valid this means that the type is known and the encoded bytes match what is expected.

type EnumeratedValue added in v3.8.17

type EnumeratedValue struct {
	Name  string
	Value EnumeratedData
}

func NewEnumeratedValue added in v3.8.17

func NewEnumeratedValue(name string, data interface{}) (ev EnumeratedValue, err error)

NewEnumeratedValue will take the data interface and make a best effort to figure out what type it is being given and shove it into this encoding. This is the slowest method for creating an enumerated value, use the native types.

func (EnumeratedValue) Compare added in v3.8.17

func (ev EnumeratedValue) Compare(ev2 EnumeratedValue) (err error)

Compare is a helper function to do comparisons and get errors out describing what is not the same.

func (*EnumeratedValue) Decode added in v3.8.17

func (ev *EnumeratedValue) Decode(r []byte) (n int, err error)

Decode is a helper function that returns how much of the buffer we consumed, this is used for decoding evblocks This function will make a copy of all referenced bytes so that the provided buffer can be re-used. The function returns the number of bytes consumed and a potential error.

func (*EnumeratedValue) DecodeAlt added in v3.8.17

func (ev *EnumeratedValue) DecodeAlt(r []byte) (n int, err error)

DecodeAlt is a helper function that returns how much of the buffer we consumed this is used for decoding evblocks. This function will will directly reference the underlying buffer. Callers cannot re-use the buffer if the enumerated values are enumerated values are in use. The function returns the number of bytes consumed and a potential error.

func (*EnumeratedValue) DecodeReader added in v3.8.17

func (ev *EnumeratedValue) DecodeReader(r io.Reader) (int, error)

DecodeReader decodes an enumerated value from the io.Reader and returns the number of bytes read as well as a potential error.

func (EnumeratedValue) Encode added in v3.8.17

func (ev EnumeratedValue) Encode() []byte

Encode will pack the enumerated value into a byte slice. Invalid EVs return nil.

func (EnumeratedValue) EncodeWriter added in v3.8.17

func (ev EnumeratedValue) EncodeWriter(w io.Writer) (int, error)

EncodeWriter will encode an enumerated value into a writer, it returns the number of bytes written and a potential error.

func (EnumeratedValue) Size added in v3.8.17

func (ev EnumeratedValue) Size() int

Size returns the encoded size of an enumerated value

func (EnumeratedValue) String added in v3.8.17

func (ev EnumeratedValue) String() string

String implements the stringer for Enumerated Values.

func (EnumeratedValue) TypeID added in v3.8.17

func (ev EnumeratedValue) TypeID() uint8

TypeID returns the underlying type identifier used to cast a raw buffer across types. This is just a little accessor used to get raw access to fields without exposing them for assignment.

func (EnumeratedValue) Valid added in v3.8.17

func (ev EnumeratedValue) Valid() bool

Valid is a helper function that will indicate if an enumerated value is valid. To be valid the enumerated value name must be populated and less than MaxEvNameLength and the enumerated data must be valid.

func (EnumeratedValue) ValueBuff added in v3.8.17

func (ev EnumeratedValue) ValueBuff() []byte

ValueBuff returns the underlying buffer representing the enumerated values data. This is just a little accessor used to get raw access to fields without exposing them for assignment.

type Timestamp

type Timestamp struct {
	Sec  int64
	Nsec int64
}

Timestamp is the base timestamp structure all timestamps are assumed to be UTC Sec is the second count since 0000-00-00 00:00:00 UTC Nsec is the nanosecond offset from Sec

func FromStandard

func FromStandard(ts time.Time) Timestamp

FromStandard converts the time.Time datatype to our Timestamp format

func Now

func Now() Timestamp

Now retrieves the current UTC time

func UnixTime

func UnixTime(s, ns int64) Timestamp

func (Timestamp) Add

func (t Timestamp) Add(d time.Duration) (tt Timestamp)

Add subtracts Timestamp tt from Timestamp t and returns the golang time.Duration datatype which is essentially a nanosecond count

func (Timestamp) After

func (t Timestamp) After(tt Timestamp) bool

After returns whether time instance t is after parameter time tt

func (Timestamp) Before

func (t Timestamp) Before(tt Timestamp) bool

Before returns whether time instance t is before the parameter time tt

func (*Timestamp) Decode

func (t *Timestamp) Decode(buff []byte)

Decode reads the timestamp from a buffer, it is designed to be fast and inlined it DOES NOT check the buffer size, so the caller better

func (Timestamp) Encode

func (t Timestamp) Encode(buff []byte)

Encode writes the timestamp to a buffer, it is designed to be fast and inlined, it DOES NOT check the buffer size, so the caller better

func (Timestamp) Equal

func (t Timestamp) Equal(tt Timestamp) bool

Equal returns whether time instance t is identical to parameter time tt

func (Timestamp) Format

func (t Timestamp) Format(layout string) string

Format prints the Timestamp in text using the same layout format as time.Time

func (Timestamp) IsZero

func (t Timestamp) IsZero() bool

IsZero returns whether the second and nanosecond components are both zero

func (Timestamp) MarshalBinary

func (t Timestamp) MarshalBinary() ([]byte, error)

MarshalBinary marshals the timestamp into an 12 byte byte slice

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON marshals the timestamp into the golang time.Time JSON format this is a total hack, and we will write our own marshallers soon

func (Timestamp) MarshalText

func (t Timestamp) MarshalText() ([]byte, error)

MarshalText marshals the timestamp into the golang time.Time text format this is a total hack, and we will write our own marshallers soon

func (Timestamp) StandardTime

func (t Timestamp) StandardTime() time.Time

StandardTime converts our Timestamp format to the golang time.Time datatype

func (Timestamp) String

func (t Timestamp) String() string

String returns the standard string representation of Timestamp

func (Timestamp) Sub

func (t Timestamp) Sub(tt Timestamp) time.Duration

Sub subtracts Timestamp tt from Timestamp t and returns the golang time.Duration datatype which is essentially a nanosecond count

func (*Timestamp) UnmarshalBinary

func (t *Timestamp) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals a 12 byte encoding of a Timestamp This type is NOT compatible with the time.Time format

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the timestamp JSON into the Timestamp format This format is compatible with the time.Time format

func (*Timestamp) UnmarshalText

func (t *Timestamp) UnmarshalText(data []byte) error

UnmarshalText unmarshals the Timestamp from a byte array the format is compatible with the golang time.Time Text format

Jump to

Keyboard shortcuts

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