Пример #1
0
    def create(
        obj: Union["TrackerStore", EndpointConfig, None],
        domain: Optional[Domain] = None,
        event_broker: Optional[EventBroker] = None,
    ) -> "TrackerStore":
        """Factory to create a tracker store."""
        if isinstance(obj, TrackerStore):
            return obj

        from botocore.exceptions import BotoCoreError
        import pymongo.errors
        import sqlalchemy.exc

        try:
            return _create_from_endpoint_config(obj, domain, event_broker)
        except (
            BotoCoreError,
            pymongo.errors.ConnectionFailure,
            sqlalchemy.exc.OperationalError,
            ConnectionError,
            pymongo.errors.OperationFailure,
        ) as error:
            raise ConnectionException(
                "Cannot connect to tracker store." + str(error)
            ) from error
Пример #2
0
    def create(
        obj: Union[TrackerStore, EndpointConfig, None],
        domain: Optional[Domain] = None,
        event_broker: Optional[EventBroker] = None,
    ) -> TrackerStore:
        """Factory to create a tracker store."""
        if isinstance(obj, TrackerStore):
            return obj

        from botocore.exceptions import BotoCoreError
        import pymongo.errors
        import sqlalchemy.exc

        try:
            tracker_store = _create_from_endpoint_config(
                obj, domain, event_broker)
            if not check_if_tracker_store_async(tracker_store):
                rasa.shared.utils.io.raise_deprecation_warning(
                    f"Tracker store implementation "
                    f"{tracker_store.__class__.__name__} "
                    f"is not asynchronous. Non-asynchronous tracker stores "
                    f"are currently deprecated and will be removed in 4.0. "
                    f"Please make the following methods async: "
                    f"{_get_async_tracker_store_methods()}")
                tracker_store = AwaitableTrackerStore(tracker_store)
            return tracker_store
        except (
                BotoCoreError,
                pymongo.errors.ConnectionFailure,
                sqlalchemy.exc.OperationalError,
                ConnectionError,
                pymongo.errors.OperationFailure,
        ) as error:
            raise ConnectionException("Cannot connect to tracker store." +
                                      str(error)) from error
Пример #3
0
    def create(obj: Union[LockStore, EndpointConfig, None]) -> LockStore:
        """Factory to create a lock store."""
        if isinstance(obj, LockStore):
            return obj

        try:
            return _create_from_endpoint_config(obj)
        except ConnectionError as error:
            raise ConnectionException(
                "Cannot connect to lock store.") from error
Пример #4
0
    async def create(
        obj: Union["EventBroker", EndpointConfig, None],
        loop: Optional[AbstractEventLoop] = None,
    ) -> Optional["EventBroker"]:
        """Factory to create an event broker."""
        if isinstance(obj, EventBroker):
            return obj

        import aio_pika.exceptions
        import sqlalchemy.exc

        try:
            return await _create_from_endpoint_config(obj, loop)
        except (
            sqlalchemy.exc.OperationalError,
            aio_pika.exceptions.AMQPConnectionError,
        ) as error:
            raise ConnectionException("Cannot connect to event broker.") from error