-
Notifications
You must be signed in to change notification settings - Fork 24
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
new adapter read and write api #248
Conversation
34a3346
to
fbf8b66
Compare
@juttle/developers |
f43d8ad
to
7841362
Compare
|
||
var format; | ||
try { | ||
format = contentType.parse(res).type.split('/')[1]; |
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.
Know this was just a copy-paste but I'm confused by the logic...you take the content type of res
and then use that to get a parser that you use on req
? Seems like this should be contentType.parse(req)
.
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.
Yeah I agree -- it turns out that either works, but it does seem confusing to parse the content type of the request and not the response.
I tightened things up so we don't use the req
object at all any more.
8542309
to
11e9769
Compare
@davidvgalbraith I addressed all your comments, rebased, and then also made some additional changes. Everything from 0c7b30e onward is new. Seems like we're close enough that it would make sense to merge this sooner rather than later and then start the process of converting the adapters. Once this merges I'd probably want to cut a new juttle release so we have something to base the adapter rework off of. |
this.emit_eof(); | ||
} else { | ||
this.reading.then(() => { | ||
this.emit_eof(); |
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.
This will emit 2 EOFs if the read hits an error due to line 237. I don't think that's a big deal, though.
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.
Good point -- that doesn't seem like a good thing.
Even worse, I noticed that if there is a pending call into the scheduler that never gets cancelled or cleaned up.
+1 |
|
||
toNative(points); | ||
|
||
return points; |
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.
This can just return toNative(points)
.
// Returns a promise once the adapter has completed writing all the data and | ||
// the flowgraph can be shut down. | ||
eof() { | ||
throw new Error('write must be implemented'); |
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.
Should be "eof must be implemented".
|
||
eof: function() { | ||
eof() { |
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.
The contract says we're supposed to return a promise here.
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.
The base class uses Promise.try
so I didn't see any need here.
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.
Well then we should change the contract. Are we synchronously done here after calling this.serializer.done()
anyway?
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.
Well that seems like a good thing to do.
7bcf95b
to
cf9a0bf
Compare
So they are supported by any adapter.
Code coverage slipped a bit on functions due to the fact that the new read and write implementations have shim support for the old adapters that isn't being exercised as part of the tests. This can bump back up once we remove the legacy adapter support.
The previous model in which adapters would convey statically whether or not they should behave as a timed source or an untimed source proved too limiting in practice, since it didn't lend itself well to cases like influx or sql in which the behavior actually depends on the other options given to the read call. Instead, change things to give adapters more control over their desired behavior for time options by adding two new API hooks, defaultTimeRange() to return defaults for from and to, and periodicLiveRead() which indicates to the read proc whether to do the pseudo-live pattern for reading or leave it up to the adapter to manage its own paging through time.
The previous code was stomping any location info that the adapter put into the errors, so instead only add it if it's missing.
Add generic errors for procs to use when they encounter incompatible option combinations. Rework emit to use these instead of a bunch of one-off error strings.
The rework to use the base class ticking behavior conflicted with the concurrent change to not add timestamps to the -points argument, so reconcile these two changes.
01d09ac
to
ab21596
Compare
@juttle/developers I took another pass at changing the API to better support adapters that wabt to determine their behavior relating to the time options at runtime instead of statically. I also rebased to reconcile all the latest changes to the various builtin adapters (thanks rodney) and addressed the various comments in the PR history. I think this is ready to merge so we can get on with porting the actual adapters. |
}) | ||
.catch(function(err) { | ||
self.trigger('error', self.runtime_error('RT-INTERNAL-ERROR', { | ||
.catch((err) => { |
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.
This catch
can go after the following then
.
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.
Changed
+1 |
Dave said "ship it red!" |
I'll look at that file adapter test failure... |
This PR is a big rework of the implementation of
read
andwrite
and the adapter API.Instead instead of having adapters directly implement procs, add normal proc implementations of read and write along with a new set of abstract base classes for adapters that have a cleaner contract that is more isolated from the details of the rest of the runtime.
Also convert the test adapters and the file adapter to use the new API and add a new test adapter that simulates a timeseries database to test the logic for reading pseudo-live.
More details are in the individual commit messages.
Not yet ready for merge but initial review would be appreciated.
To do before merge:
Fixes #168.