-
Notifications
You must be signed in to change notification settings - Fork 207
Rename vague has_state_changed to has_memory_state_changed (On Hold) #43
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
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.
tl;dr IMHO, we should get rid of this member variable all together.
I say that because I'd rather encourage persistent TokenCache implementations to take the following semantics:
- Modification Operations:
- Take a lock on the resource that's going to be persisted to. (i.e. use CrossPlatLock)
- See if there have been any changes to the cache since the last time the resource was loaded.
- If there's been a change, load into memory.
- Modify the cache as requested.
- Write the resource immediately.
- Release the lock taken in step one.
- Read Operations:
- Take a lock on the resource that was persisted. (i.e. use CrossPlatLock)
- See if there have been any changes to the cache since the last time the resource was loaded.
- If there's been a change, load it into memory.
- Collect the queried information.
- Release the lock taken in step one.
In both of the iia steps, the TokenCache implementations that I've written really need a timestamp with the last time they did a write operation. However, I think that logic is specific to TokenCache implementations that are backed by a file. For instance, a SQL or Consul backed implementation (not endorsing these implementations, just examples) may have little use for such a timestamp. For that reason, I would prefer to keep that timestamp out of this shared file and put it closer to the file-backed implementations instead.
The place where I could imagine implementations needing this state-change flag: if you wanted to batch together a few token adds into a single write-operation. I'm just now sure how common that is, and it would force the write logic out of the modification method and into a stand-alone "flush" method. This would give some of the persistent implementations a slightly different interface, and I don't want to do that unless it brings real value.
That said, this falls into the category of "strong opinion, weakly held" for me. If you've got a use-case in mind for it, feel free to disregard. :)
|
@marstr Thanks for your thoughtful input, and your sharing of that "Strong opinion, weakly held" approach! I think your suggestion makes sense. On the other hand, for the sake of completeness, I can also explain why the current The That experimental implementation was not merged, due to potential security review rejection on its lacking of encryption. In the real world people are rolling their own similar implementation anyway, and they were even sending their implementation to us in hoping that we would adopt it. Currently we provide no out-of-box token persistence, but provide a how-to recipe (which uses that So, that is the sad life of Lastly, the logic @marstr you described is for the other way around, from-disk-to-memory, which is suitable to the extension module you are currently working on. As long as we'll ship a feature-completed We will keep this PR on-hold for now, and revisit/retire it later when our extension module is completed. |
|
We don't see to have a strong need for this change right now. Closing. UPDATE: Also, downstream projects (like this one) already start picking up such public member. |
It caused some confusion when team members implementing token cache file state change feature in a subclass.