dronejob 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cae818f5050ff58791380e627c546e63efdddca
4
- data.tar.gz: 1131b202e4e2edf76fecfd6367003bc93d85baac
3
+ metadata.gz: dcc5382dd0f52edabfea18b2b88953e96ded21f7
4
+ data.tar.gz: f682bf69fbd79bb557d75acb5df2778d7eeb2aa4
5
5
  SHA512:
6
- metadata.gz: e0c6d490e93388f63e4bf6a19e3ff87d5f711408b12902554f8a5deecb3e4bbdaeb9cf28b8e874e9ffab8c8355e71bd3886612b7c5e1dbca21a95b5d158d1b9d
7
- data.tar.gz: 24e8e35a177f6130e02f5acefde34bfb96e530246cb25880e7d679c4ae65ce25462ceebe78862747ce877e1253603fdcb4cd7f5d596b2f752c300846cd84e1bf
6
+ metadata.gz: fe7d008500c92512d507a0c684b615e18173aa392638affe1766638f3d704f31cc9740997e851bcf961b9a036c7558b8861d459dff6425f0f2a75368d4a1183f
7
+ data.tar.gz: d0824a0944f77dabe82eed36b79f96282d1ef865889493a2e068b079d522f6a6e73d75775861f21c162eac0b1f71e01510d58ece1b2753ec5eac94bb9e77bd93
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  /*.gem
2
2
  app/*
3
3
  tmp/*
4
+ plugins/*
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- gem "gcloud", github: "GoogleCloudPlatform/gcloud-ruby", branch: "master"
data/Gemfile.lock CHANGED
@@ -1,94 +1,44 @@
1
- GIT
2
- remote: git://github.com/GoogleCloudPlatform/gcloud-ruby.git
3
- revision: bde4915fe7baffae8326ed93b4ffcf3dc2de7c54
4
- branch: master
5
- specs:
6
- gcloud (0.6.1)
7
- beefcake (~> 1.0)
8
- digest-crc (~> 0.4)
9
- google-api-client (~> 0.8.3)
10
- mime-types (~> 2.4)
11
- zonefile (~> 1.04)
12
-
13
1
  PATH
14
2
  remote: .
15
3
  specs:
16
- dronejob (1.0.2)
4
+ dronejob (1.0.3)
17
5
  activejob (~> 4.2)
18
6
  bundler (~> 1.11)
19
- gcloud (~> 0.6)
20
7
  git (~> 1.2)
21
8
  rake (~> 10.5)
9
+ sidekiq (~> 4.1.0)
10
+ sidekiq-status (~> 0.6.0)
22
11
  thor (~> 0.19)
23
12
 
24
13
  GEM
25
14
  remote: http://rubygems.org/
26
15
  specs:
27
- activejob (4.2.5.1)
28
- activesupport (= 4.2.5.1)
16
+ activejob (4.2.6)
17
+ activesupport (= 4.2.6)
29
18
  globalid (>= 0.3.0)
30
- activesupport (4.2.5.1)
19
+ activesupport (4.2.6)
31
20
  i18n (~> 0.7)
32
21
  json (~> 1.7, >= 1.7.7)
33
22
  minitest (~> 5.1)
34
23
  thread_safe (~> 0.3, >= 0.3.4)
35
24
  tzinfo (~> 1.1)
36
- addressable (2.4.0)
37
- autoparse (0.3.3)
38
- addressable (>= 2.3.1)
39
- extlib (>= 0.9.15)
40
- multi_json (>= 1.0.0)
41
- beefcake (1.1.0)
42
25
  coderay (1.1.0)
26
+ concurrent-ruby (1.0.1)
27
+ connection_pool (2.2.0)
43
28
  diff-lcs (1.2.5)
44
- digest-crc (0.4.1)
45
- extlib (0.9.16)
46
- faraday (0.9.2)
47
- multipart-post (>= 1.2, < 3)
48
- git (1.2.9.1)
29
+ git (1.3.0)
49
30
  globalid (0.3.6)
50
31
  activesupport (>= 4.1.0)
51
- google-api-client (0.8.6)
52
- activesupport (>= 3.2)
53
- addressable (~> 2.3)
54
- autoparse (~> 0.3)
55
- extlib (~> 0.9)
56
- faraday (~> 0.9)
57
- googleauth (~> 0.3)
58
- launchy (~> 2.4)
59
- multi_json (~> 1.10)
60
- retriable (~> 1.4)
61
- signet (~> 0.6)
62
- googleauth (0.5.1)
63
- faraday (~> 0.9)
64
- jwt (~> 1.4)
65
- logging (~> 2.0)
66
- memoist (~> 0.12)
67
- multi_json (~> 1.11)
68
- os (~> 0.9)
69
- signet (~> 0.7)
70
32
  i18n (0.7.0)
71
33
  json (1.8.3)
72
- jwt (1.5.2)
73
- launchy (2.4.3)
74
- addressable (~> 2.3)
75
- little-plugger (1.1.4)
76
- logging (2.0.0)
77
- little-plugger (~> 1.1)
78
- multi_json (~> 1.10)
79
- memoist (0.14.0)
80
34
  method_source (0.8.2)
81
- mime-types (2.99)
82
35
  minitest (5.8.4)
83
- multi_json (1.11.2)
84
- multipart-post (2.0.0)
85
- os (0.9.6)
86
36
  pry (0.10.3)
87
37
  coderay (~> 1.1.0)
88
38
  method_source (~> 0.8.1)
89
39
  slop (~> 3.4)
90
40
  rake (10.5.0)
91
- retriable (1.4.1)
41
+ redis (3.2.2)
92
42
  rspec (3.4.0)
93
43
  rspec-core (~> 3.4.0)
94
44
  rspec-expectations (~> 3.4.0)
@@ -102,24 +52,23 @@ GEM
102
52
  diff-lcs (>= 1.2.0, < 2.0)
103
53
  rspec-support (~> 3.4.0)
104
54
  rspec-support (3.4.1)
105
- signet (0.7.2)
106
- addressable (~> 2.3)
107
- faraday (~> 0.9)
108
- jwt (~> 1.5)
109
- multi_json (~> 1.10)
55
+ sidekiq (4.1.0)
56
+ concurrent-ruby (~> 1.0)
57
+ connection_pool (~> 2.2, >= 2.2.0)
58
+ redis (~> 3.2, >= 3.2.1)
59
+ sidekiq-status (0.6.0)
60
+ sidekiq (>= 2.7)
110
61
  slop (3.6.0)
111
62
  thor (0.19.1)
112
63
  thread_safe (0.3.5)
113
64
  tzinfo (1.2.2)
114
65
  thread_safe (~> 0.1)
115
- zonefile (1.04)
116
66
 
117
67
  PLATFORMS
118
68
  ruby
119
69
 
120
70
  DEPENDENCIES
121
71
  dronejob!
122
- gcloud!
123
72
  pry (~> 0.10)
124
73
  rspec (~> 3.3)
125
74
 
data/dronejob.gemspec CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.add_runtime_dependency "rake", "~> 10.5"
19
19
  s.add_runtime_dependency "git", "~> 1.2"
20
20
  s.add_runtime_dependency "thor", "~> 0.19"
21
+ s.add_runtime_dependency "sidekiq", "~> 4.1.0"
22
+ s.add_runtime_dependency "sidekiq-status", "~> 0.6.0"
21
23
  s.add_runtime_dependency "activejob", "~> 4.2"
22
- s.add_runtime_dependency "gcloud", "~> 0.6"
23
24
  s.add_development_dependency "rspec", "~> 3.3"
24
25
  s.add_development_dependency "pry", "~> 0.10"
25
26
  s.files = `git ls-files`.split("\n")
data/lib/dronejob/base.rb CHANGED
@@ -3,20 +3,23 @@ require 'dronejob/modules/attr_store'
3
3
  require 'dronejob/modules/core'
4
4
  require 'dronejob/modules/git'
5
5
  require 'dronejob/modules/log'
6
+ require 'dronejob/modules/queue'
7
+ require 'dronejob/modules/options'
6
8
  require 'dronejob/modules/params'
7
9
  require 'dronejob/modules/phases'
8
- require 'dronejob/modules/pub_sub'
9
10
  require 'dronejob/modules/workspace'
10
11
 
11
12
  module Dronejob
12
13
  class Base < ActiveJob::Base
14
+ queue_as :dronejob
13
15
  include Modules::AttrStore
14
16
  include Modules::Core
15
17
  include Modules::Git
16
18
  include Modules::Log
19
+ include Modules::Queue
20
+ include Modules::Options
17
21
  include Modules::Params
18
22
  include Modules::Phases
19
- include Modules::PubSub
20
23
  include Modules::Workspace
21
24
 
22
25
  ActiveSupport.run_load_hooks(:dronejob, self)
@@ -7,10 +7,7 @@ module Dronejob
7
7
  desc identifier, "Queue #{identifier} worker"
8
8
 
9
9
  # Pub/Sub options
10
- method_option(:project_id, type: :string, required: true)
11
- method_option(:queue_topic, type: :string, required: false)
12
- method_option(:status_topic, type: :string, required: false)
13
- method_option(:queue_adapter, type: :string, default: "dronejob_queue")
10
+ method_option(:queue_adapter, type: :string, default: "sidekiq")
14
11
 
15
12
  # Worker options
16
13
  method_option(:run, aliases: "-r", type: :boolean, default: false)
@@ -28,10 +25,7 @@ module Dronejob
28
25
  end
29
26
 
30
27
  define_method(identifier) do
31
- ActiveJob::Base.queue_adapter = options.queue_adapter
32
- Dronejob::Base.project_id = options.project_id
33
- Dronejob::Base.queue_topic = options.queue_topic if options.queue_topic
34
- Dronejob::Base.status_topic = options.status_topic if options.status_topic
28
+ Dronejob::Base.queue_adapter = options.queue_adapter
35
29
  Dronejob::Base.jobs_path = options.jobs_path if options.jobs_path
36
30
  Dronejob::Base.output_path = options.output_path if options.output_path
37
31
 
@@ -63,22 +57,15 @@ module Dronejob
63
57
  end
64
58
 
65
59
  desc :server, "Start Dronejob Server"
66
- method_option(:queue_adapter, type: :string, default: "dronejob_queue", enum: ["dronejob_queue"])
67
- method_option(:project_id, type: :string, required: true)
68
- method_option(:queue_topic, type: :string, required: false)
69
- method_option(:status_topic, type: :string, required: false)
60
+ method_option(:queue_adapter, type: :string, default: "sidekiq", enum: ["sidekiq"])
70
61
  method_option(:jobs_path, type: :string)
71
62
  method_option(:output_path, type: :string)
72
63
  def server
73
- ActiveJob::Base.queue_adapter = options.queue_adapter
74
- Dronejob::Base.project_id = options.project_id
75
- Dronejob::Base.queue_topic = options.queue_topic if options.queue_topic
76
- Dronejob::Base.status_topic = options.status_topic if options.status_topic
64
+ Dronejob::Base.queue_adapter = options.queue_adapter if options.queue_adapter
77
65
  Dronejob::Base.jobs_path = options.jobs_path if options.jobs_path
78
66
  Dronejob::Base.output_path = options.output_path if options.output_path
79
67
 
80
68
  # Run worker
81
- Dronejob::Base.log("info", "Subscribing to topic #{Dronejob::Base.queue_topic} in project #{Dronejob::Base.project_id}")
82
69
  Dronejob::Base.run_worker!
83
70
  end
84
71
 
@@ -25,11 +25,11 @@ module Dronejob
25
25
  self.class.attr_stores.each do |key|
26
26
  variables[key] = instance_variable_get("@#{key}")
27
27
  end
28
- file_write(".dronejob-variables", Psych.dump(variables))
28
+ file_write("dronejob.yml", Psych.dump(variables))
29
29
  end
30
30
 
31
31
  def load_variables
32
- yaml_file = File.join(working_dir, ".dronejob-variables")
32
+ yaml_file = File.join(working_dir, "dronejob.yml")
33
33
  variables = File.exists?(yaml_file) ? Psych.load_file(yaml_file) : {}
34
34
  variables.each do |key, value|
35
35
  instance_variable_set("@#{key}", value)
@@ -12,14 +12,29 @@ module Dronejob
12
12
  validate_parameters!
13
13
  create_working_dir
14
14
  load_variables
15
- git_init(@working_dir, param(:from))
15
+
16
+ git_init(@working_dir)
17
+ git_collect_commits
18
+ git_commit("start")
19
+ if param(:from)
20
+ info("starting from phase #{param(:from)}")
21
+ phase = prev_phase(param(:from))
22
+ raise("phase '#{param(:from)}' not found!") if phase.nil? or @commits[phase.to_s].nil?
23
+ git_reset(phase.to_s)
24
+ else
25
+ git_reset
26
+ end
27
+ git_collect_commits
28
+ git_clean
16
29
 
17
30
  # Run through phases
18
31
  each_phase do |phase, config|
19
32
  begin
20
33
  phase_result = public_send(phase)
21
34
  rescue Exception => e
22
- error(e)
35
+ error(e.message)
36
+ error(e.backtrace.join("\n"))
37
+ return false
23
38
  end
24
39
  publish_status(phase_result) if config[:notify]
25
40
  git_commit(phase)
@@ -6,17 +6,11 @@ module Dronejob
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- attr_accessor :from
10
- attr_reader :git
9
+ attr_reader :git, :commits
11
10
  end
12
11
 
13
- def git_init(path, commit=nil)
12
+ def git_init(path)
14
13
  @git = ::Git.init(path)
15
- git_collect_commits
16
- git_commit("start")
17
- git_reset(commit)
18
- git_collect_commits
19
- git_clean
20
14
  end
21
15
 
22
16
  def git_commit(commit)
@@ -46,11 +40,7 @@ module Dronejob
46
40
 
47
41
  def git_reset(commit=nil)
48
42
  if commit
49
- info("resetting to phase '#{commit}'")
50
- from_index = @commits.keys.index(commit)
51
- error("phase '#{commit}' not found!") if from_index.nil? or !@commits.keys[from_index]
52
- previous = @commits.keys[from_index]
53
- @git.reset_hard(@commits[previous])
43
+ @git.reset_hard(@commits[commit])
54
44
  else
55
45
  @git.reset_hard()
56
46
  end
@@ -0,0 +1,35 @@
1
+ module Dronejob
2
+ module Modules
3
+ module Options
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ attr_reader :options
8
+ end
9
+
10
+ module ClassMethods
11
+ def options
12
+ if @options.nil?
13
+ yaml_file = File.join("dronejob.yml")
14
+ yaml_options = File.exists?(yaml_file) ? Psych.load_file(yaml_file) : default_options
15
+ @options = OpenStruct.new(default_options.merge(yaml_options))
16
+ end
17
+ @options
18
+ end
19
+
20
+ def default_options
21
+ {redis_url: "redis://127.0.0.1:6379"}
22
+ end
23
+ end
24
+
25
+ def options
26
+ self.class.options
27
+ end
28
+
29
+ def option(key)
30
+ self.class.options.send(key)
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -45,6 +45,14 @@ module Dronejob
45
45
  def skip_phase?(phase)
46
46
  param(:skip) and param(:skip).include?(phase.to_s)
47
47
  end
48
+
49
+ def prev_phase(phase)
50
+ phases = self.class.phases.keys
51
+ index = phases.index(phase.to_sym)
52
+ return nil if index.nil?
53
+ return "start" if index == 0
54
+ phases[index - 1]
55
+ end
48
56
 
49
57
  end
50
58
  end
@@ -0,0 +1,32 @@
1
+ module Dronejob
2
+ module Modules
3
+ module Queue
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ attr_accessor :queue_adapter
8
+ end
9
+
10
+ module ClassMethods
11
+ def run_worker!
12
+ ActiveJob::Base.queue_adapter = self.queue_adapter
13
+ require 'sidekiq/cli'
14
+ $:.push("./")
15
+ cli = Sidekiq::CLI.instance
16
+ cli.parse(["-qdronejob", "-rlib/dronejob/server/sidekiq.rb"])
17
+ cli.run
18
+ end
19
+ end
20
+
21
+ def publish_status(result=nil)
22
+ data = {phase: @phase, result: result}
23
+ Redis.new({url: option(:redis_url)}).publish(self.publish_channel, data.to_json)
24
+ end
25
+
26
+ def publish_channel
27
+ "dronejob"
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,5 @@
1
+ require "dronejob/workspace_file"
2
+ require "dronejob/workspace_dir"
1
3
  module Dronejob
2
4
  module Modules
3
5
  module Workspace
@@ -8,6 +10,14 @@ module Dronejob
8
10
  cattr_accessor(:jobs_path) { "app/jobs" }
9
11
  cattr_accessor(:output_path) { "tmp/jobs" }
10
12
  end
13
+
14
+ def file(path)
15
+ WorkspaceFile.new(working_dir, path)
16
+ end
17
+
18
+ def dir(path)
19
+ WorkspaceDir.new(working_dir, path)
20
+ end
11
21
 
12
22
  def create_working_dir
13
23
  @working_dir = File.join(self.class.output_path, uuid)
@@ -16,11 +26,53 @@ module Dronejob
16
26
 
17
27
  def file_write(target_path, contents)
18
28
  full_path = File.join(working_dir, target_path)
19
- open(full_path, "wb") do |file|
20
- file << contents
21
- end
29
+ open(full_path, "wb"){|file| file << contents}
22
30
  full_path
23
31
  end
32
+
33
+ def file_create_path(*args)
34
+ path = File.join(working_dir, *args)
35
+ FileUtils.mkdir_p(path)
36
+ path
37
+ end
38
+
39
+ def file_replace_contents(target_path, &block)
40
+ binding.pry
41
+ contents = File.open(target_path).read
42
+ contents = block.call(contents)
43
+ file_write(target_path, contents)
44
+ end
45
+
46
+ def file_delete_path(*args)
47
+ binding.pry
48
+ path = File.join(*args)
49
+ FileUtils.rm_rf(path)
50
+ path
51
+ end
52
+
53
+ def file_parse_haml(haml_path, output_path, options={})
54
+ binding.pry
55
+ engine = Haml::Engine.new(haml_path)
56
+ open(output_path, 'wb') do |file|
57
+ file << engine.render(Object.new, options)
58
+ end
59
+ end
60
+
61
+ def file_root_dir
62
+ binding.pry
63
+ File.expand_path("../../../", __FILE__)
64
+ end
65
+
66
+ def file_data_path(target_path)
67
+ binding.pry
68
+ File.join(Gem.datadir("app-drone"), target_path)
69
+ end
70
+
71
+ def file_data_contents(target_path)
72
+ binding.pry
73
+ path = file_data_path(target_path)
74
+ File.open(path).read
75
+ end
24
76
 
25
77
  end
26
78
  end
@@ -1,6 +1,5 @@
1
1
  namespace :dronejob do
2
2
  task :server => :environment do
3
- Dronejob::Base.log("info", "Subscribing to topic #{Dronejob::Base.queue_topic} in project #{Dronejob::Base.project_id}")
4
3
  Dronejob::Base.run_worker!
5
4
  end
6
5
  end
@@ -0,0 +1,7 @@
1
+ require "sidekiq-status"
2
+ Sidekiq.configure_server do |config|
3
+ config.redis = { url: Dronejob::Base.options.redis_url }
4
+ config.server_middleware do |chain|
5
+ chain.add Sidekiq::Status::ServerMiddleware
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Dronejob
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -0,0 +1,11 @@
1
+ module Dronejob
2
+ class WorkspaceDir
3
+ attr_accessor :workspace, :path
4
+
5
+ def initialize(workspace, path)
6
+ @workspace = workspace
7
+ @path = path
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,43 @@
1
+ module Dronejob
2
+ class WorkspaceFile
3
+ attr_accessor :workspace, :path
4
+ attr_reader :contents
5
+
6
+ def initialize(workspace, path)
7
+ @workspace = workspace
8
+ @path = path
9
+ set(read) if exists?
10
+ end
11
+
12
+ def set(contents)
13
+ @contents = contents
14
+ self
15
+ end
16
+
17
+ def replace(key, value)
18
+ @contents.gsub!(key, value)
19
+ self
20
+ end
21
+
22
+ def write(contents=nil)
23
+ contents ||= @contents
24
+ File.open(full_path, "wb") do |file|
25
+ file << contents
26
+ end
27
+ self
28
+ end
29
+
30
+ def full_path
31
+ File.join(@workspace, @path)
32
+ end
33
+
34
+ def exists?
35
+ File.exists?(full_path)
36
+ end
37
+
38
+ def read
39
+ File.open(full_path).read
40
+ end
41
+
42
+ end
43
+ end
data/lib/dronejob.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "active_support"
2
2
  require 'active_support/rails'
3
- require "active_job/queue_adapters/dronejob_queue_adapter"
4
3
  require "dronejob/version"
5
4
 
6
5
  require 'dronejob/railtie' if defined?(Rails)
metadata CHANGED
@@ -1,125 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dronejob
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Strebitzer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-16 00:00:00.000000000 Z
11
+ date: 2016-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.11'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: git
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.19'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.19'
69
69
  - !ruby/object:Gem::Dependency
70
- name: activejob
70
+ name: sidekiq
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '4.2'
75
+ version: 4.1.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '4.2'
82
+ version: 4.1.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: gcloud
84
+ name: sidekiq-status
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.6'
89
+ version: 0.6.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.6.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: activejob
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
95
102
  - !ruby/object:Gem::Version
96
- version: '0.6'
103
+ version: '4.2'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '4.2'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rspec
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ~>
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
117
  version: '3.3'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ~>
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '3.3'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - ~>
129
+ - - "~>"
116
130
  - !ruby/object:Gem::Version
117
131
  version: '0.10'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - ~>
136
+ - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0.10'
125
139
  description: Scalable worker factory for ruby
@@ -130,13 +144,12 @@ executables:
130
144
  extensions: []
131
145
  extra_rdoc_files: []
132
146
  files:
133
- - .gitignore
147
+ - ".gitignore"
134
148
  - Gemfile
135
149
  - Gemfile.lock
136
150
  - README.md
137
151
  - bin/dronejob
138
152
  - dronejob.gemspec
139
- - lib/active_job/queue_adapters/dronejob_queue_adapter.rb
140
153
  - lib/dronejob.rb
141
154
  - lib/dronejob/base.rb
142
155
  - lib/dronejob/command.rb
@@ -145,13 +158,17 @@ files:
145
158
  - lib/dronejob/modules/core.rb
146
159
  - lib/dronejob/modules/git.rb
147
160
  - lib/dronejob/modules/log.rb
161
+ - lib/dronejob/modules/options.rb
148
162
  - lib/dronejob/modules/params.rb
149
163
  - lib/dronejob/modules/phases.rb
150
- - lib/dronejob/modules/pub_sub.rb
164
+ - lib/dronejob/modules/queue.rb
151
165
  - lib/dronejob/modules/workspace.rb
152
166
  - lib/dronejob/railtie.rb
153
167
  - lib/dronejob/railties/dronejob.rake
168
+ - lib/dronejob/server/sidekiq.rb
154
169
  - lib/dronejob/version.rb
170
+ - lib/dronejob/workspace_dir.rb
171
+ - lib/dronejob/workspace_file.rb
155
172
  homepage: https://github.com/MagLoft/dronejob
156
173
  licenses:
157
174
  - BSD-3-Clause
@@ -162,17 +179,17 @@ require_paths:
162
179
  - lib
163
180
  required_ruby_version: !ruby/object:Gem::Requirement
164
181
  requirements:
165
- - - ~>
182
+ - - "~>"
166
183
  - !ruby/object:Gem::Version
167
184
  version: '2.0'
168
185
  required_rubygems_version: !ruby/object:Gem::Requirement
169
186
  requirements:
170
- - - ~>
187
+ - - "~>"
171
188
  - !ruby/object:Gem::Version
172
189
  version: '2.4'
173
190
  requirements: []
174
191
  rubyforge_project:
175
- rubygems_version: 2.5.1
192
+ rubygems_version: 2.4.5.1
176
193
  signing_key:
177
194
  specification_version: 4
178
195
  summary: DroneJob Drone Factory
@@ -1,19 +0,0 @@
1
- require "gcloud"
2
- module ActiveJob
3
- module QueueAdapters
4
- class DronejobQueueAdapter
5
- class << self
6
-
7
- def enqueue(job)
8
- Dronejob::Base.log("info", "Enqueuing worker #{job.class.name} with job id #{job.job_id}")
9
- Dronejob::Base.publish_job(job)
10
- end
11
-
12
- def enqueue_at(*)
13
- raise NotImplementedError.new("Delayed execution is not supported on Google Cloud Pub Sub.")
14
- end
15
-
16
- end
17
- end
18
- end
19
- end
@@ -1,60 +0,0 @@
1
- require "gcloud"
2
-
3
- module Dronejob
4
- module Modules
5
- module PubSub
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- cattr_accessor(:project_id) { "default" }
10
- cattr_accessor(:queue_topic) { "dronejob_queue" }
11
- cattr_accessor(:status_topic) { "dronejob_status" }
12
- end
13
-
14
- module ClassMethods
15
-
16
- def pubsub
17
- @pubsub ||= Gcloud.new(project_id).pubsub
18
- end
19
-
20
- def publish_job(job)
21
- publish(queue_topic, job.serialize)
22
- end
23
-
24
- def publish_status(job, detail)
25
- publish(status_topic, {job_id: job.job_id, detail: detail})
26
- end
27
-
28
- def publish(topic_name, data)
29
- topic = pubsub.topic(topic_name)
30
- topic.publish(data.to_json)
31
- end
32
-
33
- def run_worker!
34
- subscribe(queue_topic, true) do |data|
35
- begin
36
- ActiveJob::Base.deserialize(data).perform_now()
37
- rescue Exception => e
38
- log("error", e)
39
- end
40
- end
41
- end
42
-
43
- def subscribe(topic_name, autoack=true, &block)
44
- topic = pubsub.topic(topic_name)
45
- subscription = topic.subscription(topic_name)
46
- topic.subscribe(topic_name) if subscription.nil? or !subscription.exists?
47
- subscription.listen autoack: autoack do |message|
48
- block.call(JSON.parse(message.data))
49
- end
50
- end
51
-
52
- end
53
-
54
- def publish_status(result=nil)
55
- self.class.publish_status(self, {phase: @phase, result: result})
56
- end
57
-
58
- end
59
- end
60
- end