-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): consistently generated session ids #531
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing necessary to change in here, quite clean and the change will allow us to apply specific logic on every internal use-case.
A general advise is use and enforce name parameters, it avoids errors when refactoring and increases intelligibility quite much.
@Archento I have modified the code so that it is not coupled with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Proposed Changes
Summary of the Problem
Internally, the uAgents have a concept of an Internal and external context variants. The internal one was created and cached inside the agent object.
Due to the nature of the cached internal context, this would leads to some interesting outcomes specifically for the session id. In some cases (like a startup event) the session id can be
None
. Additionally, some session ids values are cached depending on the order of how handlers are called.All of the above means that being able to reliable use the session id for chaining is difficult.
Consistent Generation of Session IDs
Semantically, this change ensures that the following rule is always applied:
The session id is always taken from the triggering envelope, when this is not possible a new session id is always generated
As a result of this, the code is updated so that the context is always built before it is used. This was always the case for the external context, but now is true for the internal context as well. This consistency eliminates some of the quirky cached behaviour that we had beforehand.
More importantly, however, this ensures that the session id can be used by the agent code to track responses from chained sessions.
Linked Issues
n/a
Types of changes
What type of change does this pull request make (put an
x
in the boxes that apply)?Checklist
Put an
x
in the boxes that apply:If applicable
Further comments
[if this is a relatively large or complex change, kick off a discussion by explaining why you chose the solution you did, what alternatives you considered, etc...]