Documentation
¶
Overview ¶
Package whevent turns one accepted webhook request into the events a source stores, and renders them as the JSON-lines a segment holds (#1870).
An event is the envelope the receiver adds around what the sender posted: when it was received, which replica received it, the sender's id, type and key for it when the source says where to find them, and the posted JSON as text. The payload is never transformed: a reader extracts what it needs from it with json_extract_scalar, and a sender adding a field never changes the table.
Index ¶
Constants ¶
const FormPayloadField = "payload"
FormPayloadField is the form field a sender that posts application/x-www-form-urlencoded carries its JSON in.
const TimestampLayout = "2006-01-02 15:04:05.000000"
TimestampLayout is how a timestamp is written into a segment: the text the Hive JSON reader parses as a TIMESTAMP(6), in UTC.
Variables ¶
var ( ErrNotJSON = errors.New("the body is not JSON") ErrNoPayload = errors.New("the form has no payload field") ErrSplitNotArray = errors.New("the split path does not name an array in the body") )
Refusals a body can meet. Each is answered 400 and nothing is stored.
var Columns = []string{
"received_at", "landed_at", "event_id", "event_type", "key",
"content_hash", "replica", "payload",
}
Columns are the columns every source's tables and view declare, in order. dt, hour and minute are the partition columns and are not written into a file.
Functions ¶
func EncodeSegment ¶
EncodeSegment renders events as gzipped JSON-lines, each stamped with landedAt.
Types ¶
type Event ¶
type Event struct {
ReceivedAt time.Time
EventID string
EventType string
Key string
ContentHash string
Replica string
// Payload is the event's JSON, compacted.
Payload []byte
}
Event is one stored event.