Closed gambrose closed 7 years ago
Hi @gambrose!
First, awesome - would personally love to see something like this out there.
Though, I don't think this particular repository is currently going to be a good vehicle for it; we're making progress (with much thanks to you) on a 1.0 of the metrics collection/line protocol implementation, but really, resources to keep things at a production level of quality are somewhat stretched. I don't think we'd want to take focus from the current scenarios to dig into new ones just yet, or in the very near future.
But, I think it's a great candidate to stand up as a library in its own right! This project was originally "indie" and got off to a good start that way. I can't speak for InfluxData (not an employee), but getting something out there under your own steam to start off, and opening a discussion further down the track, would seem like a viable approach.
HTH!
@nblumhardt thanks for your feedback.
I will spin up a separate repo and see if I can get something working.
I realise that there are already many libraries out there that enable querying data out of influx. But none of them I have found enabled me to easily query data out in a type safe way. I have done some thinking and some hacking and think I have something that might be worth perusing. It's just a proposal at the moment. I have scaffolded the api to ensure it compiles and gives me the correct type safety.
I would appreciate it if you could give me some feedback on if you think this would be useful addition to the library, if I get it running, or if it is something you would not likely accept a pull request for.
Clinet Api
Query a single series
Each point is returned as a value tuple of values and time (as a
DateTime
). We are using tuple destucturing in the foreach to print out the values and time.Values are matched with columns based on propery names. Attribues could be used to customise the name matching.
Query multible series (GROUP BY)
We are passing in Value and Tag types so we know this returns multible series. Tag values are returned once for each series rather than for each point which is more efficient on the wire.
We can also flatten the results to make it more consise.
Design
The basic design of the query api is to use seperate types that define the values and tags a query has.
This seams overly verbose but has benifits when building queries using a fluent api and still enabling full intellisense for the results. As we can track projections made to the values and tags types.
C# does not allow union types but by using an anonymous type in the select clause we can conbine both fields and tags into a single values type.
The Select function takes an
Expression
so that we can parse the expression tree and produce the select clause. In this case we are importing the InfluxAggregations.COUNT function this is just a place holder that accepts field value types, in this case double, and returns int.Group by time clause is kept sperate from the tag selection. I haven't dsesigned the Where clause yet.
I tried to separate the client api which accepts strings and result types to deserialise separate from the query builder api. I would likely build the client api first and then get the more complicated query api working.