Skip to content

Instantly share code, notes, and snippets.

@PouyaEsmaeili
Created January 3, 2023 22:17
Show Gist options
  • Save PouyaEsmaeili/3758d0fac4c8709c8b0391a971959627 to your computer and use it in GitHub Desktop.
Save PouyaEsmaeili/3758d0fac4c8709c8b0391a971959627 to your computer and use it in GitHub Desktop.
def _get_lock_name(self, client_id: str, resource_id: str) -> str:
if self._limit_per_client:
return f'{resource_id}-lock'
return f'{client_id}-{resource_id}-lock'
def _get_log_pattern(self, client_id: str, resource_id: str) -> str:
if self._limit_per_client:
return f'{resource_id}-*'
return f'{client_id}-{resource_id}-*'
def _generate_log_name(self, client_id: str, resource_id: str) -> str:
padding = ''.join(
choices(
ascii_uppercase + ascii_lowercase,
k=10,
)
)
if self._limit_per_client:
return f'{resource_id}-{padding}'
return f'{client_id}-{resource_id}-{padding}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment