-
Notifications
You must be signed in to change notification settings - Fork 27
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
Simpler client request interface? #356
Comments
@scott-gibson-sociomantic @don-clugston-sociomantic @daniel-zullo-sociomantic as the primary users of the neo clients, any thoughts on this? |
in the case of fatal errors As for retry behaviour, i'm unsure how to approach this as my applications have different requirements (some should always retry, some can retry a few times then decide not to continue). As long as these apps can have control over the behaviour then perhaps a simple request wrapper would suffice. In either case i think we might need a greater sample size of usage until we can try to simplify. |
Right, that could work. It'd require quite a bit of reworking of the way things are currently set up, but I think it'd present a nicer API to the end-user.
Indeed, this is the tricky bit. I imagine that one-shot requests like this that could be retried would have some additional arguments to configure this behaviour. Something like this maybe: DhtClient.Neo.Get.RetryConfig retry;
retry.max_retries = 3;
dht_client.get("channel", key, retry); |
Though... it'd mean a union inside a union, which might not be that fun to deal with. |
I agree with this point. We don't have a large enough usage sample yet to be able to make a good judgement. I just wanted to get some ideas going, in advance. |
How about having the taskblocking call return void[] get_buf;
auto result = this.dht.blocking.get("channel", 0x1234567812345678,
get_buf);
if ( result.succeeded )
{
if ( result.value.length )
// Received the requested record.
else
// Key not found in DHT.
}
else {
with (result.error) switch (result.error) {
case node_disconnected:
schedule_retry(); break;
}
} |
That would be an improvement to the current API, yes. It wouldn't address the point about most apps (probably) ending up implementing the same error handling logic, though, which is kind of my main problem with the current approach. |
Thoughts on implementing this:
|
Scott;
These cases are not quite the same. Some of those, such as Gavin:
I don't think that's true. For apps like shore, where the data is not very valuable, the task blocking API is perfect. |
You might want to consider defining a generic default behaviour for retrying a request and error handling given the user the flexibility to implement their own ones for special/corner cases. From the user perspective this could help avoiding code duplication and also reduce the focus in the logic of handling a request and mainly deal with the business logic on application/client side instead. |
Yeah, I certainly wouldn't envisage removing the current "full info, full power" API. |
Interesting. I didn't expect anyone to use the blocking API without the notifiers in anything but simple tests. The danger of it is that error logging will be very unhelpful. |
Don, maybe we're getting mixed up. There are three ways of assigning many requests:
3 isn't recommended for use in real apps, but 2 is. |
Theoretically the node could be reverted or updated that would resolved the unsupported request. An aggregation app continue running aggregating data in that case. |
(This issue possibly doesn't apply to swarm specifically, but might have to be implemented independently in each *proto. Writing it here initially, just to put it in a central location.)
The current recommended client usage looks something like this (taking the DHT client's Get request as an example):
This is of the "precise knowledge gives great control" variety of API: it provides the user with full information about what happened, allowing them to decide what to do, but does not implement any default behaviour.
On the other hand, we have the simplified,
Task
-blocking API, which looks like this:This is the opposite extreme: it only provides the user with ultra minimal information about what happened, and still doesn't implement any default error handling behaviour.
It seems to me that:
Something like this, for DHT Get:
The text was updated successfully, but these errors were encountered: