mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-17 12:28:07 +00:00
cache tokens in memory forever (#195)
This commit is contained in:
@ -22,12 +22,12 @@ from msrestazure.tools import parse_resource_id
|
|||||||
from .monkeypatch import allow_more_workers, reduce_logging
|
from .monkeypatch import allow_more_workers, reduce_logging
|
||||||
|
|
||||||
|
|
||||||
@cached(ttl=60)
|
@cached
|
||||||
def get_msi() -> MSIAuthentication:
|
def get_msi() -> MSIAuthentication:
|
||||||
return MSIAuthentication()
|
return MSIAuthentication()
|
||||||
|
|
||||||
|
|
||||||
@cached(ttl=60)
|
@cached
|
||||||
def mgmt_client_factory(client_class: Any) -> Any:
|
def mgmt_client_factory(client_class: Any) -> Any:
|
||||||
allow_more_workers()
|
allow_more_workers()
|
||||||
reduce_logging()
|
reduce_logging()
|
||||||
@ -40,7 +40,7 @@ def mgmt_client_factory(client_class: Any) -> Any:
|
|||||||
return client_class(get_msi(), get_subscription())
|
return client_class(get_msi(), get_subscription())
|
||||||
|
|
||||||
|
|
||||||
@cached(ttl=60)
|
@cached
|
||||||
def get_storage_account_name_key(account_id: Optional[str] = None) -> Tuple[str, str]:
|
def get_storage_account_name_key(account_id: Optional[str] = None) -> Tuple[str, str]:
|
||||||
db_client = mgmt_client_factory(StorageManagementClient)
|
db_client = mgmt_client_factory(StorageManagementClient)
|
||||||
if account_id is None:
|
if account_id is None:
|
||||||
@ -56,7 +56,7 @@ def get_storage_account_name_key(account_id: Optional[str] = None) -> Tuple[str,
|
|||||||
return resource["name"], key
|
return resource["name"], key
|
||||||
|
|
||||||
|
|
||||||
@cached(ttl=60)
|
@cached
|
||||||
def get_blob_service(account_id: Optional[str] = None) -> BlockBlobService:
|
def get_blob_service(account_id: Optional[str] = None) -> BlockBlobService:
|
||||||
logging.debug("getting blob container (account_id: %s)", account_id)
|
logging.debug("getting blob container (account_id: %s)", account_id)
|
||||||
name, key = get_storage_account_name_key(account_id)
|
name, key = get_storage_account_name_key(account_id)
|
||||||
@ -101,7 +101,10 @@ def get_instance_url() -> str:
|
|||||||
return "https://%s.azurewebsites.net" % get_instance_name()
|
return "https://%s.azurewebsites.net" % get_instance_name()
|
||||||
|
|
||||||
|
|
||||||
@cached(ttl=60)
|
DAY_IN_SECONDS = 60 * 60 * 24
|
||||||
|
|
||||||
|
|
||||||
|
@cached(ttl=DAY_IN_SECONDS)
|
||||||
def get_regions() -> List[str]:
|
def get_regions() -> List[str]:
|
||||||
client = mgmt_client_factory(SubscriptionClient)
|
client = mgmt_client_factory(SubscriptionClient)
|
||||||
subscription = get_subscription()
|
subscription = get_subscription()
|
||||||
|
Reference in New Issue
Block a user