Couchbase.Extensions.DnsDiscovery
2.0.2
dotnet add package Couchbase.Extensions.DnsDiscovery --version 2.0.2
NuGet\Install-Package Couchbase.Extensions.DnsDiscovery -Version 2.0.2
<PackageReference Include="Couchbase.Extensions.DnsDiscovery" Version="2.0.2" />
paket add Couchbase.Extensions.DnsDiscovery --version 2.0.2
#r "nuget: Couchbase.Extensions.DnsDiscovery, 2.0.2"
// Install Couchbase.Extensions.DnsDiscovery as a Cake Addin
#addin nuget:?package=Couchbase.Extensions.DnsDiscovery&version=2.0.2
// Install Couchbase.Extensions.DnsDiscovery as a Cake Tool
#tool nuget:?package=Couchbase.Extensions.DnsDiscovery&version=2.0.2
Couchbase.Extensions.DnsDiscovery
A .Net Core compatible DNS SRV mechanism for discovering a Couchbase cluster dynamically.
Getting Started
Assuming you have an installation of Couchbase Server and Visual Studio (examples with VSCODE forthcoming), do the following:
- Create a .NET Core Web Application using Visual Studio or VsCodeor CIL
- Install the package from NuGet or build from source and add reference
Configuration
To use, call AddCouchbaseDnsDiscovery
during the service registration process, usually in your Startup
class. You may choose whether or not to add this step based on the environment. Be sure to add the basic Couchbase configuration first.
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
Environment = env;
}
public IConfigurationRoot Configuration { get; }
public IHostingEnvironment Environment { get; }
public void ConfigureServices(IServiceCollection services)
{
// Register Couchbase with configuration section
services.AddCouchbase(Configuration.GetSection("Couchbase"));
services.AddCouchbaseDnsDiscovery();
// Register other services, like .AddMvc()
}
Example configuration file:
{
"Couchbase": {
"Username": "Administrator",
"Password": "Password",
"ConnectionString": "couchbase://services.local"
}
}
The above configuration will perform a DNS SRV query for _couchbase._tcp.services.local
, based on the single entry in the Servers section of the configuration. The results will be used to replace the Servers list in the Couchbase client configuration.
The following rules will be applied:
- If using ConnectionString, there must be only one server listed in the string
- If using the Servers collection, there must be only one URI in the collection
- The URI must use either the "couchbase://" or "couchbases://" scheme
- The URI must not have a port number
- If these rules aren't matched, or if no DNS SRV records is found, then the client will fallback to directly connecting to the listed servers
Due to the nature of Couchbase clusters, the priority and weight fields in the DNS SRV records are ignored. However, the port is used and should normally be set to 11210 for _couchbase and 11207 for _couchbases.
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net461 net462 net463 net47 net471 net472 net48 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETStandard 2.0
- CouchbaseNetClient (>= 2.5.9)
- DnsClient (>= 1.0.1)
- Microsoft.Extensions.Logging (>= 1.1.2)
- Microsoft.Extensions.Options (>= 1.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.2 | 31,937 | 5/9/2018 |
2.0.1 | 5,495 | 3/1/2018 |
2.0.0 | 1,480 | 11/8/2017 |
1.0.2 | 4,320 | 8/7/2017 |
1.0.0 | 1,397 | 2/15/2017 |
1.0.0-beta4 | 793 | 1/26/2017 |
1.0.0-beta2 | 738 | 1/8/2017 |