event.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:cbapi-python 作者: carbonblack 项目源码 文件源码
def __init__(self, cb):
        super(RabbitMQEventSource, self).__init__()
        self.daemon = True

        self._closing = False
        self._connection = None
        self._channel = None
        self._closing = False
        self._consumer_tag = None
        self._auto_ack = True
        self._consuming = False

        self._cb = cb
        creds = cb.credentials

        if not creds.rabbitmq_pass:
            error_text = "RabbitMQEventSource requires credentials for the event bus. Make sure that\n" + \
                         "rabbitmq_pass, rabbitmq_user, rabbitmq_host, and rabbitmq_port are defined\n" + \
                         "in the credential file"

            if cb.credential_profile_name:
                error_text += " for profile '{0}'.".format(cb.credential_profile_name)

            raise CredentialError(error_text)

        self._url = "amqp://{0}:{1}@{2}:{3}".format(creds.rabbitmq_user, creds.rabbitmq_pass, creds.rabbitmq_host,
                                                    creds.rabbitmq_port)

        self.QUEUE = "cbapi-event-handler-{0}-{1}".format(platform.uname()[1], os.getpid())
        self.EXCHANGE = "api.events"
        self.ROUTING_KEYS = registry.event_types
        self.EXCHANGE_TYPE = "topic"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号