async-job 0.5.0 → 0.7.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: f0c2495e88bb7e1dd1636fd03290813e4d9ca0837157d9e6b145cb098e68a616
4
- data.tar.gz: 0e050ec503af7ac00c620bf822358a794dfa12c71d829850df2d668d09d9830e
3
+ metadata.gz: 75714ead23077e752af18aead579e3590187f0119a564024e0dbafe1f8c0ed82
4
+ data.tar.gz: bb3d48e293245743b6f9316f250a52f274c9c27928ba869551344ee1b83390f5
5
5
  SHA512:
6
- metadata.gz: 863fe9d09f5afacaf38e912d31cbaab011b019b7b3737f0fa21f196a4fb0b76f4b3da2169178ce1c20576b26cae8e98469707e2c3fbf01826670aa2638794524
7
- data.tar.gz: cfffcc7dc08d90a95109247341a0728e920305a2ebc55b3fe568970a674fe654c7aa7033ff12a6d4c0461ac0baf5057dfc0ee9bfc0816ae9f2e43397cb722195
6
+ metadata.gz: a28a7f19901b8376570e47963bd0aa3d10ba7c16440058d6da0dd74136ee7937448e4c3175ada2aad0a313540b963d6c7a17354c457c81960ade593570d35439
7
+ data.tar.gz: 82048073802bd9cfa18c29142e979e57af45f4916a62d41e327f688dbfce6be2f8ca7293db5df087458c2fff8212c878dd35611ea13730f885e8557351760e02
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ require 'console/event/failure'
7
+
8
+ module Async
9
+ module Job
10
+ module Backend
11
+ module Aggregate
12
+ class Server
13
+ def initialize(delegate, parent: nil)
14
+ @delegate = delegate
15
+
16
+ @task = nil
17
+ @ready = Async::Condition.new
18
+
19
+ @pending = Array.new
20
+ @processing = Array.new
21
+ end
22
+
23
+ def flush(jobs)
24
+ while job = jobs.shift
25
+ @delegate.call(job)
26
+ end
27
+ rescue => error
28
+ Console::Event::Failure.for(error).emit(self, "Could not flush #{jobs.size} jobs.")
29
+ end
30
+
31
+ def run
32
+ while true
33
+ while @pending.empty?
34
+ @ready.wait
35
+ end
36
+
37
+ # Swap the buffers:
38
+ @pending, @processing = @processing, @pending
39
+
40
+ flush(@processing)
41
+ end
42
+ end
43
+
44
+ def start!(parent: Async::Task.current)
45
+ @task ||= parent.async(transient: true) do
46
+ run
47
+ ensure
48
+ # Ensure that all jobs are flushed before we exit:
49
+ flush(@pending)
50
+ flush(@processing)
51
+ end
52
+ end
53
+
54
+ def call(job)
55
+ start!
56
+
57
+ @pending << job
58
+ @ready.signal
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ require_relative 'aggregate/server'
7
+
8
+ module Async
9
+ module Job
10
+ module Backend
11
+ module Aggregate
12
+ def self.new(delegate)
13
+ return Server.new(delegate)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -29,7 +29,7 @@ module Async
29
29
  end
30
30
 
31
31
  def queue(queue, *arguments, **options)
32
- # The delegate is the output side of the queue, e.g. a Queuedelegate or similar wrapper.
32
+ # The delegate is the output side of the queue, e.g. a Redis server delegate or similar wrapper.
33
33
  # The queue itself is instantiated with the delegate.
34
34
  @queue = ->(delegate){queue.new(delegate, *arguments, **options)}
35
35
  end
@@ -52,7 +52,11 @@ module Async
52
52
  end
53
53
 
54
54
  # We can now construct the queue with the delegate:
55
- producer = consumer = @queue.call(delegate)
55
+ if @queue
56
+ producer = consumer = @queue.call(delegate)
57
+ else
58
+ producer = consumer = delegate
59
+ end
56
60
 
57
61
  # We now construct the queue producer:
58
62
  @enqueue.reverse_each do |middleware|
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Job
8
- VERSION = "0.5.0"
8
+ VERSION = "0.7.0"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # MIT License
2
2
 
3
3
  Copyright, 2024, by Samuel Williams.
4
+ Copyright, 2024, by Alexey Ivanov.
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -12,6 +12,10 @@ Please see the [project documentation](https://socketry.github.io/async-job/) fo
12
12
 
13
13
  - [Redis Backend](https://socketry.github.io/async-job/guides/redis-backend/index) - This guide gives a brief overview of the implementation of the Redis backend.
14
14
 
15
+ ## See Also
16
+
17
+ - [async-job-adapter-active\_job](https://github.com/socketry/async-job-adapter-active_job) - ActiveJob adapter for `async-job`.
18
+
15
19
  ## Contributing
16
20
 
17
21
  We welcome contributions to this project.
@@ -24,12 +28,8 @@ We welcome contributions to this project.
24
28
 
25
29
  ### Developer Certificate of Origin
26
30
 
27
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
31
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
28
32
 
29
- ### Contributor Covenant
30
-
31
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
32
-
33
- ## See Also
33
+ ### Community Guidelines
34
34
 
35
- - [async-job-adapter-active_job](https://github.com/socketry/async-job-adapter-active_job) - ActiveJob adapter for `async-job`.
35
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,10 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - Alexey Ivanov
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain:
@@ -37,7 +38,7 @@ cert_chain:
37
38
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
39
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
40
  -----END CERTIFICATE-----
40
- date: 2024-03-06 00:00:00.000000000 Z
41
+ date: 2024-08-03 00:00:00.000000000 Z
41
42
  dependencies:
42
43
  - !ruby/object:Gem::Dependency
43
44
  name: async
@@ -75,6 +76,8 @@ extra_rdoc_files: []
75
76
  files:
76
77
  - lib/async/job.rb
77
78
  - lib/async/job/backend.rb
79
+ - lib/async/job/backend/aggregate.rb
80
+ - lib/async/job/backend/aggregate/server.rb
78
81
  - lib/async/job/backend/inline.rb
79
82
  - lib/async/job/backend/inline/server.rb
80
83
  - lib/async/job/backend/redis.rb
@@ -97,6 +100,7 @@ licenses:
97
100
  - MIT
98
101
  metadata:
99
102
  documentation_uri: https://socketry.github.io/async-job/
103
+ source_code_uri: https://github.com/socketry/async-job
100
104
  post_install_message:
101
105
  rdoc_options: []
102
106
  require_paths:
@@ -112,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
116
  - !ruby/object:Gem::Version
113
117
  version: '0'
114
118
  requirements: []
115
- rubygems_version: 3.5.3
119
+ rubygems_version: 3.5.11
116
120
  signing_key:
117
121
  specification_version: 4
118
122
  summary: A asynchronous job queue for Ruby.
metadata.gz.sig CHANGED
Binary file