-
Notifications
You must be signed in to change notification settings - Fork 7
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
Tenant layer introduction to library #549
Tenant layer introduction to library #549
Conversation
This will break many things ... it has to be implemented differently. |
asab/library/contextvars.py
Outdated
from contextvars import ContextVar | ||
|
||
# Define a context variable for tenant | ||
tenant_var = ContextVar('tenant', default=None) |
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.
Move this into Zookeeper provider.
There has to be an official and documented way how an user can set it.
asab/library/providers/abc.py
Outdated
@@ -53,3 +53,33 @@ async def subscribe(self, path: str): | |||
|
|||
""" | |||
raise NotImplementedError("{}.subscribe()".format(self.__class__.__name__)) | |||
|
|||
async def tenant_exists(self): |
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.
This method is not needed.
asab/library/providers/zookeeper.py
Outdated
tenant = tenant_var.get() | ||
|
||
if tenant not in [None, ""]: | ||
node_path = self.BasePath + "/.tenants/" + tenant + path |
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.
Yo need to do two "hits" to zookeeper - first into /.tenants/....
and if the item doesn't exist there, then you do hit the "normal" path.
There are two ways how a microservice can set "tenant" into zookeeper library provider:
Snippet of the handler code:
|
Please proceed with a merge @mithunbharadwaj |
Please remove |
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.
See the comment.
asab/library/providers/zookeeper.py
Outdated
@@ -300,13 +300,19 @@ async def list(self, path: str) -> list: | |||
global_nodes = await self.Zookeeper.get_children(global_node_path) or [] | |||
global_items = await self.process_nodes(global_nodes, path) | |||
|
|||
<<<<<<< HEAD |
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.
?? ... likely untested code
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.
No! I am synchronising this PR to latest master.
Let me know when this is ready for a review, please. |
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.
From the workshop:
- Remove
tenant
param from LibraryService calls:read
,open
,list
andexport
... tenant must be extracted from theTenantContextVar
-
check_disabled
keeps the tenant param, it is a responsibility of the caller to obtaintenant
(ie fromTenantContextVar
) or removetenant
param too in a same way as above point - Coordinate with other team members so that this breaking change is adopted in every relevant microservice (use a spreadsheet for that)
asab/library/providers/zookeeper.py
Outdated
from contextvars import ContextVar | ||
|
||
# Define a context variable for tenant | ||
TenantContextVar = ContextVar('tenant', default=None) |
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.
This MAY go into asab.web.auth
... discuss this with @byewokko
Let me know when this is ready for re-review. |
No description provided.