This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Event.cs
42 lines (36 loc) · 1.6 KB
/
Event.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using Newtonsoft.Json.Linq;
namespace Resque
{
public class Event
{
public static event BeforePerformHandler BeforePerform = delegate { };
public static event AfterPerformHandler AfterPerform = delegate { };
public static event FailureHandler Failure = delegate { };
public static event AfterEnqueueHandler AfterEnqueue = delegate { };
public delegate void BeforePerformHandler(Job job, EventArgs eventArgs);
public delegate void AfterPerformHandler(Job job, EventArgs eventArgs);
public delegate void FailureHandler(Exception exception, Job job, EventArgs eventArgs);
public delegate void AfterEnqueueHandler(string className, JObject arguments, string queue, EventArgs eventArgs);
public static void OnBeforePerform(Job job, EventArgs eventargs)
{
var handler = BeforePerform;
if (handler != null) handler(job, eventargs);
}
public static void OnAfterPerform(Job job, EventArgs eventargs)
{
var handler = AfterPerform;
if (handler != null) handler(job, eventargs);
}
public static void OnFailure(Exception exception, Job job, EventArgs eventargs)
{
var handler = Failure;
if (handler != null) handler(exception, job, eventargs);
}
public static void OnAfterEnqueue(string className, JObject arguments, string queue, EventArgs eventargs)
{
var handler = AfterEnqueue;
if (handler != null) handler(className, arguments, queue, eventargs);
}
}
}