Server Version Number

I would like a way to get the cluster server version numbers through the SDK (after calling Cluster.ConnectAsync). My use case is that if I detected everything is 6.5 or greater I would like to call Cluster.WaitUntilReadyAsync, and skip that call if anything is 6.0 or less. I cannot find anything like this and the only flags in the source code are internal. I can call ip:8091/versions but a) that would be an extra HTTP call and b) if that information is ever changed my code would break.

As the SDK gets more mature and the server versions keep growing, I could see this being extremely useful (especially for users like me who need to support multiple Couchbase versions at once).



await cluster.ClusterServices.GetRequiredService<IClusterVersionProvider>().GetVersionAsync();

This should return the version of the node in the cluster with the lowest version.

1 Like

Thanks @btburnett3 .
This works: (IClusterVersionProvider)TheCluster.ClusterServices.GetService(typeof(IClusterVersionProvider)). I don’t see the generic version or GetRequiredService?!

The generic version is an extension method in the Microsoft.Extensions.DependencyInjection package/namespace which most users on .NET Core have. If you don’t have those extension methods available then yes you’d need to do the typecasting approach you used.

1 Like