Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Threading.Tasks;
using ConsoleSample;
using Hangfire;
using Hangfire.Logging;
using Hangfire.Pro.Redis;
using Microsoft.Owin;
using Microsoft.Owin.Hosting;
using Owin;
@odinserj
odinserj / SkipIfExistsAttribute.cs
Last active April 15, 2022 02:46
SkipIfExistsAttribute.cs
// Zero-Clause BSD (more permissive than MIT, doesn't require copyright notice)
//
// Permission to use, copy, modify, and/or distribute this software for any purpose
// with or without fee is hereby granted.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
@odinserj
odinserj / SkipWhenPreviousJobIsRunningAttribute.cs
Last active May 3, 2024 17:03
SkipWhenPreviousJobIsRunningAttribute.cs
// Zero-Clause BSD (more permissive than MIT, doesn't require copyright notice)
//
// Permission to use, copy, modify, and/or distribute this software for any purpose
// with or without fee is hereby granted.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
@odinserj
odinserj / pausebatch.cs
Created April 26, 2017 08:56
Pause Batches
using System;
using System.Collections.Generic;
using Hangfire;
using Hangfire.Common;
using Hangfire.States;
using Hangfire.Storage;
namespace ConsoleApp18
{
public class CanBePausedAttribute : JobFilterAttribute, IElectStateFilter
@odinserj
odinserj / DebounceAttribute.cs
Created April 18, 2017 12:41
DebounceAttribute
public sealed class DebounceAttribute : JobFilterAttribute, IElectStateFilter
{
private readonly string _resourceFormat;
private readonly int _milliseconds;
public DebounceAttribute(string resourceFormat, int milliseconds)
{
_resourceFormat = resourceFormat ?? throw new ArgumentNullException(nameof(resourceFormat));
_milliseconds = milliseconds;
}
@odinserj
odinserj / docker-compose.yml
Last active November 29, 2019 14:46
ProGet using docker compose
version: '2'
services:
nginx:
image: jwilder/nginx-proxy
container_name: nginx-proxy
environment:
- DEFAULT_HOST=nuget.hangfire.io
links:
- proget
ports:
@odinserj
odinserj / HangfireFSharp.cs.diff
Created November 14, 2016 12:04
HangfireFSharp.cs.diff
@@ -323,7 +323,7 @@ private static Job FromExpression([NotNull] LambdaExpression methodCall, [CanBeN
{
if (methodCall == null) throw new ArgumentNullException(nameof(methodCall));
var callExpression = methodCall.Body as MethodCallExpression;
var callExpression = UnwrapFSharpExpression(methodCall).Body as MethodCallExpression;
if (callExpression == null)
{
throw new ArgumentException("Expression body should be of type `MethodCallExpression`", nameof(methodCall));
@@ -363,6 +363,36 @@ private static Job FromExpression([NotNull] LambdaExpression methodCall, [CanBeN
@odinserj
odinserj / MutexAttribute.cs
Last active January 15, 2022 12:56
MutexAttribute.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Hangfire.Common;
using Hangfire.States;
using Hangfire.Storage;
namespace Hangfire.Pro
{
/// <summary>
@odinserj
odinserj / FailoverRedisStorage.cs
Created November 24, 2015 12:19
FailoverRedisStorage
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Hangfire;
using Hangfire.Logging;
using Hangfire.Redis;
using Hangfire.Storage;
@odinserj
odinserj / gist:4ac6014f4a9da099959c
Created July 3, 2015 13:53
FailoverRedisStorage.cs
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Hangfire;
using Hangfire.Logging;
using Hangfire.Redis;
using Hangfire.Storage;