jcelliott / turnpike

Go implementation of a WAMP (Web Application Messaging Protocol) client and router
MIT License
258 stars 88 forks source link

Persistent state between RPC requests #138

Open richardartoul opened 7 years ago

richardartoul commented 7 years ago

I know this isn't part of the WAMP spec, but it would be a nice feature to support persisting some amount of state between RPC requests. The example I have in mind is that I'm authenticating users WAMP sessions with API keys. Once the WAMP connection is established, I don't want to have to hit the database everytime I receive an RPC to lookup which user is associated with the API key.

If I was using traditional websockets it would be trivial to cache the user in local scope for some amount of time such that only the associated websocket connection has access to it.

The existing turnpike interface makes doing this fairly difficult.

What are your thoughts? I'm happy to take a stab at implementing the feature, just want confirmation that it would be considered useful / merged if I did so.

richardartoul commented 7 years ago

The alternative to building a way of storing state with the sessions would be to make it easier to expose the session id in the RPC method. I think the way this is intended to work in Turnpike is by having the client send a "disclose_me" option, but this field appears to be deprecated (the Autobahn Python library no longer supports it for example), so this doesn't leave a lot of room for doing this any other way.