-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement simple InfluxDB client #19
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
==========================================
- Coverage 56.54% 52.77% -3.77%
==========================================
Files 5 6 +1
Lines 168 180 +12
==========================================
Hits 95 95
- Misses 73 85 +12 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments:
- Could you wrap the client in a module so that everything InfluxDB is in its own namespace?
module InfluxDB # current contents of influx.jl end # module InfluxDB
- With the above change, maybe it is best to rename
InfluxClient
to justClient
- Do you have any idea how to write tests for this module?
src/influx.jl
Outdated
InfluxClient( | ||
host::String, | ||
database::String, | ||
port::Int = 8086, | ||
path::String = "query", | ||
username::String = "", | ||
password::String = "", | ||
) = new(host, database, port, username, password, path) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this kind of convenience constructors can be inner. You should move this to outer, then you cannot use new
. So, probably this:
InfluxClient( | |
host::String, | |
database::String, | |
port::Int = 8086, | |
path::String = "query", | |
username::String = "", | |
password::String = "", | |
) = new(host, database, port, username, password, path) | |
end | |
end | |
InfluxClient( | |
host::String, | |
database::String, | |
) = InfluxClient(host, database, 8086, "query", "", "") |
@wcoenraads Is this waiting on Suvayu's return? |
@clizbe if my review comments are addressed, we can merge this as a first implementation. I'm more concerned about the lack/difficulty of testing. We need to solve it, but not necessarily in this PR. |
These comments/notifications completely passed me by - apologies! I'll address your comments and update the PR this afternoon. As for testing, I'm also unsure. Downstream tests relying on these APIs could use mock data, but the influx client should really be tested against the InfluxDB API as that's the thing it interacts with. We could create a setup with a development DB to test against, but that feels like a lot of effort for little gain at the moment. |
Good point on the module! I've renamed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @wcoenraads, everything looks good 👍, except I think it would be more consistent if the file was called influxdb.jl
.
Sorry, I should have included this comment earlier. I'll comment separately on testing.
Indeed, and a separate dev endpoint would also be too much external dependency. I can think of two approaches:
I would say (1) is good enough for now, we can think about (2) later. WDYT? How about @clizbe, any opinions? |
PS: I think the nightly test failure is due to an upstream packaging issue, ignore for now. |
Yep, good point - changed!
The first approach could work, but seems limited and fragile: tests that can't be run in CI are much less likely to be adhered to, and they would depend on the specifics of an internal DB we only have limited control over. The second approach is solid, but indeed more work. It might also be beneficial in tests for later components, where we can do end-to-end tests without mocks in between. But that's a concern for later. |
Thanks! I merged this, we can workout the tests in a separate PR. |
Closes #6 |
Adds a simple InfluxDB client as described in #6. It's important to note that the current implementation does not escape the parameters to the query, so it should not be used with untrusted input.