openwferu-scheduler 0.9.15.1127 → 0.9.15.1128
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/openwfe/util/scheduler.rb +29 -11
- metadata +1 -1
@@ -53,7 +53,7 @@ module OpenWFE
|
|
53
53
|
# params (usually an array or nil), either a block, which is more in the
|
54
54
|
# Ruby way.
|
55
55
|
#
|
56
|
-
#
|
56
|
+
# Some examples :
|
57
57
|
#
|
58
58
|
# scheduler.schedule_in("3d") do
|
59
59
|
# regenerate_monthly_report()
|
@@ -62,7 +62,16 @@ module OpenWFE
|
|
62
62
|
# # will call the regenerate_monthly_report method
|
63
63
|
# # in 3 days from now
|
64
64
|
#
|
65
|
-
#
|
65
|
+
# scheduler.schedule "0 22 * * 1-5" do
|
66
|
+
# log.info "activating security system..."
|
67
|
+
# activate_security_system()
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# job_id = scheduler.schedule_at "Sun Oct 07 14:24:01 +0900 2009" do
|
71
|
+
# init_self_destruction_sequence()
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# an example that uses a Schedulable class :
|
66
75
|
#
|
67
76
|
# class Regenerator < Schedulable
|
68
77
|
# def trigger (frequency)
|
@@ -122,6 +131,7 @@ module OpenWFE
|
|
122
131
|
# end
|
123
132
|
#
|
124
133
|
# jobs = find_jobs 'backup'
|
134
|
+
# jobs.each { |job| job.unschedule }
|
125
135
|
#
|
126
136
|
# Multiple tags may be attached to a single job :
|
127
137
|
#
|
@@ -390,7 +400,7 @@ module OpenWFE
|
|
390
400
|
# schedule
|
391
401
|
|
392
402
|
b = to_block(params, &block)
|
393
|
-
job = CronJob.new(cron_id, cron_line, tags, &b)
|
403
|
+
job = CronJob.new(self, cron_id, cron_line, tags, &b)
|
394
404
|
@cron_jobs[job.job_id] = job
|
395
405
|
|
396
406
|
job.job_id
|
@@ -536,7 +546,7 @@ module OpenWFE
|
|
536
546
|
tags = params[:tags]
|
537
547
|
|
538
548
|
b = to_block(params, &block)
|
539
|
-
job = jobClass.new(at, job_id, tags, &b)
|
549
|
+
job = jobClass.new(self, at, job_id, tags, &b)
|
540
550
|
|
541
551
|
unschedule(job_id) if job_id
|
542
552
|
|
@@ -744,11 +754,12 @@ module OpenWFE
|
|
744
754
|
# as a scheduler is fully transient, no need to
|
745
755
|
# have persistent ids, a simple counter is sufficient
|
746
756
|
|
747
|
-
attr_accessor
|
748
|
-
|
757
|
+
attr_accessor :job_id, :tags, :block
|
758
|
+
attr_reader :scheduler
|
749
759
|
|
750
|
-
def initialize (job_id, tags, &block)
|
760
|
+
def initialize (scheduler, job_id, tags, &block)
|
751
761
|
|
762
|
+
@scheduler = scheduler
|
752
763
|
@block = block
|
753
764
|
|
754
765
|
if job_id
|
@@ -773,14 +784,21 @@ module OpenWFE
|
|
773
784
|
def has_tag? (tag)
|
774
785
|
@tags.include?(tag)
|
775
786
|
end
|
787
|
+
|
788
|
+
#
|
789
|
+
# Removes (cancels) this job from its scheduler.
|
790
|
+
#
|
791
|
+
def unschedule
|
792
|
+
@scheduler.unschedule(@job_id)
|
793
|
+
end
|
776
794
|
end
|
777
795
|
|
778
796
|
class AtJob < Job
|
779
797
|
|
780
798
|
attr_accessor :at
|
781
799
|
|
782
|
-
def initialize (at, at_id, tags, &block)
|
783
|
-
super(at_id, tags, &block)
|
800
|
+
def initialize (scheduler, at, at_id, tags, &block)
|
801
|
+
super(scheduler, at_id, tags, &block)
|
784
802
|
@at = at
|
785
803
|
end
|
786
804
|
|
@@ -796,9 +814,9 @@ module OpenWFE
|
|
796
814
|
|
797
815
|
attr_accessor :cron_line
|
798
816
|
|
799
|
-
def initialize (cron_id, line, tags, &block)
|
817
|
+
def initialize (scheduler, cron_id, line, tags, &block)
|
800
818
|
|
801
|
-
super(cron_id, tags, &block)
|
819
|
+
super(scheduler, cron_id, tags, &block)
|
802
820
|
|
803
821
|
if line.kind_of?(String)
|
804
822
|
@cron_line = CronLine.new(line)
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: openwferu-scheduler
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.15.
|
6
|
+
version: 0.9.15.1128
|
7
7
|
date: 2007-10-07 00:00:00 +09:00
|
8
8
|
summary: OpenWFEru scheduler for Ruby (at, cron and every)
|
9
9
|
require_paths:
|