diff --git a/google/pubsub_v1/services/schema_service/client.py b/google/pubsub_v1/services/schema_service/client.py index b150b2681..2def4613f 100644 --- a/google/pubsub_v1/services/schema_service/client.py +++ b/google/pubsub_v1/services/schema_service/client.py @@ -18,6 +18,8 @@ import re from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources +import grpc +import functools from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -411,6 +413,15 @@ def __init__( ) Transport = type(self).get_transport_class(transport) + + emulator_host = os.environ.get("PUBSUB_EMULATOR_HOST") + if emulator_host: + if issubclass(Transport, type(self)._transport_registry["grpc"]): + channel = grpc.insecure_channel(target=emulator_host) + else: + channel = grpc.aio.insecure_channel(target=emulator_host) + Transport = functools.partial(Transport, channel=channel) + self._transport = Transport( credentials=credentials, credentials_file=client_options.credentials_file,