-
Notifications
You must be signed in to change notification settings - Fork 44
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
Use optional parameters instead of option in interfaces #130
Comments
Do you use different timeout on every call? The common use case is to have a few timeout values that are specified as fields, and pass them around. In case when timeout is always the same, it can be set directly via HOCON |
Nah, it was mostly when I didn't care to specify a timeout, but I switched to using the operator more instead which passes If this was implemented as optional parameters it would look a little better when piping the parameter to it. myMsg |> tellable.Ask vs myMsg
|> fun msg -> tellable <? msg I ended up just making a little module to do this for me: [<RequireQualifiedAccess>]
module Actor =
let tell (actor: IActorRef<'Message>) (msg: 'Message) = actor <! msg
let ask (actor: IActorRef<'Message>) (msg: 'Message) = actor <? msg |
If your goal if to pipe message from the left to actor on the right you could as well define: |
That's a good idea! Funny enough right above that section I had a definition for Any opposition to adding a Although it's a bit "off" because |
@Shmew I'm not really sure if incorporating this into library is a good idea. While anyone can add this operator in their own library and use in scope of their own project, IMO adding custom operators that are not obvious deepens confusion of developers. Even Re. sending Async to an actor - tell/ask are specifically designed to convey message passing behavior. |
Yeah that makes sense. So really it just comes back to making the timeouts optional rather than needing |
On the akka JVM providing the timeout parameter to In C#/F# it's not that easy - the solution that would let us to have sane arg passing and still being able to use |
Yeah I get that, but is there a reason the second parameter needs to be explicitly I'm fine with keeping the API the way it is if it's your preference or there's a reason for it. I'm just having a hard time understanding the point you're trying to make. This would not be a breaking change and make piping a message to an actor a lot more ergonomic in cases where you don't need to give an explicit timeout. |
It's a little annoying to have to do add
Some
orNone
when calling instance methods for things likeICanTell<'Message>
. These can be written using optional parameters which makes the API a bit easier to consume.ICanTell<'Message>
could be rewritten as:I don't mind submitting a PR, let me know what you think.
The text was updated successfully, but these errors were encountered: