async-job 0.11.0 → 0.11.1
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 +4 -4
- checksums.yaml.gz.sig +2 -3
- data/context/aggregate-queue.md +19 -0
- data/context/getting-started.md +75 -0
- data/context/index.yaml +20 -0
- data/context/inline-queue.md +17 -0
- data/lib/async/job/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +5 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e3a0d320ec9bea1f6e7417bba2e2d6f738e217fe234a78e411d968fd85e358
|
4
|
+
data.tar.gz: d516887d48045aad5e9f88b71884fbbfb49c07bbaaf7da117d3c02d410483400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10ea8b43a19ca2d8aac3f99589d8b049bb64fca9e0c517ceed85071f08ac40e95396bc6c95aee4c2a995e726cfdca5abd3704066deb03f9629842e679435c0c6
|
7
|
+
data.tar.gz: 1e5aa618908e7caf4eaa2caa034557603a87e3e2a435ab13d16a1d253977ea0163bd46643f059800fe17db05152ecc3220e3b8dfd255dec762f93b2fbcc58317
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
hB���I�'�#=�)�`�,��=��"$�9�Q@���$J��w2��ɠ�/�%\po!j�'Rx��0C�F��'�$Y��U�Z�,�eA֘h��j�G��8�L;�c������1�ܹ�qV�N�4�?��
|
1
|
+
'�
|
2
|
+
i5
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Aggregate Queue
|
2
|
+
|
3
|
+
This guide explains how to use the Aggregate queue to reduce input latency and improve the performance of your application.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
The {ruby Async::Job::Queue::Aggregate} queue is designed to reduce front-end processing latency by accumulating multiple jobs which are then processed together. This is particularly useful when you are scheduling jobs during a request-response cycle, as it allows you to move processing latency to a background task. However, as a consequence, it may reduce the overall robustness of your application, as a failure during processing may result in jobs being lost. The aggregate queue tries to mitigate this risk by ensuring all pending jobs are processed before the application exits, but it is not guaranteed.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
You can add the aggregate queue to an existing queue:
|
12
|
+
|
13
|
+
~~~ ruby
|
14
|
+
pipeline = Async::Job::Builder.build(buffer) do
|
15
|
+
# Aggregating before passing the job into Redis will avoid Redis latency issues affecting the front-end:
|
16
|
+
enqueue Async::Job::Queue::Aggregate
|
17
|
+
dequeue Async::Job::Queue::Redis
|
18
|
+
end
|
19
|
+
~~~
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Getting Started
|
2
|
+
|
3
|
+
This guide gives you an overview of the `async-job` gem and explains the core concepts.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add the gem to your project:
|
8
|
+
|
9
|
+
``` shell
|
10
|
+
$ bundle add async-job
|
11
|
+
```
|
12
|
+
|
13
|
+
## Core Concepts
|
14
|
+
|
15
|
+
`async-job` is a library for building asynchronous job queues.
|
16
|
+
|
17
|
+
- Several included {ruby Async::Job::Queue} implementations for enqueueing and running jobs.
|
18
|
+
- Several supported {ruby Async::Job::Coder} implementations for encoding and decoding job payloads.
|
19
|
+
- A {ruby Async::Job::Generic} class which describes the minimum required job interface.
|
20
|
+
|
21
|
+
The `async-job` library provides a framework for enqueueing and dequeuing jobs, without prescribing how jobs are executed. It is expected that you would use this library to wrap existing schemas for job definition and execution. This design allows you to use `async-job` in a wide variety of applications, without the need for cumbersome wrappers.
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
In general, a job processing system pipeline comprises two parts: a client that submits jobs into a queue, and a server that reads jobs out of a queue and processes them.
|
26
|
+
|
27
|
+
```mermaid
|
28
|
+
sequenceDiagram
|
29
|
+
participant A as Client (Application)
|
30
|
+
participant ME as Middleware (Enqueue)
|
31
|
+
participant S as Server (Queue)
|
32
|
+
participant MD as Middleware (Dequeue)
|
33
|
+
participant H as Delegate
|
34
|
+
|
35
|
+
Note over A,S: Client
|
36
|
+
A->>+ME: Submit Job
|
37
|
+
ME->>+S: Enqueue Job
|
38
|
+
|
39
|
+
Note over S,H: Server
|
40
|
+
S->>+MD: Dequeue Job
|
41
|
+
MD->>+H: Execute Job
|
42
|
+
```
|
43
|
+
|
44
|
+
You can use {ruby Async::Job::Builder} to create a pipeline that includes both the producer and consumer sides of a queue:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require "async"
|
48
|
+
require "async/job"
|
49
|
+
require "async/job/processor/inline"
|
50
|
+
|
51
|
+
# This is how we execute a job from the queue:
|
52
|
+
executor = proc do |job|
|
53
|
+
puts "Processing job: #{job}"
|
54
|
+
end
|
55
|
+
|
56
|
+
# Create a simple inline pipeline:
|
57
|
+
pipeline = Async::Job::Builder.build(executor) do
|
58
|
+
# We are going to use an inline processor which processes the job in the background using Async{}:
|
59
|
+
enqueue Async::Job::Processor::Inline
|
60
|
+
end
|
61
|
+
|
62
|
+
# Enqueue a job:
|
63
|
+
Async do
|
64
|
+
pipeline.call("My job")
|
65
|
+
# Prints "Processing job: My job"
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
## Rails Integration
|
70
|
+
|
71
|
+
You can use `async-job` with Rails's ActiveJob framework by using the `async-job-adapter-active_job` gem. This allows you to use `async-job` as a backend for ActiveJob, which is useful for integrating with existing Rails applications.
|
72
|
+
|
73
|
+
### Redis Processor
|
74
|
+
|
75
|
+
The `async-job-processor-redis` gem provides a Redis-based processor for `async-job`. This processor is similar to Sidekiq, and is designed to provide a similar interface and feature set.
|
data/context/index.yaml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Automatically generated context index for Utopia::Project guides.
|
2
|
+
# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
|
3
|
+
---
|
4
|
+
description: An asynchronous job queue for Ruby.
|
5
|
+
metadata:
|
6
|
+
documentation_uri: https://socketry.github.io/async-job/
|
7
|
+
source_code_uri: https://github.com/socketry/async-job
|
8
|
+
files:
|
9
|
+
- path: getting-started.md
|
10
|
+
title: Getting Started
|
11
|
+
description: This guide gives you an overview of the `async-job` gem and explains
|
12
|
+
the core concepts.
|
13
|
+
- path: inline-queue.md
|
14
|
+
title: Inline Queue
|
15
|
+
description: This guide explains how to use the Inline queue to execute background
|
16
|
+
jobs.
|
17
|
+
- path: aggregate-queue.md
|
18
|
+
title: Aggregate Queue
|
19
|
+
description: This guide explains how to use the Aggregate queue to reduce input
|
20
|
+
latency and improve the performance of your application.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Inline Queue
|
2
|
+
|
3
|
+
This guide explains how to use the Inline queue to execute background jobs.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
The {ruby Async::Job::Queue::Inline} queue is designed to process jobs in the background using the `Async` framework. This is particularly useful when you want to execute jobs in the same process as the client, but in a separate task. The inline queue is ideal for low-latency jobs that do not require transactional consistency.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
You can use the inline queue for dequeueing and executing jobs:
|
12
|
+
|
13
|
+
~~~ ruby
|
14
|
+
pipeline = Async::Job::Builder.build(buffer) do
|
15
|
+
dequeue Async::Job::Queue::Inline
|
16
|
+
end
|
17
|
+
~~~
|
data/lib/async/job/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -74,6 +74,10 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- context/aggregate-queue.md
|
78
|
+
- context/getting-started.md
|
79
|
+
- context/index.yaml
|
80
|
+
- context/inline-queue.md
|
77
81
|
- lib/async/job.rb
|
78
82
|
- lib/async/job/buffer.rb
|
79
83
|
- lib/async/job/builder.rb
|
metadata.gz.sig
CHANGED
Binary file
|