GithubHelp home page GithubHelp logo

smartfire / hangfire.mysqlstorage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arnoldasgudas/hangfire.mysqlstorage

0.0 3.0 0.0 98 KB

MySql storage for Hangfire - fire-and-forget, delayed and recurring tasks runner

License: GNU General Public License v2.0

C# 99.95% PowerShell 0.05%

hangfire.mysqlstorage's Introduction

Hangfire MySql Storage Implementation

Latest version Official Site

MySql storage implementation of 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.

Some features of MySql storage implementation is under development!

Installation

Install MySQL

Run the following command in the NuGet Package Manager console to install Hangfire.MySqlStorage:

Install-Package Hangfire.MySqlStorage

Usage

Use one the following ways to initialize MySqlStorage:

  • Create new instance of MySqlStorage with connection string constructor parameter and pass it to Configuration with UseStorage method:
  GlobalConfiguration.Configuration.UseStorage(
    new MySqlStorage(connectionString));
  • There must be Allow User Variables set to true in the connection string. For example: server=127.0.0.1;uid=root;pwd=root;database={0};Allow User Variables=True
  • Alternatively one or more options can be passed as a parameter to MySqlStorage:
GlobalConfiguration.Configuration.UseStorage(
    new MySqlStorage(
        connectionString, 
        new MySqlStorageOptions
        {
            TransactionIsolationLevel = IsolationLevel.ReadCommitted,
            QueuePollInterval = TimeSpan.FromSeconds(15),
            JobExpirationCheckInterval = TimeSpan.FromHours(1),
            CountersAggregateInterval = TimeSpan.FromMinutes(5),
            PrepareSchemaIfNecessary = true,
            DashboardJobListLimit = 50000,
            TransactionTimeout = TimeSpan.FromMinutes(1),
        }));

Description of optional parameters:

  • TransactionIsolationLevel - transaction isolation level. Default is read committed.
  • QueuePollInterval - job queue polling interval. Default is 15 seconds.
  • JobExpirationCheckInterval - job expiration check interval (manages expired records). Default is 1 hour.
  • CountersAggregateInterval - interval to aggregate counter. Default is 5 minutes.
  • PrepareSchemaIfNecessary - if set to true, it creates database tables. Default is true.
  • DashboardJobListLimit - dashboard job list limit. Default is 50000.
  • TransactionTimeout - transaction timeout. Default is 1 minute.

How to limit number of open connections

Number of opened connections depends on Hangfire worker count. You can limit worker count by setting WorkerCount property value in BackgroundJobServerOptions:

app.UseHangfireServer(
   new BackgroundJobServerOptions
   {
      WorkerCount = 1
   });

More info: http://hangfire.io/features.html#concurrency-level-control

Dashboard

Hangfire provides a dashboard Dashboard More info: Hangfire Overview

Build

Please use Visual Studio or any other tool of your choice to build the solution

Test

In order to run unit tests and integrational tests set the following variables in you system environment variables (restart of Visual Studio is required):

Hangfire_SqlServer_ConnectionStringTemplate (default: server=127.0.0.1;uid=root;pwd=root;database={0};Allow User Variables=True)

Hangfire_SqlServer_DatabaseName (default: Hangfire.MySql.Tests)

hangfire.mysqlstorage's People

Contributors

arnoldasgudas avatar nick-pat avatar osoykan avatar

Watchers

 avatar  avatar  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.