Skip to content

Returning a client as *either* cluster or non-cluster, using the common Commander interface? #1773

Open
@GeoffreyPlitt

Description

My project sometimes uses redis in cluster mode, sometimes not.

I am making a redis-client-creator function using IORedis, and I'd like it to return a single type that works either way.

I notice that both non-cluster and yes-cluster Redis classes inherit from Commander class (https://ioredis.readthedocs.io/en/latest/API/#Commander), so I thought this would be a perfect interface to use as the return type for my client creator.

But Commander is not exported by the IORedis library. It's internal only?

What is a good way for my client-creator function to return a single type that could be either a cluster or non-cluster client?

Or can I do this with ClientContext?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions