Improving the message sending APIs #1227
Replies: 3 comments 3 replies
-
Thanks for putting this together! It's always a good exercise to step back and get a new perspective on things. Since you asked for my thoughts, here are a couple of initial questions/considerations that I had while reading your post in no particular order. Regarding the Scheduled and delayed requests are not a thing at the moment. They are proposed, but the API would have non-intuitive implications. Requests have a relative timeout. Scheduled/delayed send ships the message after a timeout expires. So when should the timer on the request start? Consider: The proposed As a user, would I find this new API easier to learn or use? I think template parameters that change the signature of a function add another level of complexity: As a maintainer, I wonder whether the extra complexity introduced by more templates pays for the potential reduction in code. |
Beta Was this translation helpful? Give feedback.
-
That's not quite what I meant. 🙂 I should've picked just
I believe template parameters that change the signature of a function can make the API quite unwieldy to learn/navigate. Without I can see the approach work for However, the picture would change if we were to break up the API using a DSL. For example:
Or with a bit less method chaining:
The So basically, I see We do have actors that can On thing that makes this DSL quite intriguing for me is that there's only a single entrypoint into the dsl: @dominiklohmann, @riemass: thoughts? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback! I think we have consensus on the version with less chaining. I like that version better as well. 🙂
I think an unfinished builder shouldn't be a thing. Marking all steps
Technically not an issue, but doing it this way would break the symmetry with the dynamically typed API.
I think keeping them separate keeps the API a bit clearer, but I think keeping the terminology is probably for the better, i.e.,
Yeah, good point.
The current default is In any case, I think I'll get started on a first draft version of the new API and then we have something more concrete to discuss. |
Beta Was this translation helpful? Give feedback.
-
send/request
currently have a lot of duplicated code, because there are a lot of variations of the functions. I believe these are all of them:Now with #1222 there is another modifier proposed, which is
weak
. This also relates to #1189.I propose extending the
message_priority
template parameter to a more generalmessage_policy
template parameter, that can have either of the following values.anonymous
delayed
scheduled
weak
urgent
(as a replacement formessage_priority::high
)If necessary, the following policy parameters can be added to explicitly use the normal way:
onymous
(explicitly notanonymous
)instant
(explicitly neitherdelayed
norscheduled
)strong
(explicitly notweak
)nonurgent
(as a replacement formessage_priority::normal
)With these being a template argument it should be easy to detect impossible policy combinations at compile time to give proper error messages. E.g.,
self->request<anonymous>
cannot work, andself->send<delayed + scheduled>
doesn't make sense either.Not quite sure on the exact naming, but I wanted to get this idea out here. What do you think @Neverlord?
Beta Was this translation helpful? Give feedback.
All reactions