Dependency Injection for different Clusters in Asp.net Core?

Could you please describe how to add the Dependency Injection for different Clusters in Asp.net Core?

Scenario1:
Connecting to multiple Couchbase Clusters from the Asp.net core. Suppose, we are connecting to multiple different couchbase clusters from my application which have different server/nodes

As per the documentation here, the following is the suggested approach for connecting to single cluster with multiple buckets passing in the Couchbase configuration. This works fine for a single cluster.

services
    .AddCouchbase(Configuration.GetSection("Couchbase"))
    .AddCouchbaseBucket<ITravelSampleBucketProvider>("travel-sample", "password");

Is there a code sample as to configure the DI, when we need to connect to a different cluster having a different address, and buckets?

services
    .AddCouchbase(Configuration.GetSection("Couchbase1"))
    .AddCouchbaseBucket<ITravelSampleBucketProvider>("travel-sample", "password");

services
        .AddCouchbase(Configuration.GetSection("Couchbase2"))
        .AddCouchbaseBucket<ITravelSampleBucketProvider>("beer-sample", "password");

@abhinav.galodha -

I don’t know if it’s possible because the DI extensions registers the cluster as a singleton lifetime service. If it is possible it would be done the same as you have done here, but I suspect it will override what you set with “Couchbase1” cluster.

I am curious, why do you need multiple clusters? A cluster can contain multiple buckets; as long as you don’t add dozens of buckets.

-Jeff

I am curious, why do you need multiple clusters? A cluster can contain multiple buckets; as long as you don’t add dozens of buckets.

We are a part of a big enterprise where different team owns their own clusters and our API needs to communicate with the multiple clusters.

Any solution?. I have same problem

There is not an official solution for multi-cluster dependency injection at this time. I’ve started some work to add support, but I’m not really happy about the API surface right now. Until then, the best I can recommend is to manage the instances and DI yourself rather than a built-in library.

In case it’s any help, I just pushed up my WIP for adding this support: http://review.couchbase.org/c/couchbase-net-client/+/150914