|
1 | | -# Copyright 2017, Google LLC All rights reserved. |
| 1 | +# Copyright 2019, Google LLC All rights reserved. |
2 | 2 | # |
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | # you may not use this file except in compliance with the License. |
@@ -53,14 +53,45 @@ class Client(object): |
53 | 53 | settings for batch publishing. |
54 | 54 | kwargs (dict): Any additional arguments provided are sent as keyword |
55 | 55 | arguments to the underlying |
56 | | - :class:`~.gapic.pubsub.v1.publisher_client.PublisherClient`. |
57 | | - Generally, you should not need to set additional keyword arguments. |
58 | | - Before being passed along to the GAPIC constructor, a channel may |
59 | | - be added if ``credentials`` are passed explicitly or if the |
60 | | - Pub / Sub emulator is detected as running. |
61 | | - Regional endpoints can be set via ``client_options`` that takes a |
62 | | - single key-value pair that defines the endpoint, i.e. |
63 | | - ``client_options={"api_endpoint": REGIONAL_ENDPOINT}``. |
| 56 | + :class:`~google.cloud.pubsub_v1.gapic.publisher_client.PublisherClient`. |
| 57 | + Generally you should not need to set additional keyword |
| 58 | + arguments. Optionally, publish retry settings can be set via |
| 59 | + ``client_config`` where user-provided retry configurations are |
| 60 | + applied to default retry settings. And regional endpoints can be |
| 61 | + set via ``client_options`` that takes a single key-value pair that |
| 62 | + defines the endpoint. |
| 63 | +
|
| 64 | + Example: |
| 65 | +
|
| 66 | + .. code-block:: python |
| 67 | +
|
| 68 | + from google.cloud import pubsub_v1 |
| 69 | +
|
| 70 | + publisher_client = pubsub_v1.PublisherClient( |
| 71 | + # Optional |
| 72 | + batch_settings = pubsub_v1.types.BatchSettings( |
| 73 | + max_bytes=1024, # One kilobyte |
| 74 | + max_latency=1, # One second |
| 75 | + ), |
| 76 | +
|
| 77 | + # Optional |
| 78 | + client_config = { |
| 79 | + "interfaces": { |
| 80 | + "google.pubsub.v1.Publisher": { |
| 81 | + "retry_params": { |
| 82 | + "messaging": { |
| 83 | + 'total_timeout_millis': 650000, # default: 600000 |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + }, |
| 89 | +
|
| 90 | + # Optional |
| 91 | + client_options = { |
| 92 | + "api_endpoint": REGIONAL_ENDPOINT |
| 93 | + } |
| 94 | + ) |
64 | 95 | """ |
65 | 96 |
|
66 | 97 | _batch_class = thread.Batch |
@@ -117,7 +148,8 @@ def from_service_account_file(cls, filename, batch_settings=(), **kwargs): |
117 | 148 | kwargs: Additional arguments to pass to the constructor. |
118 | 149 |
|
119 | 150 | Returns: |
120 | | - PublisherClient: The constructed client. |
| 151 | + A Publisher :class:`~google.cloud.pubsub_v1.publisher.client.Client` |
| 152 | + instance that is the constructed client. |
121 | 153 | """ |
122 | 154 | credentials = service_account.Credentials.from_service_account_file(filename) |
123 | 155 | kwargs["credentials"] = credentials |
@@ -206,9 +238,10 @@ def publish(self, topic, data, **attrs): |
206 | 238 | sent as metadata. (These may be text strings or byte strings.) |
207 | 239 |
|
208 | 240 | Returns: |
209 | | - ~google.api_core.future.Future: An object conforming to the |
210 | | - ``concurrent.futures.Future`` interface (but not an instance |
211 | | - of that class). |
| 241 | + A :class:`~google.cloud.pubsub_v1.publisher.futures.Future` |
| 242 | + instance that conforms to Python Standard library's |
| 243 | + :class:`~concurrent.futures.Future` interface (but not an |
| 244 | + instance of that class). |
212 | 245 | """ |
213 | 246 | # Sanity check: Is the data being sent as a bytestring? |
214 | 247 | # If it is literally anything else, complain loudly about it. |
|
0 commit comments