88import gzip
99import logging
1010import uuid
11- from typing import Optional
11+ from typing import Any , Optional
1212
1313from azure .storage .blob import BlobServiceClient
1414from azure .storage .blob .aio import BlobServiceClient as AsyncBlobServiceClient
1515
16- from durabletask .extensions .azure_blob_payloads .options import BlobPayloadStoreOptions
1716from durabletask .payload .store import LargePayloadStorageOptions , PayloadStore
1817
1918logger = logging .getLogger ("durabletask-blobpayloads" )
@@ -36,59 +35,66 @@ class BlobPayloadStore(PayloadStore):
3635 account_url: Azure Storage account URL. Must be combined with
3736 *credential*.
3837 credential: A ``TokenCredential`` for token-based auth.
39- options: Additional configuration. If not provided, defaults
40- are used.
38+ container_name: Blob container for externalized payloads.
39+ threshold_bytes: Payloads larger than this are externalized.
40+ max_stored_payload_bytes: Maximum externalized payload size.
41+ enable_compression: GZip-compress payloads before uploading.
42+ api_version: Azure Storage API version override (useful for
43+ Azurite compatibility).
4144 """
4245
4346 def __init__ (
4447 self ,
4548 * ,
4649 connection_string : Optional [str ] = None ,
4750 account_url : Optional [str ] = None ,
48- credential : Optional [object ] = None ,
49- options : Optional [BlobPayloadStoreOptions ] = None ,
51+ credential : Any = None ,
52+ container_name : str = "durabletask-payloads" ,
53+ threshold_bytes : int = 900_000 ,
54+ max_stored_payload_bytes : int = 10 * 1024 * 1024 ,
55+ enable_compression : bool = True ,
56+ api_version : Optional [str ] = None ,
5057 ):
51- if options is None :
52- options = BlobPayloadStoreOptions (
53- connection_string = connection_string ,
54- account_url = account_url ,
55- credential = credential ,
56- )
57-
58- if not options .connection_string and not options .account_url :
58+ if not connection_string and not account_url :
5959 raise ValueError (
6060 "Either 'connection_string' or 'account_url' (with 'credential') must be provided."
6161 )
6262
63- self ._options = options
64- self ._container_name = options .container_name
63+ self ._options = LargePayloadStorageOptions (
64+ threshold_bytes = threshold_bytes ,
65+ max_stored_payload_bytes = max_stored_payload_bytes ,
66+ enable_compression = enable_compression ,
67+ )
68+ self ._container_name = container_name
6569
6670 # Optional kwargs shared by both sync and async clients.
6771 extra_kwargs : dict = {}
68- if options . api_version :
69- extra_kwargs ["api_version" ] = options . api_version
72+ if api_version :
73+ extra_kwargs ["api_version" ] = api_version
7074
7175 # Build sync client
72- if options . connection_string :
76+ if connection_string :
7377 self ._blob_service_client = BlobServiceClient .from_connection_string (
74- options . connection_string , ** extra_kwargs ,
78+ connection_string , ** extra_kwargs ,
7579 )
7680 else :
81+ assert account_url is not None # guaranteed by validation above
7782 self ._blob_service_client = BlobServiceClient (
78- account_url = options . account_url ,
79- credential = options . credential ,
83+ account_url = account_url ,
84+ credential = credential ,
8085 ** extra_kwargs ,
8186 )
8287
8388 # Build async client
84- if options . connection_string :
89+ if connection_string :
8590 self ._async_blob_service_client = AsyncBlobServiceClient .from_connection_string (
86- options . connection_string , ** extra_kwargs ,
91+ connection_string , ** extra_kwargs ,
8792 )
8893 else :
94+ assert account_url is not None # guaranteed by validation above
8995 self ._async_blob_service_client = AsyncBlobServiceClient (
90- account_url = options . account_url ,
91- credential = options . credential ,
96+ account_url = account_url ,
97+ credential = credential ,
9298 ** extra_kwargs ,
9399 )
94100
0 commit comments