async-job-adapter-active_job 0.1.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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/async/job/adapter/active_job/queue_adapter.rb +40 -0
- data/lib/async/job/adapter/active_job/railtie.rb +41 -0
- data/lib/async/job/adapter/active_job/service.rb +32 -0
- data/lib/async/job/adapter/active_job/version.rb +14 -0
- data/lib/async/job/adapter/active_job.rb +9 -0
- data/license.md +21 -0
- data/readme.md +49 -0
- data.tar.gz.sig +4 -0
- metadata +107 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e5bc238dcba4866e573e4e386f1d26117d666d25c8efd1fc47c062a36daca4dd
|
4
|
+
data.tar.gz: fc2c1da33a3d490a8c98c510c4ced40ee6f1374b70f7643ed25acfacfcfb3684
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0ce16c1b4812fffc4b6e396ade664e3db380c67e5884123d7a65ec7f7f43ee887948dea5ba52d3253d28760ab9314995ca086fc473863c5405b72e6b2ace42cb
|
7
|
+
data.tar.gz: e020340bec9824af95b34c71a87d519aac0688023e55ab98055eee53ab61665d8a1659018112a27d4005577ce0a480252f2698dea7fb1f010cc5cf31ca776204
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
module Async
|
7
|
+
module Job
|
8
|
+
module Adapter
|
9
|
+
module ActiveJob
|
10
|
+
class QueueAdapter
|
11
|
+
def initialize(server, coder = JSON)
|
12
|
+
@server = server
|
13
|
+
@coder = coder
|
14
|
+
end
|
15
|
+
|
16
|
+
def enqueue(job)
|
17
|
+
Console.info(self, "Enqueueing job...", id: job.job_id)
|
18
|
+
@server.enqueue(@coder.dump(job.serialize))
|
19
|
+
end
|
20
|
+
|
21
|
+
def enqueue_at(job, timestamp)
|
22
|
+
Console.info(self, "Enqueueing job at...", id: job.job_id, timestamp: timestamp)
|
23
|
+
@server.schedule(@coder.dump(job.serialize), timestamp)
|
24
|
+
end
|
25
|
+
|
26
|
+
def start
|
27
|
+
Async do
|
28
|
+
@server.start
|
29
|
+
|
30
|
+
@server.each do |id, data|
|
31
|
+
job = @coder.parse(data)
|
32
|
+
::ActiveJob::Base.execute(job)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require 'thread/local'
|
7
|
+
require 'async/redis/client'
|
8
|
+
require 'async/job/backend/redis/server'
|
9
|
+
|
10
|
+
module Async
|
11
|
+
module Job
|
12
|
+
module Adapter
|
13
|
+
module ActiveJob
|
14
|
+
class Railtie < ::Rails::Railtie
|
15
|
+
module Dispatcher
|
16
|
+
extend Thread::Local
|
17
|
+
|
18
|
+
def self.local
|
19
|
+
# We should load configuration from the Railtie...
|
20
|
+
|
21
|
+
client = Async::Redis::Client.new
|
22
|
+
server = Async::Job::Backend::Redis::Server.new(client, "async:job:active_job")
|
23
|
+
|
24
|
+
return QueueAdapter.new(server)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.enqueue(job)
|
28
|
+
self.instance.enqueue(job)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.enqueue_at(job, timestamp)
|
32
|
+
self.instance.enqueue_at(job, timestamp)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
config.active_job.queue_adapter = Dispatcher
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require 'async/service/generic'
|
7
|
+
|
8
|
+
module Async
|
9
|
+
module Job
|
10
|
+
module Adapter
|
11
|
+
module ActiveJob
|
12
|
+
class Service < Async::Service::Generic
|
13
|
+
def self.each
|
14
|
+
yield :service_class, self
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup(container)
|
18
|
+
container.run(name: self.name, restart: true) do |instance|
|
19
|
+
require File.expand_path('config/environment', @environment.evaluator.root)
|
20
|
+
|
21
|
+
instance.ready!
|
22
|
+
|
23
|
+
Sync do
|
24
|
+
Railtie::Dispatcher.instance.start
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative 'active_job/version'
|
7
|
+
require_relative 'active_job/queue_adapter'
|
8
|
+
|
9
|
+
require_relative "active_job/railtie" if defined?(Rails::Railtie)
|
data/license.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2024, by Samuel Williams.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Async::Job::Adapter::AsyncJob
|
2
|
+
|
3
|
+
Provides an adapter for ActiveJob on top of `Async::Job`.
|
4
|
+
|
5
|
+
[](https://github.com/socketry/async-job-adapter-active_job/actions?workflow=Test)
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Basically, just add this gem to your gemfile:
|
10
|
+
|
11
|
+
``` shell
|
12
|
+
$ bundle add async-job-adapter-active_job
|
13
|
+
```
|
14
|
+
|
15
|
+
To run a server, create a service file, e.g. `job-server.rb` with the following content:
|
16
|
+
|
17
|
+
``` ruby
|
18
|
+
#!/usr/bin/env async-service
|
19
|
+
|
20
|
+
require 'async/job/adapter/active_job/service'
|
21
|
+
|
22
|
+
service "job-server" do
|
23
|
+
include Async::Job::Adapter::ActiveJob::Service
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
Then run it:
|
28
|
+
|
29
|
+
``` shell
|
30
|
+
$ bundle exec ./job-server.rb
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
We welcome contributions to this project.
|
36
|
+
|
37
|
+
1. Fork it.
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`).
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
41
|
+
5. Create new Pull Request.
|
42
|
+
|
43
|
+
### Developer Certificate of Origin
|
44
|
+
|
45
|
+
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.
|
46
|
+
|
47
|
+
### Contributor Covenant
|
48
|
+
|
49
|
+
This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
|
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: async-job-adapter-active_job
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
14
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
15
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
16
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
17
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
18
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
19
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
20
|
+
9qZdoq9xt7H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RVuKkrKjqhYCdmMBqCws
|
35
|
+
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
36
|
+
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
37
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
|
+
-----END CERTIFICATE-----
|
40
|
+
date: 2024-02-24 00:00:00.000000000 Z
|
41
|
+
dependencies:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: async-job
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: thread-local
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
description:
|
71
|
+
email:
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/async/job/adapter/active_job.rb
|
77
|
+
- lib/async/job/adapter/active_job/queue_adapter.rb
|
78
|
+
- lib/async/job/adapter/active_job/railtie.rb
|
79
|
+
- lib/async/job/adapter/active_job/service.rb
|
80
|
+
- lib/async/job/adapter/active_job/version.rb
|
81
|
+
- license.md
|
82
|
+
- readme.md
|
83
|
+
homepage:
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata:
|
87
|
+
documentation_uri: https://socketry.github.io/async-job-adapter-active_job
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubygems_version: 3.5.3
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: A asynchronous job queue for Ruby on Rails.
|
107
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|