-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Proposal:
This is related to the suggestion in #69.
If InfluxDBClient.Point
was changed to be a struct, the usability of it could be improved.
The properties could be made public. This would be a simpler way to modify the values in the point than using the add...
methods, which don't do anything other than silently ignore being passed a nil
key.
The existing public init can be updated to have parameters with default values for all the properties of the struct.
Current behavior:
Example from the readme
let recordPoint = InfluxDBClient
.Point("demo")
.addTag(key: "type", value: "point")
.addField(key: "value", value: .int(2))
let recordPointDate = InfluxDBClient
.Point("demo")
.addTag(key: "type", value: "point-timestamp")
.addField(key: "value", value: .int(2))
.time(time: .date(Date()))
Desired behavior:
Public properties allow separating the creation of the point from setting the values. It's not always possible to have all the values at the same time the point is created.
var recordPoint = InfluxDBClient.Point("demo")
recordPoint.tags["type"] = "point"
recordPoint.fields["value"] = .int(2)
var recordPointDate = InfluxDBClient.Point("demo")
recordPoint.tags["type"] = "point"
recordPoint.fields["value"] = .int(2)
recordPoint.time = .date(Date())
Public init showing all the properties available to be set on the type though the one initializer instead of needing to chain function calls.
let recordPoint = InfluxDBClient.Point(
"demo",
tags: ["type": "point"]
fields: ["value": .int(2)]
)
let recordPointDate = InfluxDBClient.Point(
"demo"
tags: ["type": "point"]
fields: ["value": .int(2)]
time: .date(Date())