Fake Mirrors
    Preparing search index...

    Class RedisConsumerConnector

    Redis-based consumer connector implementation.

    Uses the ioredis client to manage connections for the Bull queue consumer.

    https://github.com/redis/ioredis - ioredis documentation

    Depends:

    import { DIContainer } from '@famir/common'
    import { RedisConsumerConnector } from '@famir/consumer'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Register dependency in container
    RedisConsumerConnector.register(container)
    import { DIContainer } from '@famir/common'
    import { CONSUMER_CONNECTOR, ConsumerConnector } from '@famir/domain'
    import { RedisConsumerConnection } from '@famir/consumer'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Resolve dependency from container
    const connector = container.resolve<ConsumerConnector>(CONSUMER_CONNECTOR)

    // Get underlying Redis connection
    const connection = connector.getConnection<RedisConsumerConnection>()

    // Close connection
    await connector.close()

    Implements

    • Gracefully closes a connection to the consumer.

      This method should be called during application shutdown to ensure all pending operations are completed and resources are released.

      Returns Promise<void>

      LifecycleError If the connection cannot be closed properly.

    • Establishes a connection to the consumer.

      This method should be called during application bootstrap to ensure the connection is ready before any operations are performed.

      Returns Promise<void>

      LifecycleError If the consumer connection cannot be established.

    • Retrieves the underlying consumer connection.

      This method uses a type assertion to return the connection as the requested type. It is the caller's responsibility to ensure the correct type is used.

      Type Parameters

      • T

        The expected type of the consumer connection.

      Returns T

      The consumer connection cast to type T.

    • Registers the connector as a singleton in the DI container.

      Parameters

      • container: DIContainer

        The DI container to register in.

      Returns void