Skip to content

Instantly share code, notes, and snippets.

@xNok
Created September 13, 2021 00:55
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/5104a915f7f5bbe81ec2275589e55a48 to your computer and use it in GitHub Desktop.
Save xNok/5104a915f7f5bbe81ec2275589e55a48 to your computer and use it in GitHub Desktop.
func write_event_with_params_constror(client influxdb2.Client, t ThermostatSetting) {
// Use blocking write client for writes to desired bucket
writeAPI := client.WriteAPI(org, bucket)
// Create point using full params constructor
p := influxdb2.NewPoint("thermostat",
map[string]string{"unit": "temperature", "user": t.user},
map[string]interface{}{"avg": t.avg, "max": t.max},
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