Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Python: expose 'channel' as a property of the transport.
Browse files Browse the repository at this point in the history
Permits app developers to e.g. perform explicit 'close' on channels for
dynamically-created clients.

See: googleapis/google-cloud-python#5523.

Closes #2337.
  • Loading branch information
tseaver committed Oct 31, 2018
1 parent 0be30d8 commit ce8ac96
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/resources/com/google/api/codegen/py/transport.snip
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
credentials=credentials,
)

self._channel = channel

@# gRPC uses objects called "stubs" that are bound to the
@# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -92,6 +94,15 @@
scopes=cls._OAUTH_SCOPES,
)

@@property
def channel(self):
"""The gRPC channel used by the transport.

Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

# ----- RPC CALLS -----
@join apiMethod : api.apiMethods on BREAK.add(BREAK)
@@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3527,6 +3527,8 @@ class LibraryServiceGrpcTransport(object):
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -3563,6 +3565,15 @@ class LibraryServiceGrpcTransport(object):
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.

Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def create_shelf(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,8 @@ class DecrementerServiceGrpcTransport(object):
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -1383,6 +1385,15 @@ class DecrementerServiceGrpcTransport(object):
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.

Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def decrement(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down Expand Up @@ -1461,6 +1472,8 @@ class IncrementerServiceGrpcTransport(object):
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -1492,6 +1505,15 @@ class IncrementerServiceGrpcTransport(object):
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.

Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def increment(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,8 @@ class NoTemplatesApiServiceGrpcTransport(object):
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -1100,6 +1102,15 @@ class NoTemplatesApiServiceGrpcTransport(object):
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.

Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def increment(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down

0 comments on commit ce8ac96

Please sign in to comment.