internal static Worker[] all() { var workers = from id in Resque.redis().GetMembersOfSet("resque:workers") select find(Encoding.UTF8.GetString(id)); return(workers.ToArray <Worker>()); }
private void setStarted() { currentTimeFormatted(); Resque.redis().Set(new Dictionary <string, byte[]>() { { startedKey(), Encoding.UTF8.GetBytes(currentTimeFormatted()) } }); }
public void Init() { // This is the IP address of my computer running Redis. server = "ec2-184-73-7-218.compute-1.amazonaws.com"; //server = "192.168.56.102"; Resque.setRedis(new Redis(server, 6379)); Resque.redis().FlushAll(); }
private void setWorkingOn(Job job) { job.worker = this; string data = Resque.encode(new Dictionary <string, object>() { { "queue", job.queue }, { "run_at", currentTimeFormatted() }, { "payload", job.payload } }); Resque.redis().Set("resque:worker:" + workerId(), data); }
public void Init() { server = "ec2-184-73-7-218.compute-1.amazonaws.com"; //string server = "192.168.56.102"; Resque.setRedis(new Redis(server, 6379)); Resque.redis().FlushAll(); worker = new Worker("jobs"); //Job.create("jobs", "resque.DummyJob", 20, "/tmp"); }
public void Init() { // This is the IP address of my computer running Redis. server = "ec2-184-73-7-218.compute-1.amazonaws.com"; //server = "192.168.56.102"; Resque.setRedis(new Redis(server, 6379)); Resque.redis().FlushAll(); Exception ex = new Exception(testString); Worker worker = new Worker(); String queue = testString; payload = Encoding.UTF8.GetBytes(testString); myRedis = new Failure.Redis(ex, worker, queue, payload); }
internal static Worker[] working() { Worker[] workers = all(); if (workers.Length == 0) { return(workers); } string[] names = (from worker in workers select "resque:worker:" + worker.workerId()).ToArray <string>(); string[] redisValues = (from bytes in Resque.redis().GetKeys(names) select bytes == null ? null : Encoding.UTF8.GetString(bytes)).ToArray <string>();; List <Worker> results = new List <Worker>(); for (int i = 0; i < names.Length; i++) { if (!String.IsNullOrEmpty(redisValues[i])) { results.Add(find(Regex.Replace(names[i], "resque:worker:", ""))); } } return(results.ToArray()); }
public Dictionary <string, object> job() { return((Dictionary <string, object>)Resque.decode(Resque.redis().Get("resque:worker:" + workerId()))); }
public void QueuesAreAlwaysAList() { Resque.redis().FlushAll(); Assert.That(Resque.queues(), Is.EqualTo(new string[0])); }
public static void clear(String stat) { Resque.redis().Remove("resque:stat:" + stat); }
private void setDoneWorking() { setProcssed(); Resque.redis().Remove("resque:worker:" + workerId()); }
public static void increment(String stat) { Resque.redis().Increment("resque:stat:" + stat, 1); }
public static void decrement(String stat) { Resque.redis().Decrement("resque:stat:" + stat); }
public static int get(String stat) { return(Int32.Parse(Resque.redis().GetString("resque:stat:" + stat))); }
public void unregisterWorker() { Resque.redis().RemoveFromSet("resque:workers", workerId()); Resque.redis().Remove("worker:" + workerId() + ":started"); // FIXME clear stats }
private void registerWorker() { Resque.redis().AddToSet("resque:workers", workerId()); setStarted(); }
public static bool isExisting(string id) { return(Resque.redis().IsMemberOfSet("resque:workers", id)); }
public string state() { return(Resque.redis().ContainsKey("resque:worker:" + workerId()) ? "working" : "idle"); }