disqualified 0.1.1 → 0.2.0

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
  SHA256:
3
- metadata.gz: ec05ac0a0d2eadb072a6cfddd164ae66d3dc14642234663917ebb02c824cecec
4
- data.tar.gz: 05f192048112ba00432dc7a1e9844e106f0515e7a7f835e65b2a646f9909b8b6
3
+ metadata.gz: fc97aaa11362ee9b3b2de020309c6ad083dce7c9c0dfa8337efdac9dc6194f81
4
+ data.tar.gz: d78e23de661b6e78cffa4a46253ad3abd7a00715593307fe043d5d24776df820
5
5
  SHA512:
6
- metadata.gz: 23ac21c0d08bd70540746321ba5f6cf427d75027acf49f2f4a4295ad6a52fbcaa821f35b40369d99108e4d6dd7d0ad5c04100cb4d7b6a9a10419cd8129fb8c2f
7
- data.tar.gz: eb6495ae699c5a1a9414f54924af2a90b583b5ab249e6437f067696416f2807a3871d164b8ac8ee2c4139ae7342e644658b64fa207f4a8d6c7c664c37a42842e
6
+ metadata.gz: ddca0e4fa03d30f0c974003baa82be69d56e17128eb8a4a3d9643fda4a021562eb805b128b02f1d797213d23ef4be5c9d93e053f7a15abb52c9725a8fd51d2a6
7
+ data.tar.gz: 79aa2ca84d392afb379c9a3ad9987b0df49ce0189deb1bde5d0ba3fc325e43b14da03e394296feacc785d32ff01955dabbcd7422930f442e53197d851011af50
data/README.md CHANGED
@@ -6,12 +6,35 @@ Since SQLite doesn't have any features like Postgres' `LISTEN`/`NOTIFY`,
6
6
  Disqualified resorts to polling the database. This might _disqualify_ it as an
7
7
  option for you, but it works well enough for my workload.
8
8
 
9
- Disqualified only works with Rails. It does not work with ActiveJob.
9
+ Disqualified only works with Rails. You can use it with ActiveJob or by itself.
10
10
 
11
11
 
12
12
  ## Usage
13
13
 
14
- Run `bundle exec disqualified --help`
14
+ Run `bundle exec disqualified --help` for more information on how to run the
15
+ Disqualified server.
16
+
17
+
18
+ ### Defining a job
19
+
20
+ ```ruby
21
+ class ComplicatedJob
22
+ include Disqualified::Job
23
+
24
+ def perform(arg1, arg2)
25
+ # ...
26
+ end
27
+ end
28
+ ```
29
+
30
+
31
+ ### Queuing
32
+
33
+ ```ruby
34
+ ComplicatedJob.perform_async(1, 2)
35
+ ComplicatedJob.perform_in(1.minute, 1, 2)
36
+ ComplicatedJob.perform_at(3.days.from_now, 1, 2)
37
+ ```
15
38
 
16
39
 
17
40
  ## Installation
@@ -25,6 +48,24 @@ bundle binstub disqualified
25
48
  ```
26
49
 
27
50
 
51
+ ### ActiveJob
52
+
53
+ You can optionally set up Disqualified as ActiveJob's default backend.
54
+
55
+ Usually, you'll just need to update your `config/environments/production.rb`
56
+ file to include something like this.
57
+
58
+ ```ruby
59
+ require "disqualified/active_job"
60
+
61
+ Rails.application.configure do
62
+ # ...
63
+ config.active_job.queue_adapter = :disqualified
64
+ # ...
65
+ end
66
+ ```
67
+
68
+
28
69
  ## Contributing
29
70
 
30
71
  PRs are welcome! Please confirm the change with me before you start working;
@@ -0,0 +1,25 @@
1
+ require "active_job"
2
+ require "disqualified"
3
+
4
+ class Disqualified::ActiveJobAdapter
5
+ include Disqualified::Job
6
+
7
+ def perform(serialized_job_data)
8
+ ::ActiveJob::Base.execute(serialized_job_data)
9
+ end
10
+ end
11
+
12
+ module ActiveJob
13
+ module QueueAdapters
14
+ class DisqualifiedAdapter
15
+ def enqueue(job_data)
16
+ Disqualified::ActiveJobAdapter.perform_async(job_data.serialize)
17
+ end
18
+
19
+ def enqueue_at(job_data, timestamp)
20
+ timestamp = Time.at(timestamp)
21
+ Disqualified::ActiveJobAdapter.perform_at(timestamp, job_data.serialize)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -29,7 +29,7 @@ class Disqualified::CLI
29
29
  logger.info { ' / /_/ / (__ ) /_/ / /_/ / /_/ / / / __/ / __/ /_/ /' }
30
30
  logger.info { '/_____/_/____/\__, /\__,_/\__,_/_/_/_/ /_/\___/\__,_/' }
31
31
  logger.info { ' /_/' + "v#{Disqualified::VERSION}".rjust(32, " ") }
32
- logger.info { "#{Disqualified.server_options.to_s}" }
32
+ logger.info { Disqualified.server_options.to_s }
33
33
 
34
34
  pool = Disqualified::Pool.new(delay_range:, pool_size:, logger:) do |args|
35
35
  args => { promise_index:, running: }
@@ -6,7 +6,7 @@ module Disqualified::Job
6
6
  module ClassMethods
7
7
  def perform_at(the_time, *args)
8
8
  Disqualified::Record.create(
9
- handler: self.name,
9
+ handler: name,
10
10
  arguments: JSON.dump(args),
11
11
  queue: "default",
12
12
  run_at: the_time
@@ -9,7 +9,7 @@ class Disqualified::Main
9
9
  def call
10
10
  run_id = SecureRandom.uuid
11
11
 
12
- Rails.application.executor.wrap do
12
+ Rails.application.reloader.wrap do
13
13
  # Claim a job
14
14
  claimed_count =
15
15
  Disqualified::Record
@@ -1,3 +1,3 @@
1
1
  module Disqualified
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disqualified
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: concurrent-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: mocktail
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -62,12 +76,12 @@ extra_rdoc_files: []
62
76
  files:
63
77
  - LICENSE
64
78
  - README.md
65
- - app/assets/config/disqualified_manifest.js
66
79
  - app/models/disqualified/base_record.rb
67
80
  - app/models/disqualified/record.rb
68
81
  - config/routes.rb
69
82
  - exe/disqualified
70
83
  - lib/disqualified.rb
84
+ - lib/disqualified/active_job.rb
71
85
  - lib/disqualified/cli.rb
72
86
  - lib/disqualified/engine.rb
73
87
  - lib/disqualified/job.rb
@@ -79,7 +93,6 @@ files:
79
93
  - lib/generators/disqualified/install/USAGE
80
94
  - lib/generators/disqualified/install/install_generator.rb
81
95
  - lib/generators/disqualified/install/templates/20220703062536_create_disqualified_jobs.rb
82
- - lib/tasks/disqualified_tasks.rake
83
96
  homepage: https://github.com/zachahn/disqualified
84
97
  licenses:
85
98
  - LGPL-3.0-only
File without changes
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :disqualified do
3
- # # Task goes here
4
- # end