dronejob 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -25
- data/README.md +0 -4
- data/dronejob.gemspec +1 -2
- data/lib/dronejob.rb +0 -4
- data/lib/dronejob/base.rb +0 -3
- data/lib/dronejob/command.rb +3 -21
- data/lib/dronejob/version.rb +1 -1
- metadata +6 -24
- data/lib/dronejob/modules/queue.rb +0 -78
- data/lib/dronejob/railtie.rb +0 -25
- data/lib/dronejob/railties/dronejob.rake +0 -5
- data/lib/dronejob/server.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a63ea40c1eec60c227ff462f07e631976b3559434eee2ef791931823c7806cf
|
4
|
+
data.tar.gz: 8bf04ed23e899f5b65c3fa5f77d4cf9fffc1ccf8ef1428e82c51751ee26251bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5513d3f5cbb14d2e3f4d7cb53d10343f441567908dd7013152ca4efb7d640d7fc1e41cde665e55882345c2a9f6d01c56de21de4e1170daeee39fbd14293945fe
|
7
|
+
data.tar.gz: 51be755b012d8a2e847cb70b5dfb29d0bed271fc4038a14ff8a7065b077fb0548ad9086d063dfbd7959c683a03af2ad9d3b3fb80794503a58456f5ed3453dddb
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dronejob (3.0.
|
4
|
+
dronejob (3.0.1)
|
5
5
|
actionpack (>= 4.0.2, < 5.0.0)
|
6
6
|
activejob (>= 4.0.2, < 5.0.0)
|
7
|
-
|
7
|
+
bigdecimal (~> 1.4)
|
8
8
|
bundler (>= 1.12.0, < 3.0.0)
|
9
9
|
git (>= 1.3)
|
10
10
|
google-cloud-logging (>= 1.2)
|
11
|
-
pusher (>= 1.3)
|
12
11
|
thor (>= 0.19)
|
13
12
|
workspace (>= 2.0)
|
14
13
|
workspace-archive (>= 2.0)
|
@@ -35,11 +34,6 @@ GEM
|
|
35
34
|
activejob (4.2.11.3)
|
36
35
|
activesupport (= 4.2.11.3)
|
37
36
|
globalid (>= 0.3.0)
|
38
|
-
activejob-google-cloud-pubsub (0.7.3)
|
39
|
-
activejob
|
40
|
-
activesupport
|
41
|
-
concurrent-ruby
|
42
|
-
google-cloud-pubsub (>= 0.27.0)
|
43
37
|
activesupport (4.2.11.3)
|
44
38
|
i18n (~> 0.7)
|
45
39
|
minitest (~> 5.1)
|
@@ -48,6 +42,7 @@ GEM
|
|
48
42
|
addressable (2.7.0)
|
49
43
|
public_suffix (>= 2.0.2, < 5.0)
|
50
44
|
ast (2.4.1)
|
45
|
+
bigdecimal (1.4.4)
|
51
46
|
builder (3.2.4)
|
52
47
|
coderay (1.1.3)
|
53
48
|
concurrent-ruby (1.1.6)
|
@@ -76,13 +71,6 @@ GEM
|
|
76
71
|
googleapis-common-protos (>= 1.3.9, < 2.0)
|
77
72
|
googleapis-common-protos-types (>= 1.0.4, < 2.0)
|
78
73
|
stackdriver-core (~> 1.3)
|
79
|
-
google-cloud-pubsub (1.8.0)
|
80
|
-
concurrent-ruby (~> 1.1)
|
81
|
-
google-cloud-core (~> 1.2)
|
82
|
-
google-gax (~> 1.8)
|
83
|
-
googleapis-common-protos (>= 1.3.9, < 2.0)
|
84
|
-
googleapis-common-protos-types (>= 1.0.4, < 2.0)
|
85
|
-
grpc-google-iam-v1 (~> 0.6.9)
|
86
74
|
google-gax (1.8.1)
|
87
75
|
google-protobuf (~> 3.9)
|
88
76
|
googleapis-common-protos (>= 1.3.9, < 2.0)
|
@@ -106,14 +94,9 @@ GEM
|
|
106
94
|
grpc (1.30.1-universal-darwin)
|
107
95
|
google-protobuf (~> 3.12)
|
108
96
|
googleapis-common-protos-types (~> 1.0)
|
109
|
-
grpc-google-iam-v1 (0.6.10)
|
110
|
-
google-protobuf (~> 3.11)
|
111
|
-
googleapis-common-protos (>= 1.3.10, < 2.0)
|
112
|
-
grpc (~> 1.27)
|
113
97
|
haml (5.1.2)
|
114
98
|
temple (>= 0.8.0)
|
115
99
|
tilt
|
116
|
-
httpclient (2.8.3)
|
117
100
|
i18n (0.9.5)
|
118
101
|
concurrent-ruby (~> 1.0)
|
119
102
|
jwt (2.2.1)
|
@@ -143,11 +126,6 @@ GEM
|
|
143
126
|
method_source (~> 1.0)
|
144
127
|
psych (3.2.0)
|
145
128
|
public_suffix (4.0.5)
|
146
|
-
pusher (1.3.3)
|
147
|
-
httpclient (~> 2.7)
|
148
|
-
multi_json (~> 1.0)
|
149
|
-
pusher-signature (~> 0.1.8)
|
150
|
-
pusher-signature (0.1.8)
|
151
129
|
rack (1.6.13)
|
152
130
|
rack-test (0.6.3)
|
153
131
|
rack (>= 1.0)
|
data/README.md
CHANGED
data/dronejob.gemspec
CHANGED
@@ -16,10 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_dependency "bundler", "< 3.0.0", ">= 1.12.0"
|
17
17
|
s.add_runtime_dependency "actionpack", ">= 4.0.2", "< 5.0.0"
|
18
18
|
s.add_runtime_dependency "activejob", ">= 4.0.2", "< 5.0.0"
|
19
|
-
s.add_runtime_dependency "
|
19
|
+
s.add_runtime_dependency "bigdecimal", "~> 1.4"
|
20
20
|
s.add_runtime_dependency "git", ">= 1.3"
|
21
21
|
s.add_runtime_dependency "google-cloud-logging", ">= 1.2"
|
22
|
-
s.add_runtime_dependency "pusher", ">= 1.3"
|
23
22
|
s.add_runtime_dependency "thor", ">= 0.19"
|
24
23
|
s.add_runtime_dependency "workspace", ">= 2.0"
|
25
24
|
s.add_runtime_dependency "workspace-archive", ">= 2.0"
|
data/lib/dronejob.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
-
require 'activejob_google_cloud_pubsub'
|
2
1
|
require "google/cloud/logging"
|
3
2
|
require "active_support"
|
4
3
|
require 'active_support/rails'
|
5
|
-
require "dronejob/server"
|
6
4
|
require "dronejob/version"
|
7
5
|
require "psych"
|
8
6
|
|
9
|
-
require 'dronejob/railtie' if defined?(Rails)
|
10
|
-
|
11
7
|
module Dronejob
|
12
8
|
extend ActiveSupport::Autoload
|
13
9
|
autoload :Base
|
data/lib/dronejob/base.rb
CHANGED
@@ -9,7 +9,6 @@ require 'dronejob/modules/callbacks'
|
|
9
9
|
require 'dronejob/modules/core'
|
10
10
|
require 'dronejob/modules/git'
|
11
11
|
require 'dronejob/modules/log'
|
12
|
-
require 'dronejob/modules/queue'
|
13
12
|
require 'dronejob/modules/options'
|
14
13
|
require 'dronejob/modules/params'
|
15
14
|
require 'dronejob/modules/phases'
|
@@ -23,7 +22,6 @@ module Dronejob
|
|
23
22
|
include Modules::Core
|
24
23
|
include Modules::Git
|
25
24
|
include Modules::Options
|
26
|
-
include Modules::Queue
|
27
25
|
include Modules::Params
|
28
26
|
include Modules::Phases
|
29
27
|
include Modules::Workspace
|
@@ -39,7 +37,6 @@ module Dronejob
|
|
39
37
|
|
40
38
|
rescue_from(Exception) do |exception|
|
41
39
|
error_rescue(exception) if respond_to?(:error_rescue)
|
42
|
-
publish_error(exception)
|
43
40
|
error(exception)
|
44
41
|
end
|
45
42
|
|
data/lib/dronejob/command.rb
CHANGED
@@ -4,14 +4,12 @@ require "active_job"
|
|
4
4
|
module Dronejob
|
5
5
|
class Command < Thor
|
6
6
|
Dronejob::Loader.workers(:base).each do |identifier, worker|
|
7
|
-
desc identifier, "
|
7
|
+
desc identifier, "Run #{identifier} worker"
|
8
8
|
|
9
9
|
# Worker options
|
10
|
-
method_option(:run, aliases: "-r", type: :boolean, default: false)
|
11
10
|
method_option(:break, aliases: "-b", type: :boolean, default: false)
|
12
11
|
method_option(:skip, aliases: "-s", type: :array, default: [])
|
13
12
|
method_option(:from, aliases: "-f", type: :string)
|
14
|
-
method_option(:notify, aliases: "-n", type: :boolean, default: true)
|
15
13
|
method_option(:jobs_path, type: :string)
|
16
14
|
method_option(:output_path, type: :string)
|
17
15
|
|
@@ -24,13 +22,8 @@ module Dronejob
|
|
24
22
|
Dronejob::Base.jobs_path = options.jobs_path if options.jobs_path
|
25
23
|
Dronejob::Base.output_path = options.output_path if options.output_path
|
26
24
|
|
27
|
-
# Execute
|
28
|
-
|
29
|
-
worker.perform_now(options)
|
30
|
-
else
|
31
|
-
job = worker.perform_later(options.to_hash)
|
32
|
-
Dronejob::Base.log("info", "Enqueued job #{job.job_id}")
|
33
|
-
end
|
25
|
+
# Execute job
|
26
|
+
worker.perform_now(options)
|
34
27
|
end
|
35
28
|
end
|
36
29
|
|
@@ -87,16 +80,5 @@ module Dronejob
|
|
87
80
|
job_params["from"] = options.from
|
88
81
|
worker.perform_now(job_params)
|
89
82
|
end
|
90
|
-
|
91
|
-
desc :server, "Start Dronejob Server"
|
92
|
-
def server
|
93
|
-
server = Server.new(Dronejob::Base.options)
|
94
|
-
begin
|
95
|
-
server.start
|
96
|
-
rescue Interrupt
|
97
|
-
server.stop
|
98
|
-
exit
|
99
|
-
end
|
100
|
-
end
|
101
83
|
end
|
102
84
|
end
|
data/lib/dronejob/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dronejob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Strebitzer
|
@@ -71,19 +71,19 @@ dependencies:
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 5.0.0
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
74
|
+
name: bigdecimal
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- - "
|
77
|
+
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '
|
79
|
+
version: '1.4'
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - "
|
84
|
+
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '
|
86
|
+
version: '1.4'
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: git
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,20 +112,6 @@ dependencies:
|
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '1.2'
|
115
|
-
- !ruby/object:Gem::Dependency
|
116
|
-
name: pusher
|
117
|
-
requirement: !ruby/object:Gem::Requirement
|
118
|
-
requirements:
|
119
|
-
- - ">="
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
version: '1.3'
|
122
|
-
type: :runtime
|
123
|
-
prerelease: false
|
124
|
-
version_requirements: !ruby/object:Gem::Requirement
|
125
|
-
requirements:
|
126
|
-
- - ">="
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
version: '1.3'
|
129
115
|
- !ruby/object:Gem::Dependency
|
130
116
|
name: thor
|
131
117
|
requirement: !ruby/object:Gem::Requirement
|
@@ -279,11 +265,7 @@ files:
|
|
279
265
|
- lib/dronejob/modules/options.rb
|
280
266
|
- lib/dronejob/modules/params.rb
|
281
267
|
- lib/dronejob/modules/phases.rb
|
282
|
-
- lib/dronejob/modules/queue.rb
|
283
268
|
- lib/dronejob/modules/workspace.rb
|
284
|
-
- lib/dronejob/railtie.rb
|
285
|
-
- lib/dronejob/railties/dronejob.rake
|
286
|
-
- lib/dronejob/server.rb
|
287
269
|
- lib/dronejob/version.rb
|
288
270
|
homepage: https://github.com/MagLoft/dronejob
|
289
271
|
licenses:
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require "pry"
|
2
|
-
require "pusher"
|
3
|
-
|
4
|
-
module Dronejob
|
5
|
-
module Modules
|
6
|
-
module Queue
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
queue_as option(:dronejob_queue) || :dronejob
|
11
|
-
set_callback :phase, :before, :notify_before_phase
|
12
|
-
set_callback :job, :after, :notify_after_job
|
13
|
-
end
|
14
|
-
|
15
|
-
class_methods do
|
16
|
-
def pubsub
|
17
|
-
emulator_host = option(:google_cloud_pubsub_emulator_host)
|
18
|
-
@pubsub ||= Google::Cloud::Pubsub.new(project_id: option(:google_cloud_project_id), credentials: option(:google_cloud_service_account), timeout: 60, emulator_host: emulator_host)
|
19
|
-
end
|
20
|
-
|
21
|
-
def queue_adapter
|
22
|
-
@queue_adapter ||= ActiveJob::GoogleCloudPubsub::Adapter.new(async: false, logger: logger, pubsub: pubsub)
|
23
|
-
end
|
24
|
-
|
25
|
-
def notify(value = true)
|
26
|
-
@notify = value
|
27
|
-
end
|
28
|
-
|
29
|
-
def notify?
|
30
|
-
!!@notify
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def pusher_client
|
35
|
-
@pusher_client ||= Pusher::Client.new(
|
36
|
-
app_id: option(:pusher_app_id),
|
37
|
-
key: option(:pusher_key),
|
38
|
-
secret: option(:pusher_secret),
|
39
|
-
cluster: option(:pusher_cluster),
|
40
|
-
encrypted: true
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
def publish_status(data = {}, status = "working")
|
45
|
-
data[:action] = "update_process"
|
46
|
-
data[:user_id] = param(:user_id)
|
47
|
-
data[:jid] = job_id
|
48
|
-
data[:worker] = Loader.identifier_for(self)
|
49
|
-
data[:timestamp] = Time.now.to_i
|
50
|
-
data[:status] = status
|
51
|
-
return false if data[:user_id].nil?
|
52
|
-
|
53
|
-
pusher_client.trigger("private-#{data[:user_id]}", "process", data)
|
54
|
-
end
|
55
|
-
|
56
|
-
def publish_error(event)
|
57
|
-
publish_status({ title: self.title, description: event.message, phase: @phase, progress: 100 }, "failed") if should_notify?
|
58
|
-
end
|
59
|
-
|
60
|
-
def notify_before_phase
|
61
|
-
publish_status({ title: self.title, description: @phase_config[:title], phase: @phase, progress: @phase_config[:progress] }, "working") if @phase_config[:notify] and should_notify?
|
62
|
-
end
|
63
|
-
|
64
|
-
def notify_after_job
|
65
|
-
publish_status({ title: self.title, description: "Job Completed!", phase: @phase, progress: 100 }, "complete") if should_notify?
|
66
|
-
end
|
67
|
-
|
68
|
-
def should_notify?
|
69
|
-
self.class.notify? and param(:notify) and !param(:run)
|
70
|
-
end
|
71
|
-
|
72
|
-
def publish_progress(progress, description = nil, details = {})
|
73
|
-
message = { title: self.title, description: description, phase: @phase, progress: progress, details: details }
|
74
|
-
publish_status(message, "working") if should_notify?
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/lib/dronejob/railtie.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'global_id/railtie'
|
2
|
-
require 'dronejob'
|
3
|
-
|
4
|
-
module Dronejob
|
5
|
-
# = Dronejob Railtie
|
6
|
-
class Railtie < Rails::Railtie
|
7
|
-
config.dronejob = ActiveSupport::OrderedOptions.new
|
8
|
-
|
9
|
-
initializer 'dronejob.logger' do
|
10
|
-
ActiveSupport.on_load(:dronejob) { self.logger = ::Rails.logger }
|
11
|
-
end
|
12
|
-
|
13
|
-
initializer "dronejob.set_configs" do |app|
|
14
|
-
options = app.config.dronejob
|
15
|
-
|
16
|
-
ActiveSupport.on_load(:dronejob) do
|
17
|
-
options.each { |k, v| send("#{k}=", v) }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
rake_tasks do
|
22
|
-
load "dronejob/railties/dronejob.rake"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/dronejob/server.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Dronejob
|
2
|
-
class Dronejob::Server
|
3
|
-
attr_reader :worker, :queue
|
4
|
-
|
5
|
-
def initialize(options)
|
6
|
-
@queue = options.dronejob_queue || "drone"
|
7
|
-
end
|
8
|
-
|
9
|
-
def start
|
10
|
-
@worker = ActiveJob::GoogleCloudPubsub::Worker.new(queue: @queue, pubsub: Dronejob::Base.pubsub)
|
11
|
-
Dronejob::Base.log("info", "Starting server for queue #{@queue} ...", nil)
|
12
|
-
@worker.run
|
13
|
-
end
|
14
|
-
|
15
|
-
def stop
|
16
|
-
Dronejob::Base.log("info", "Stopping server ...", nil)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|