Skip to content

Instantly share code, notes, and snippets.

@xNok
Created September 13, 2021 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xNok/dd408b73e48318fef6334f07783f819b to your computer and use it in GitHub Desktop.
Save xNok/dd408b73e48318fef6334f07783f819b to your computer and use it in GitHub Desktop.
func write_event_with_fluent_Style(client influxdb2.Client, t ThermostatSetting) {
// Use blocking write client for writes to desired bucket
writeAPI := client.WriteAPI(org, bucket)
// create point using fluent style
p := influxdb2.NewPointWithMeasurement("thermostat").
AddTag("unit", "temperature").
AddTag("user", t.user).
AddField("avg", t.avg).
AddField("max", t.max).
SetTime(time.Now())
writeAPI.WritePoint(p)
// Flush writes
writeAPI.Flush()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment