Giter VIP home page Giter VIP logo

hangfire.couchbase's Introduction

Hangfire.Couchbase

Official Site Latest version Build status

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.

Installation

Hangfire.Couchbase is available as a NuGet package. Install it using the NuGet Package Console window:

PM> Install-Package Hangfire.Couchbase

Usage

1. Using the ClientConfiguration to initialize the server
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>");
2. Using the XML configuration to intialzie .Net application
<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>");
3. Using the JSON configuration for .Net Core application
{
  "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);

Questions? Problems?

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.

hangfire.couchbase's People

Contributors

imranmomin avatar mgroves avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.