Exemplo n.º 1
0
def get_simple_kafka_client(client_id=GENERIC_KAFKA_CLIENT_ID):
    # this uses the old SimpleClient because we are using the old SimpleProducer interface
    return ClosingContextProxy(
        SimpleClient(
            hosts=settings.KAFKA_BROKERS,
            client_id=client_id,
            timeout=30,  # seconds
        ))
Exemplo n.º 2
0
 def fetch_attachment(self, name, stream=False):
     if self._deferred_blobs and name in self._deferred_blobs:
         if self._deferred_blobs[name] is None:
             raise ResourceNotFound(
                 "{model} {model_id} attachment: {name!r}".format(
                     model=type(self).__name__,
                     model_id=self._id,
                     name=name,
                 ))
         body = self._deferred_blobs[name]["content"]
         if stream:
             return ClosingContextProxy(BytesIO(body))
         return body
     return super(DeferredBlobMixin, self).fetch_attachment(name, stream)
Exemplo n.º 3
0
 def open(self):
     obj = self.s3_bucket.Object(self.key).get()
     return ClosingContextProxy(obj["Body"])
Exemplo n.º 4
0
def _get_consumer():
    return ClosingContextProxy(
        KafkaConsumer(client_id='pillowtop_utils',
                      bootstrap_servers=settings.KAFKA_BROKERS,
                      request_timeout_ms=1000))
Exemplo n.º 5
0
def get_kafka_consumer():
    return ClosingContextProxy(
        KafkaConsumer(
            client_id='pillowtop_utils',
            bootstrap_servers=settings.KAFKA_BROKERS,
        ))
Exemplo n.º 6
0
def get_kafka_client(client_id=GENERIC_KAFKA_CLIENT_ID):
    return ClosingContextProxy(
        KafkaClient(bootstrap_servers=settings.KAFKA_BROKERS,
                    client_id=client_id,
                    api_version=settings.KAFKA_API_VERSION))