Exemple #1
0
        internal static Worker[] all()
        {
            var workers = from id in Resque.redis().GetMembersOfSet("resque:workers")
                          select find(Encoding.UTF8.GetString(id));

            return(workers.ToArray <Worker>());
        }
Exemple #2
0
 private void setStarted()
 {
     currentTimeFormatted();
     Resque.redis().Set(new Dictionary <string, byte[]>()
     {
         { startedKey(), Encoding.UTF8.GetBytes(currentTimeFormatted()) }
     });
 }
Exemple #3
0
        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();
        }
Exemple #4
0
        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");
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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());
        }
Exemple #8
0
 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]));
 }
Exemple #10
0
 public static void clear(String stat)
 {
     Resque.redis().Remove("resque:stat:" + stat);
 }
Exemple #11
0
 private void setDoneWorking()
 {
     setProcssed();
     Resque.redis().Remove("resque:worker:" + workerId());
 }
Exemple #12
0
 public static void increment(String stat)
 {
     Resque.redis().Increment("resque:stat:" + stat, 1);
 }
Exemple #13
0
 public static void decrement(String stat)
 {
     Resque.redis().Decrement("resque:stat:" + stat);
 }
Exemple #14
0
 public static int get(String stat)
 {
     return(Int32.Parse(Resque.redis().GetString("resque:stat:" + stat)));
 }
Exemple #15
0
 public void unregisterWorker()
 {
     Resque.redis().RemoveFromSet("resque:workers", workerId());
     Resque.redis().Remove("worker:" + workerId() + ":started");
     // FIXME clear stats
 }
Exemple #16
0
 private void registerWorker()
 {
     Resque.redis().AddToSet("resque:workers", workerId());
     setStarted();
 }
Exemple #17
0
 public static bool isExisting(string id)
 {
     return(Resque.redis().IsMemberOfSet("resque:workers", id));
 }
Exemple #18
0
 public string state()
 {
     return(Resque.redis().ContainsKey("resque:worker:" + workerId()) ? "working" : "idle");
 }