cowboy
cowboy copied to clipboard
Question - Not possible to keep a connection state?
Hi!
I can't find any way to neither be informed about new connections - nor any possibility to update the initial state of a path handler. Is there no way to achieve any of this? If things are needed to be done once per connection (without process jump for each request)? Also we want to set DSCP for each connection - but at the same time be able to update the DSCP without restarting connections.
Is the only way currently to keep this externally e.g. an ets-table? Or wrap...
And for this we really need to be informed about when a connection is lost as well...
You can probably write a custom Ranch protocol that then defers to Cowboy's and do any modification you require there. For connection loss the process will exit so monitoring is probably the way to go.
For updating existing connections I don't think there's currently a built-in way to do this. On the other hand you can have your custom Ranch protocol pass the socket forward via the options and then write a stream handler that will process an arbitrary message to update the socket options.
Ok - thx. I assume custom protocol means wrapping cowboy:start as well then?
Just using ranch:start_listener
directly.