Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TimeFromUnixMillisecond ¶
TimeFromUnixMillisecond returns time from Unix epoch time in milliseconds.
func TimeToUnixMillisecond ¶
TimeToUnixMillisecond converts t into Unix epoch time in milliseconds. That's because seconds is not enough precision and nanoseconds is too much.
Types ¶
type Reader ¶
type Reader struct { // hints that the data was written without a timestamp // (see Writer.NoTimestamp). We're permissive i.e. we'll // read timestamp if it's written even if NoTimestamp is true NoTimestamp bool // Record is available after ReadNextRecord(). // It's over-written in next ReadNextRecord(). Record *Record // Data / Name / Timestampe are available after ReadNextData. // They are over-written in next ReadNextData. Data []byte Name string Timestamp time.Time // position of the current record within the reader. // We keep track of it so that callers can index records // by offset and seek to it CurrRecordPos int64 // position of the next record within the reader. NextRecordPos int64 // contains filtered or unexported fields }
Reader is for reading (deserializing) records from a bufio.Reader
func (*Reader) ReadNextData ¶
ReadNextData reads next block from the reader, returns false when no more record. If returns false, check Err() to see if there were errors. After reading Data containst data, and Timestamp and (optional) Name contain meta-data
func (*Reader) ReadNextRecord ¶
ReadNextRecord reads a key / value record. Returns false if there are no more record. Check Err() for errors. After reading information is in Record (valid until next read).
type Record ¶
type Record struct { // Entries are available after Unmarshal/UnmarshalRecord Entries []Entry Name string // when writing, if not provided we use current time Timestamp time.Time // contains filtered or unexported fields }
Record represents list of key/value pairs that can be serialized/deserialized
func UnmarshalRecord ¶
UnmarshalRecord unmarshall record as marshalled with Record.Marshal For efficiency re-uses record r. If r is nil, will allocate new record.
func (*Record) Reset ¶
func (r *Record) Reset()
Reset makes it easy to re-use Record (as opposed to allocating a new one each time)
type Writer ¶
type Writer struct { // NoTimestamp disables writing timestamp, which // makes serialized data not depend on when they were written NoTimestamp bool // contains filtered or unexported fields }
Writer writes records to in a structured format