Repository navigation
Expand file tree
/
Copy pathconfig.py
More file actions
60 lines (48 loc) · 1.86 KB
/
Copy pathconfig.py
File metadata and controls
60 lines (48 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from temporalio.converter import DataConverter
from codec import EncryptionCodec, NexusCodec
from service import (
COMPRESSED_ENCRYPTED_1_ENDPOINT,
COMPRESSED_ENCRYPTED_2_ENDPOINT,
ENCRYPTED_1_ENDPOINT,
ENCRYPTED_2_ENDPOINT,
)
# These keys are for this local example. Load production keys from secure storage.
COMPRESSED_ENCRYPTED_KEY_1 = b"handler-a-key-01"
COMPRESSED_ENCRYPTED_KEY_2 = b"handler-a-key-02"
ENCRYPTED_KEY_1 = b"handler-b-key-01"
ENCRYPTED_KEY_2 = b"handler-b-key-02"
CALLER_WORKFLOW_KEY = b"sample-key-C-123"
def _compressed_encrypted_codecs() -> dict[str, EncryptionCodec]:
return {
COMPRESSED_ENCRYPTED_1_ENDPOINT: EncryptionCodec(
"compressed-encrypted-1", COMPRESSED_ENCRYPTED_KEY_1, compress=True
),
COMPRESSED_ENCRYPTED_2_ENDPOINT: EncryptionCodec(
"compressed-encrypted-2", COMPRESSED_ENCRYPTED_KEY_2, compress=True
),
}
def _encrypted_codecs() -> dict[str, EncryptionCodec]:
return {
ENCRYPTED_1_ENDPOINT: EncryptionCodec("encrypted-1", ENCRYPTED_KEY_1),
ENCRYPTED_2_ENDPOINT: EncryptionCodec("encrypted-2", ENCRYPTED_KEY_2),
}
def caller_data_converter() -> DataConverter:
return DataConverter(
payload_codec=NexusCodec(
{**_compressed_encrypted_codecs(), **_encrypted_codecs()},
EncryptionCodec("caller-workflow", CALLER_WORKFLOW_KEY),
)
)
def compressed_encrypted_data_converter() -> DataConverter:
return DataConverter(
payload_codec=NexusCodec(
_compressed_encrypted_codecs(),
EncryptionCodec("compressed-encrypted-1", COMPRESSED_ENCRYPTED_KEY_1),
)
)
def encrypted_data_converter() -> DataConverter:
return DataConverter(
payload_codec=NexusCodec(
_encrypted_codecs(), EncryptionCodec("encrypted-1", ENCRYPTED_KEY_1)
)
)