Open Daniel-Diaz opened 7 years ago
I'd defer to @kazu-yamamoto on this one. My gut feeling is that this is an internal structure that we wouldn't really want to expose, but I don't have a strong feeling here.
Generally, I don't mind exporting Counter
.
so that the user of the library can create a counter and keep track of it.
I don't understand this. So, please show me your patch.
@Daniel-Diaz Could you explain what you meant with the following?
so that the user of the library can create a counter and keep track of it.
Do you mean you want the user to be able to provide a TVar which will be adjusted exactly the same as the internal one? I don't think we want to expose the internal one, since it is relied on for graceful shutdowns.
@Daniel-Diaz Could you explain what you meant with the following?
so that the user of the library can create a counter and keep track of it.
Do you mean you want the user to be able to provide a TVar which will be adjusted exactly the same as the internal one? I don't think we want to expose the internal one, since it is relied on for graceful shutdowns.
Hello!
Wow, this is really old. I totally forgot about it!
I'm not completely sure what I meant by that sentence, but I definitely meant for the counter to be read-only. I guess a function to read it without exposing the type would also do.
Hello.
In an application I wanted to have available the number of open connections to the server. So I used
setOnOpen
andsetOnClose
together with a variable. This worked well.For some reason, I started reading warp's code, and realized that there is already a counter set up in those same places, but this counter is hidden from the user. I know keeping an additional counter is not a big deal, but maybe I just don't like redundant work.
In my opinion, the best way to solve this is to export the
Counter
type, but only with construction and accessing functions so that the user can't mess up the internals, and then addsetWithCounter :: Maybe Counter -> Settings -> Settings
so that the user of the library can create a counter and keep track of it. WhenNothing
is provided, warp would create the counter just like it does today.Well, this was my thought today. If it's regarded as a good idea, I can go ahead and write a patch.
Thanks.