mongodb-scheduler 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +2 -1
- data/lib/scheduler/examples/executable_class.rb +4 -3
- data/lib/scheduler/schedulable.rb +2 -2
- data/lib/scheduler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6e941c10de62e0a4099809484e1c80b42b61710f5f8085bd805eb414f303cc2
|
4
|
+
data.tar.gz: d1ef56a14c5d82e547fa6b970c375440c4898167d6cbba79c02d9d006af2bce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e353475369f8c5fb8826850ebdec1aa4de00f6b0734fd200155729f93ea4a146d340fa5a7952ed47a79089bf54f041c5082845541971fc7fb343681fbe32258b
|
7
|
+
data.tar.gz: 13fa5d14f11c3e2c3e4bf3fe5291e49f8fe525a4833a74d149ac41fcdae42585e7cb5166fb7fc565b127bd67e88e114c60dec2032518101cf15315d1c4694e89
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
scheduler (0.1.0)
|
4
|
+
mongodb-scheduler (0.1.0)
|
5
5
|
bson_ext
|
6
6
|
hanami-cli
|
7
7
|
hanami-mongoid
|
@@ -65,9 +65,9 @@ PLATFORMS
|
|
65
65
|
|
66
66
|
DEPENDENCIES
|
67
67
|
bundler (~> 2.0)
|
68
|
+
mongodb-scheduler!
|
68
69
|
rake (~> 10.0)
|
69
70
|
rspec (~> 3.0)
|
70
|
-
scheduler!
|
71
71
|
|
72
72
|
BUNDLED WITH
|
73
73
|
2.0.1
|
data/README.md
CHANGED
@@ -23,7 +23,8 @@ $ scheduler restart
|
|
23
23
|
A `Scheduler` is a process that keeps running looking for jobs to perform. The jobs are documents of a specific collection that you can specify in the scheduler configuration file. You can specify your own model to act as a schedulable entity, as long as it includes the `Schedulable` module. The other configuration options are explained in the template file `lib/scheduler/templates/scheduler.rb` file.
|
24
24
|
|
25
25
|
As an example, the gem comes with a `Scheduler::Examples::SchedulableModel` which is a bare class that just includes the `Scheduler::Schedulable` module, and also an `Scheduler::Examples::ExecutableClass` class which is a bare implementation of an executable class.
|
26
|
-
An executable class is just a plain Ruby class which must implement a `call` method which accepts
|
26
|
+
An executable class is just a plain Ruby class which must implement a `call` method which accepts the same arguments that you passed to the schedulable model attribute `args`.
|
27
|
+
Also, the executable class, must have the first argument of its `initialize` method to accept the current instance of the schedulable model.
|
27
28
|
|
28
29
|
First start by running the scheduler:
|
29
30
|
```bash
|
@@ -2,11 +2,12 @@ module Scheduler
|
|
2
2
|
module Examples
|
3
3
|
class ExecutableClass
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(job)
|
6
|
+
@job = job
|
6
7
|
end
|
7
8
|
|
8
|
-
def call(
|
9
|
-
job.log :info, 'Example of execution.'
|
9
|
+
def call(*args)
|
10
|
+
@job.log :info, 'Example of execution.'
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -126,12 +126,12 @@ module Scheduler
|
|
126
126
|
#
|
127
127
|
# @return [Object] the instanced executable_class.
|
128
128
|
def perform(pid = nil)
|
129
|
-
job = self.executable_class.new(
|
129
|
+
job = self.executable_class.new(self)
|
130
130
|
raise Scheduler::Error.new "#{self.executable_class} does not implement method 'call'. Please make "\
|
131
131
|
"sure to implement it before performing the job." unless job.respond_to? :call
|
132
132
|
self.status!(:running)
|
133
133
|
self.update(pid: pid) if pid.present?
|
134
|
-
job.call(self)
|
134
|
+
job.call(*self.args)
|
135
135
|
self.completed_at = Time.current
|
136
136
|
if self.status == :running
|
137
137
|
self.progress!(100)
|
data/lib/scheduler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongodb-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Ballardin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|