Skip to content
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

cache service connector tokens and respect expiry time #89

Open
hmoffatt opened this issue Jul 22, 2022 · 2 comments
Open

cache service connector tokens and respect expiry time #89

hmoffatt opened this issue Jul 22, 2022 · 2 comments

Comments

@hmoffatt
Copy link
Contributor

ServiceConnector.get_access_token caches access tokens within the ServiceConnector object in case of repeated service calls, but firstly it doesn't handle them expiring, and secondly it would be useful to be able to store these in the cache and use them across instances, if still valid.

@dmitry-viskov
Copy link
Owner

dmitry-viskov commented Sep 5, 2022

@hmoffatt

but firstly it doesn't handle them expiring,

Usually ServiceConnector instance (together with token) recreates on each request so there is no need to check expiration because in such case we may trust to external platform + usually ordinary request longs no longer than few seconds (ideally no longer than 0.1-0.2sec) so there is no need in such validation.
Problems could be in case of using instances in daemon mode but can't imagine situation where you operate with the same message_launch instance for a long time. Consequently ServiceConnector will be recreated together with the new message_launch instance.

it would be useful to be able to store these in the cache and use them across instances, if still valid.

Ideally there should be the separate background process that is responsible for creating/prolongation tokens only (based on cron or celery beat). There should be considered different variants of caches/frameworks... So i think this task is out of scope of this library for now.

@hmoffatt
Copy link
Contributor Author

hmoffatt commented Sep 9, 2022

I was thinking of the case where you need to update a lot of grades at once. You don't want to re-create the service connector for every grade because then it will request a new token each time, but also if you keep the token too long it may expire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants