This repo will add a Couchbase N1QL storage support to Hangfire - fire-and-forget, delayed and recurring tasks runner for .NET. Scalable and reliable background job runner. Supports multiple servers, CPU and I/O intensive, long-running and short-running jobs.
Hangfire.Couchbase is available as a NuGet package. Install it using the NuGet Package Console window:
PM> Install-Package Hangfire.Couchbase
ClientConfiguration configuration = new ClientConfiguration {
BucketConfigs = new Dictionary<string, BucketConfiguration> {
{"default", new BucketConfiguration {
PoolConfiguration = new PoolConfiguration {
MaxSize = 6,
MinSize = 4,
SendTimeout = 12000
},
DefaultOperationLifespan = 123,
Password = "password",
Username = "username",
BucketName = "default"
}}
}
};
GlobalConfiguration.Configuration.UseCouchbaseStorage(configuration, "<defaultBucket>");
If you're using Couchbase 5.0+, then you'll need to supply RBAC credentials:
ClientConfiguration configuration = new ClientConfiguration {
BucketConfigs = new Dictionary<string, BucketConfiguration> {
{"default", new BucketConfiguration {
PoolConfiguration = new PoolConfiguration {
MaxSize = 6,
MinSize = 4,
SendTimeout = 12000
},
DefaultOperationLifespan = 123,
BucketName = "default"
}}
}
};
configuration.SetAuthenticator(new PasswordAuthenticator("<username>", "<password>"));
GlobalConfiguration.Configuration.UseCouchbaseStorage(configuration, "<defaultBucket>");
<configSections>
<sectionGroup name="couchbaseClients">
<section name="couchbase" type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient" />
</sectionGroup>
</configSections>
<couchbaseClients>
<couchbase>
<servers>
<add uri="http://localhost:8091"></add>
</servers>
<buckets>
<add name="default" password="password" />
</buckets>
<serializer name="CustomSerializer" type="Hangfire.Couchbase.Json.DocumentDefaultSerializer, Hangfire.Couchbase" />
</couchbase>
</couchbaseClients>
GlobalConfiguration.Configuration.UseCouchbaseStorage("couchbaseClients/couchbase", "<defaultBucket>");
{
"couchbase": {
"basic": {
"servers": [
"http://localhost:8091/"
],
"buckets": [
{
"name": "default",
"password": "password"
}
],
"serializer": "Hangfire.Couchbase.Json.DocumentDefaultSerializer, Hangfire.Couchbase"
}
}
}
IConfigurationBuilder builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
IConfigurationRoot configuration = builder.Build();
GlobalConfiguration.Configuration.UseCouchbaseStorage(configuration, "couchbase:basic", "<defaultBucket>");
You can also customize some of the options to fine tune the job server. The below are defaults; if no overrides found
Hangfire.Couchbase.CouchbaseStorageOptions options = new Hangfire.Couchbase.CouchbaseStorageOptions
{
RequestTimeout = TimeSpan.FromSeconds(30),
ExpirationCheckInterval = TimeSpan.FromMinutes(2),
CountersAggregateInterval = TimeSpan.FromMinutes(2),
QueuePollInterval = TimeSpan.FromSeconds(15)
};
GlobalConfiguration.Configuration.UseCouchbaseStorage(configuration, "<defaultBucket>", options);
Open-source project are developing more smoothly, when all discussions are held in public.
If you have any questions or problems related to Hangfire.Couchbase itself or this storage implementation or want to discuss new features, please create under issues and assign the correct label for discussion.
If you've discovered a bug, please report it to the GitHub Issues. Detailed reports with stack traces, actual and expected behavours are welcome.