Introducing sessions (internally) #276
Replies: 1 comment 1 reply
-
Hi there Soós, Sorry for the late reply, this discussion slipped through the cracks. I hope you're still interested in this. I like the idea of structuring and simplifying the connection part, you're right in that there have been quite a lot of issues on this! @frederikaalund proposed something similar a while ago ("user friendly layer on top of a strict layer") 👍 One thing I'm not sure about is how strictly we can actually separate these things in practice. The queue of incoming messages is for example still accessible after a connection failure, while there are still messages inside. I haven't used the typestate pattern before, so it could also just be that I'm not understanding it well enough, yet. I would be happy if you drafted something up! I'm currently experimenting with reconnection myself. I would be happy to collaborate on this and/or hear your thoughts 😊 |
Beta Was this translation helpful? Give feedback.
-
Hi. Love the project. I'd like to use it in a tool I'm building. Unfortunately the recent issues with the context reusability not working properly (#269) makes it cumbersome for me to build it into my project. I've also noticed another context related state management issue (#268) and that there's is a plan to internally implement automatic reconnection.
I'd like to propose an internal structural change. Right now the client owns everything. Both the connection parameters and all the state that is only meant to be used with a working connection. We could create a Session class or ConnectedClient class or whatever to represent the connected state and let it handle the following:
This would simplify the parts where the client state has to be validated. There wouldn't be a way to access messages outside an active connection for example. The auto reconnect feature could be implemented inside the Client then. The Client itself would remain clean in the sense that all the session related state would be destroyed when the context manager exists. I've just started looking at the code, so I'm not familiar with some of the nuances. I'd be willing to implement the changes with automatic reconnection too.
Beta Was this translation helpful? Give feedback.
All reactions