-
Notifications
You must be signed in to change notification settings - Fork 21
/
deployment_manager_pubsub_ethereum.py
44 lines (38 loc) · 1.57 KB
/
deployment_manager_pubsub_ethereum.py
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
def GenerateConfig(context):
resources = []
chains = ['ethereum']
entity_types = ['blocks', 'transactions', 'logs', 'token_transfers', 'traces', 'contracts', 'tokens']
for chain in chains:
topic_name_prefix = 'crypto_' + chain
subscription_name_prefix = 'crypto_' + chain + '.dataflow.bigquery'
# 7 days
message_retention_duration = '604800s'
for entity_type in entity_types:
topic_name = topic_name_prefix + '.' + entity_type
topic_resource_name = topic_name.replace('.', '-')
subscription_name = subscription_name_prefix + '.' + entity_type
subscription_resource_name = subscription_name.replace('.', '-')
resources.append({
'name': topic_resource_name,
'type': 'pubsub.v1.topic',
'properties': {
'topic': topic_name
}
})
resources.append({
'name': subscription_resource_name,
'type': 'pubsub.v1.subscription',
'properties': {
'subscription': subscription_name,
'topic': '$(ref.' + topic_resource_name + '.name)',
'ackDeadlineSeconds': 30,
'retainAckedMessages': True,
'messageRetentionDuration': message_retention_duration,
'expirationPolicy': {
}
}
})
return {'resources': resources}
if __name__ == '__main__':
res = GenerateConfig(None)
print(res)