Skip to content

Commit

Permalink
fix: update pubsub_context to correctly modify proto map fields (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpcollins-google committed Oct 7, 2020
1 parent d631626 commit 860c443
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions google/cloud/pubsublite/internal/wire/pubsub_context.py
Expand Up @@ -23,11 +23,11 @@ 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")
context.fields["language"].string_value = "PYTHON"
if framework:
context.fields["framework"] = struct_pb2.Value(string_value=framework)
context.fields["framework"].string_value = framework
version = _version()
context.fields["major_version"] = struct_pb2.Value(number_value=version.major)
context.fields["minor_version"] = struct_pb2.Value(number_value=version.minor)
context.fields["major_version"].number_value = version.major
context.fields["minor_version"].number_value = version.minor
encoded = b64encode(context.SerializeToString()).decode("utf-8")
return {"x-goog-pubsub-context": encoded}

0 comments on commit 860c443

Please sign in to comment.