Reputation: 3352
I'm using network-conduit and runTCPServer to power my stranded server.
In this case:
-- | Helper which represents a conduit chain for each client connection
serverApp :: Application SessionIO
serverApp appdata = do
-- blah blah blah initializer code
appSource appdata $$ decoder =$= protocol =$= encoder =$ appSink appdata
...
-- | Handles an input stream of 'Packet' objects and dispatches them
protocol :: Conduit Packet SessionIO Packet
protocol = undefined
How often does protocol get executed? If I wanted something to be timely executed every so often on a client socket would it be safe to put its logic in protocol, or is it only called each time data actually reaches it?
I would appreciate if you explained the way the conduit "callbacks" work. :)
Regards.
Upvotes: 1
Views: 230
Reputation: 14506
The Conduit Overview over at FP Complete explains the flow control of Conduit: specifically that conduits only go up the chain when data is needed. So if you're relying on time-based side-effects, relying on a conduit being called is not the way to do that.
This does depend a lot on your use case and the structure of your conduit chain, however, because you could put delays into a Conduit
to rate-limit it or something similar.
Upvotes: 2