I've read all this doc : https://cloud.google.com/pubsub/docs/publisher there are 3 examples:
I want to combine example 2 and 3 into single so publishing with batch mode works with retrying requests. How can I do this?
The object pubsub_v1.PublisherClient
accepts both parameters as input for the construction.
By including the two optional parameters batch_settings
and client_config
you can configure batch mode with retrying requests.
from google.cloud import pubsub_v1
publisher_client = pubsub_v1.PublisherClient(
# Optional Batch param
batch_settings = pubsub_v1.types.BatchSettings(
max_bytes=1024, # One kilobyte
max_latency=1, # One second
),
# Optional Retrying param
client_config = {
"interfaces": {
"google.pubsub.v1.Publisher": {
"retry_params": {
"messaging": {
'total_timeout_millis': 650000, # default: 600000
}
}
}
}
},
# Optional
client_options = {
"api_endpoint": REGIONAL_ENDPOINT
}
)