Skip to content

Commit

Permalink
fix: Add documentation for many files.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpcollins-google committed Aug 12, 2020
1 parent d92622d commit 0dc6b3b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions google/cloud/pubsublite/internal/wire/make_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ def make_publisher(
credentials: Optional[Credentials] = None,
client_options: Optional[ClientOptions] = None,
metadata: Optional[Mapping[str, str]] = None) -> Publisher:
"""
Make a new publisher for the given topic.
Args:
topic: The topic to publish to.
batching_delay_secs: The delay in seconds to batch messages. The default is reasonable for most cases.
credentials: The credentials to use to connect. GOOGLE_DEFAULT_CREDENTIALS is used if None.
client_options: Other options to pass to the client. Note that if you pass any you must set api_endpoint.
metadata: Additional metadata to send with the RPC.
Returns:
A new Publisher.
Throws:
GoogleApiCallException on any error determining topic structure.
"""
if client_options is None:
client_options = ClientOptions(api_endpoint=regional_endpoint(topic.location.region))
client = async_client.PublisherServiceAsyncClient(
Expand Down
3 changes: 3 additions & 0 deletions google/cloud/pubsublite/internal/wire/merge_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


def merge_metadata(a: Optional[Mapping[str, str]], b: Optional[Mapping[str, str]]) -> Mapping[str, str]:
"""
Merge the two sets of metadata if either exists. The second map overwrites the first.
"""
result = {}
if a:
for k, v in a.items():
Expand Down
3 changes: 3 additions & 0 deletions google/cloud/pubsublite/internal/wire/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@


class Publisher(ABC):
"""
A Pub/Sub Lite asynchronous wire protocol publisher.
"""
@abstractmethod
async def __aenter__(self):
raise NotImplementedError()
Expand Down
1 change: 1 addition & 0 deletions google/cloud/pubsublite/internal/wire/pubsub_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def _version() -> _Semver:


def pubsub_context(framework: Optional[str] = None) -> Mapping[str, str]:
"""Construct the pubsub context mapping for the given framework."""
context = struct_pb2.Struct()
context.fields["language"] = struct_pb2.Value(string_value="PYTHON")
if framework:
Expand Down

0 comments on commit 0dc6b3b

Please sign in to comment.