Can we have getters on Point or PointBuilder class
Hi,
I am writing some generic code to parse json string to Point, we found it's difficult to verify the Point object when I try to write test for the parsing. If we can have the Point's getters exposed, our life would be much easier.
additionally, why is the measurement field in Point.Builder made final? the measurement is dynamically resolved after the point builder are prepared in our system. So can we have a setter on measurement?
Thanks Alex
Immutability will be lost, once the getters are public. This is the point of having DTO with the Builder pattern.
You still can access what is inside for example with: https://github.com/influxdata/influxdb-java/blob/master/src/main/java/org/influxdb/dto/Point.java#L322
I have a workaround of re-construct a map by parsing the result of Point.toString() in my assertThat code of my test.
I think returning ImmutableMap with a copy of the fields and tags in builder would be helpful to keep the immutability, and make test writing a lot easier.
Meanwhile, I think the measurement should be able to updated in Builder class during the point building, as we are in the scenario of measurement is decided quite late after the point is built. So it would be great if we can have the measurement updated in Builder. we don't have a workaround for this up to now, unless we change our system design significantly.
I dont understand how you create a measurement after you build a point ?
Ok, some background below. We have a persistence sub system that supports writing to different persistence provider ( originally only mongodb and now onboarding influxdb) with dynamic data destination routing. The domain data is converted into corresponding format (Point for influx, json for mongo) once data is received by the sub system, and a dedicated writer will save the converted data to the right place (database and measurement) by looking up an external (runtime configurable) map keyed on the data type.
The data converter purely involves domain objects and Point object (in the influxdb case) during conversion. So the converter doesn't (and shouldn't, I think) have the knowledge of which measurement will the data be saved to, as that's determined by looking up the external map by the writer which may change dynamically as we want to control the data flow on the fly.
In our mongdb case, we can always prepare the json data without specifying the collection name till mongo writer looks up the map before writing. So we try to keep the design consistent for the influxdb case.
The basic idea behind is to have the separation of "data preparation" and "data destination routing". I guess this idea is not hugely crazy. And if we can have a Builder constructor takes no param, and have a setter on measurement fields, our problem is solved without too much pain on refactorying the system.
Hi,
understood some parts, but the solution will not be to change a core library to match your needs. I designed a immutable interface to points, if you need to modify them before they get written, you need to implement a layer between which solves your very specific problem.
ok cool. looking forward to the release containing the change. Thanks