-
Notifications
You must be signed in to change notification settings - Fork 21
/
deployment_manager_pubsub_bitcoin.py
39 lines (35 loc) · 1.5 KB
/
deployment_manager_pubsub_bitcoin.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
def GenerateConfig(context):
resources = []
chains = ['bitcoin', 'bitcoin_cash', 'dogecoin', 'litecoin', 'dash', 'zcash']
entity_types = ['blocks', 'transactions']
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}