Documentation ¶
Overview ¶
Optional, standardized event structure + serialization format
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeserializeLines ¶
func SerializeLines ¶
helper. last line won't have \n after it. WARNING: you're responsible for making sure none of the lines have \n on it.
func SerializeOne ¶
Types ¶
type ErrUnsupportedEvent ¶
type ErrUnsupportedEvent struct {
// contains filtered or unexported fields
}
func (*ErrUnsupportedEvent) Error ¶
func (e *ErrUnsupportedEvent) Error() string
type EventMeta ¶
type EventMeta struct { DontUseTimeLogical time.Time `json:"t"` DontUseTimeOfRecording *time.Time `json:"tr,omitempty"` DontUseUserId string `json:"u,omitempty"` }
common attributes for all events. timestamps are forced to UTC and rounded to millisecond precision. JSON fields are aggressively shortened for compactness
func Meta ¶
creates event metadata with timestamp and user. timestamp is by default normalized to UTC and stored in only millisecond precision to conserve space when storing timestamps as a string.
func MetaBackdate ¶
for when you need to backdate a user's event. i.e. something logical happened before it was finally recorded (usually *now*)
func MetaSystemUser ¶
for when the event doesn't have a known user, i.e. the user will be "system"
func MetaSystemUserBackdate ¶
same as MetaBackdate(), but with MetaSystemUser() semantics
func (*EventMeta) Time ¶
"When did this happen" - logical timestamp. most times you'll use this (as opposed to time of recording)
func (*EventMeta) TimeOfRecording ¶
"When was this event recorded". sometimes logical timestamp precedes time of recording:
- sometimes you need to backdate events, e.g. importing old data where logical events happened years ago, but the events we're migrating to will be recorded *now*. only in these cases we have separate logical and recording timestamps. sensor data e.g. GPS time of fix vs. time the server received it can be even minutes later if end device has connectivity problems (or end device vs. server clock not in sync).
- most times you're interested in TimestampLogical()
- you'll almost always set time of recording to time.Now() when creating events
func (*EventMeta) UserId ¶
returns systemUserId if event was raised by "system", i.e. there's no explicit user