You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.5KB

123456789101112131415161718192021222324252627282930
  1. # influx-writer
  2. An opinionated influxdb client in rust:
  3. - http write requests are managed by a worker thread, so "writing" to influx is wait free on the hot path
  4. - worker thread recovers from failed writes/requests with robust retry and failure handling
  5. - library includes `measure!`, a mini-dsl for creating and sending measurements to influxdb
  6. ## `measure!`
  7. `measure!` is a macro that allows highly ergonomic creation and sending of `OwnedMeasurement` instances, at the cost of a bit of a learning curve.
  8. A single letter is used to denote the type of a field, and `t` is used to denote a tag:
  9. ```rust
  10. measure!(influx, "measurement_name", t(color, "red"), i(n, 1), tm(now()));
  11. ```
  12. In the above example, `influx` is the identifier for a `InfluxWriter` instance. `InfluxWriter` is a handle to the worker thread that is sending data to the influxdb server.
  13. Now for a more advanced example: if only a single argument is passed to `t`, `f`, `i`, `b`, and other field type short-hands, it creates a field or tag by that name, and uses value in a variable binding of the same name as the field or tag's value:
  14. ```rust
  15. let color = "red";
  16. let n = 1;
  17. let t = now(); // in this example, now() would return integer timestamp
  18. measure!(influx, "even_faster", t(color), i(n), tm(t));
  19. ```
  20. In the example above, `measure!` creates a `OwnedMeasurement` instance, fills it with a tag named "color" with the value "red", an integer field "n" with the value 1, and a timestamp with the value that's in the variable `t`. Then it uses `influx` to send the measurement to the worker thread.