def __init__(self, address: str = None, channel: aiogrpc.Channel = None): if address: assert channel is None, "address and channel cannot both be specified" channel = gcs_utils.create_gcs_channel(address, aio=True) else: assert channel is not None, "One of address and channel must be specified" self._stub = gcs_service_pb2_grpc.InternalPubSubGcsServiceStub(channel)
def __init__( self, pubsub_channel_type, address: str = None, channel: grpc.Channel = None, ): super().__init__() if address: assert channel is None, \ "address and channel cannot both be specified" channel = gcs_utils.create_gcs_channel(address) else: assert channel is not None, \ "One of address and channel must be specified" # GRPC stub to GCS pubsub. self._stub = gcs_service_pb2_grpc.InternalPubSubGcsServiceStub(channel) # Type of the channel. self._channel = pubsub_channel_type # Protects multi-threaded read and write of self._queue. self._lock = threading.Lock() # A queue of received PubMessage. self._queue = deque() # Indicates whether the subscriber has closed. self._close = threading.Event()
def __init__(self, address: str = None, channel: aiogrpc.Channel = None): super().__init__() if address: assert channel is None, \ "address and channel cannot both be specified" channel = gcs_utils.create_gcs_channel(address, aio=True) else: assert channel is not None, \ "One of address and channel must be specified" # Message queue for each channel. self._messages = {} self._stub = gcs_service_pb2_grpc.InternalPubSubGcsServiceStub(channel)
def __init__(self, address: str = None, channel: aiogrpc.Channel = None): if address: assert channel is None, \ "address and channel cannot both be specified" channel = gcs_utils.create_gcs_channel(address, aio=True) else: assert channel is not None, \ "One of address and channel must be specified" self._stub = gcs_service_pb2_grpc.InternalPubSubGcsServiceStub(channel) self._subscriber_id = bytes( bytearray(random.getrandbits(8) for _ in range(28))) # Whether error info has been subscribed. self._subscribed_error = False # Buffer for holding error info. self._errors = deque()
def __init__( self, pubsub_channel_type, address: str = None, channel: aiogrpc.Channel = None, ): super().__init__() if address: assert channel is None, "address and channel cannot both be specified" channel = gcs_utils.create_gcs_channel(address, aio=True) else: assert channel is not None, "One of address and channel must be specified" # GRPC stub to GCS pubsub. self._stub = gcs_service_pb2_grpc.InternalPubSubGcsServiceStub(channel) # Type of the channel. self._channel = pubsub_channel_type # A queue of received PubMessage. self._queue = deque() # Indicates whether the subscriber has closed. self._close = asyncio.Event()
def __init__( self, address: str = None, channel: grpc.Channel = None, ): if address: assert channel is None, \ "address and channel cannot both be specified" channel = gcs_utils.create_gcs_channel(address) else: assert channel is not None, \ "One of address and channel must be specified" self._lock = threading.RLock() self._stub = gcs_service_pb2_grpc.InternalPubSubGcsServiceStub(channel) self._subscriber_id = bytes( bytearray(random.getrandbits(8) for _ in range(28))) # Whether error info has been subscribed. self._subscribed_error = False # Buffer for holding error info. self._errors = deque() # Future for indicating whether the subscriber has closed. self._close = threading.Event()
def __init__(self, address: str): channel = gcs_utils.create_gcs_channel(address) self._stub = gcs_service_pb2_grpc.InternalPubSubGcsServiceStub(channel)