Created
August 31, 2014 03:57
-
-
Save wolfeidau/57322e5e5ec53d981859 to your computer and use it in GitHub Desktop.
kako types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Event struct { | |
UserID string // GUID of the user who owns this series | |
Key string // name of the series, otherwise known as key | |
Measurement *Measurement // measurement | |
LogEntry *LogEntry // log event | |
Timestamp time.Time // when measurement was taken | |
} | |
func (e *Event) ToRowMap() map[string]bigquery.JsonValue { | |
v := make(map[string]bigquery.JsonValue) | |
v["UserID"] = e.UserID | |
v["Key"] = e.Key | |
if e.Measurement != nil { | |
v["Measurement"] = e.Measurement.ToRowMap() | |
} | |
if e.LogEntry != nil { | |
v["LogEntry.Facility"] = e.LogEntry.Facility | |
v["LogEntry.Severity"] = e.LogEntry.Severity | |
v["LogEntry.Tag"] = e.LogEntry.Tag | |
v["LogEntry.Content"] = e.LogEntry.Content | |
} | |
v["Timestamp"] = e.Timestamp | |
return v | |
} | |
// "time", "count", "min", "max", "mean", "std-dev", "95-percentile" | |
type Measurement struct { | |
Value float64 | |
Count int64 | |
Min int64 | |
Max int64 | |
Mean int64 | |
Percentile95 int64 | |
} | |
func (m *Measurement) ToRowMap() map[string]bigquery.JsonValue { | |
v := make(map[string]bigquery.JsonValue) | |
v["Value"] = m.Value | |
v["Count"] = m.Count | |
v["Min"] = m.Min | |
v["Max"] = m.Max | |
v["Mean"] = m.Mean | |
v["Percentile95"] = m.Percentile95 | |
return v | |
} | |
type LogEntry struct { | |
Facility, Severity, Tag, Content string | |
} | |
func (l *LogEntry) ToRowMap() map[string]bigquery.JsonValue { | |
v := make(map[string]bigquery.JsonValue) | |
v["Facility"] = l.Facility | |
v["Severity"] = l.Severity | |
v["Tag"] = l.Tag | |
v["Content"] = l.Content | |
return v | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment