zizq 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
- data/LICENSE +21 -0
- data/README.md +94 -0
- data/bin/profile-worker +145 -0
- data/bin/zizq-worker +174 -0
- data/lib/active_job/queue_adapters/zizq_adapter.rb +109 -0
- data/lib/zizq/ack_processor.rb +132 -0
- data/lib/zizq/active_job_config.rb +122 -0
- data/lib/zizq/backoff.rb +50 -0
- data/lib/zizq/bulk_enqueue.rb +87 -0
- data/lib/zizq/client.rb +982 -0
- data/lib/zizq/configuration.rb +164 -0
- data/lib/zizq/enqueue_request.rb +178 -0
- data/lib/zizq/enqueue_with.rb +109 -0
- data/lib/zizq/error.rb +43 -0
- data/lib/zizq/job.rb +188 -0
- data/lib/zizq/job_config.rb +244 -0
- data/lib/zizq/lifecycle.rb +58 -0
- data/lib/zizq/middleware.rb +79 -0
- data/lib/zizq/query.rb +566 -0
- data/lib/zizq/resources/error_enumerator.rb +241 -0
- data/lib/zizq/resources/error_page.rb +19 -0
- data/lib/zizq/resources/error_record.rb +19 -0
- data/lib/zizq/resources/job.rb +124 -0
- data/lib/zizq/resources/job_page.rb +57 -0
- data/lib/zizq/resources/page.rb +77 -0
- data/lib/zizq/resources/resource.rb +45 -0
- data/lib/zizq/resources.rb +16 -0
- data/lib/zizq/version.rb +9 -0
- data/lib/zizq/worker.rb +467 -0
- data/lib/zizq.rb +269 -0
- data/sig/generated/zizq/ack_processor.rbs +73 -0
- data/sig/generated/zizq/active_job_config.rbs +74 -0
- data/sig/generated/zizq/backoff.rbs +34 -0
- data/sig/generated/zizq/bulk_enqueue.rbs +72 -0
- data/sig/generated/zizq/client.rbs +419 -0
- data/sig/generated/zizq/configuration.rbs +95 -0
- data/sig/generated/zizq/enqueue_request.rbs +94 -0
- data/sig/generated/zizq/enqueue_with.rbs +88 -0
- data/sig/generated/zizq/error.rbs +41 -0
- data/sig/generated/zizq/job.rbs +136 -0
- data/sig/generated/zizq/job_config.rbs +150 -0
- data/sig/generated/zizq/lifecycle.rbs +34 -0
- data/sig/generated/zizq/middleware.rbs +50 -0
- data/sig/generated/zizq/query.rbs +327 -0
- data/sig/generated/zizq/resources/error_enumerator.rbs +148 -0
- data/sig/generated/zizq/resources/error_page.rbs +13 -0
- data/sig/generated/zizq/resources/error_record.rbs +20 -0
- data/sig/generated/zizq/resources/job.rbs +89 -0
- data/sig/generated/zizq/resources/job_page.rbs +33 -0
- data/sig/generated/zizq/resources/page.rbs +47 -0
- data/sig/generated/zizq/resources/resource.rbs +26 -0
- data/sig/generated/zizq/version.rbs +5 -0
- data/sig/generated/zizq/worker.rbs +152 -0
- data/sig/generated/zizq.rbs +180 -0
- data/sig/zizq.rbs +111 -0
- metadata +134 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Generated from lib/zizq/resources/resource.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
module Resources
|
|
5
|
+
# Base class for all typed response wrappers. Holds a reference to the
|
|
6
|
+
# Client (for following links) and the raw response hash.
|
|
7
|
+
class Resource
|
|
8
|
+
# Returns the client instance that returned this resource.
|
|
9
|
+
attr_reader client: Client
|
|
10
|
+
|
|
11
|
+
# @rbs client: Zizq::Client
|
|
12
|
+
# @rbs data: Hash[String, untyped]
|
|
13
|
+
# @rbs return: void
|
|
14
|
+
def initialize: (Zizq::Client client, Hash[String, untyped] data) -> void
|
|
15
|
+
|
|
16
|
+
# Returns the underlying raw response hash.
|
|
17
|
+
def to_h: () -> untyped
|
|
18
|
+
|
|
19
|
+
# Omit the client from inspect output to reduce noise.
|
|
20
|
+
def inspect: () -> untyped
|
|
21
|
+
|
|
22
|
+
# Convert a millisecond timestamp to fractional seconds, nil-safe.
|
|
23
|
+
def ms_to_seconds: (untyped value) -> untyped
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Generated from lib/zizq/worker.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
# Top-level worker process which orchestrates fetching jobs from the server
|
|
5
|
+
# and dispatching them to a pool of worker tasks for processing.
|
|
6
|
+
#
|
|
7
|
+
# Fiber support (when `fiber_count > 1`) creates an Async context. When
|
|
8
|
+
# `fiber_count == 1`, no Async context is created.
|
|
9
|
+
#
|
|
10
|
+
# Total concurrency is calculated as `thread_count * fiber_count`.
|
|
11
|
+
class Worker
|
|
12
|
+
DEFAULT_THREADS: Integer
|
|
13
|
+
|
|
14
|
+
DEFAULT_FIBERS: Integer
|
|
15
|
+
|
|
16
|
+
DEFAULT_RETRY_MIN_WAIT: ::Integer
|
|
17
|
+
|
|
18
|
+
DEFAULT_RETRY_MAX_WAIT: ::Integer
|
|
19
|
+
|
|
20
|
+
DEFAULT_RETRY_MULTIPLIER: ::Integer
|
|
21
|
+
|
|
22
|
+
# Convenience class method to create and run a worker.
|
|
23
|
+
def self.run: () -> untyped
|
|
24
|
+
|
|
25
|
+
# The total number of worker threads to run.
|
|
26
|
+
#
|
|
27
|
+
# For applications that are not threadsafe, this should be set to 1
|
|
28
|
+
# (default: 5).
|
|
29
|
+
attr_reader thread_count: Integer
|
|
30
|
+
|
|
31
|
+
# The total number of fibers to run within each worker thread.
|
|
32
|
+
#
|
|
33
|
+
# For applications that cannot handle multi-fiber execution, this should be
|
|
34
|
+
# set to 1. Any value greater than 1 runs workers inside an Async context
|
|
35
|
+
# (default: 1).
|
|
36
|
+
attr_reader fiber_count: Integer
|
|
37
|
+
|
|
38
|
+
# The set of queues from which to fetch jobs.
|
|
39
|
+
#
|
|
40
|
+
# An empty set (default) means all queues.
|
|
41
|
+
attr_reader queues: Array[String]
|
|
42
|
+
|
|
43
|
+
# The total number of jobs to allow to be sent from the server at once.
|
|
44
|
+
#
|
|
45
|
+
# Defaults to 2x the total concurrency (threads * fibers) to keep the
|
|
46
|
+
# pipeline full while ack round-trips are in flight.
|
|
47
|
+
attr_reader prefetch: Integer
|
|
48
|
+
|
|
49
|
+
# Proc to derive a worker ID string for each thread and fiber.
|
|
50
|
+
#
|
|
51
|
+
# When not present, the Zizq server assigns a random worker ID.
|
|
52
|
+
attr_reader worker_id_proc: (^(Integer, Integer) -> String?)?
|
|
53
|
+
|
|
54
|
+
# An instance of a Logger to be used for worker logging.
|
|
55
|
+
attr_reader logger: Logger
|
|
56
|
+
|
|
57
|
+
# The dispatcher used to handle each job.
|
|
58
|
+
#
|
|
59
|
+
# Defaults to the globally-configured `dequeue_middleware` chain.
|
|
60
|
+
# When a custom dispatcher is provided to `#initialize`, it is used as-is
|
|
61
|
+
# and the configured middleware chain is ignored. Caller may construct
|
|
62
|
+
# their own `Zizq::Middleware::Chain` if middleware needs to be applied.
|
|
63
|
+
attr_reader dispatcher: ^(Resources::Job) -> void
|
|
64
|
+
|
|
65
|
+
# @rbs queues: Array[String]
|
|
66
|
+
# @rbs thread_count: Integer
|
|
67
|
+
# @rbs fiber_count: Integer
|
|
68
|
+
# @rbs prefetch: Integer?
|
|
69
|
+
# @rbs retry_min_wait: (Float | Integer)
|
|
70
|
+
# @rbs retry_max_wait: (Float | Integer)
|
|
71
|
+
# @rbs retry_multiplier: (Float | Integer)
|
|
72
|
+
# @rbs worker_id: (^(Integer, Integer) -> String?)?
|
|
73
|
+
# @rbs logger: Logger?
|
|
74
|
+
# @rbs dispatcher: (^(Resources::Job) -> void)?
|
|
75
|
+
# @rbs return: void
|
|
76
|
+
def initialize: (?queues: Array[String], ?thread_count: Integer, ?fiber_count: Integer, ?prefetch: Integer?, ?retry_min_wait: Float | Integer, ?retry_max_wait: Float | Integer, ?retry_multiplier: Float | Integer, ?worker_id: (^(Integer, Integer) -> String?)?, ?logger: Logger?, ?dispatcher: (^(Resources::Job) -> void)?) -> void
|
|
77
|
+
|
|
78
|
+
# Request a graceful shutdown.
|
|
79
|
+
#
|
|
80
|
+
# Transitions the lifecycle to `:draining` and closes the dispatch
|
|
81
|
+
# queue. Worker threads finish any in-flight jobs, the ack processor
|
|
82
|
+
# flushes pending acks, and the producer stays connected to the server
|
|
83
|
+
# while all of that drains — only then is the streaming connection
|
|
84
|
+
# closed and `#run` returns.
|
|
85
|
+
#
|
|
86
|
+
# Safe to call from a signal handler (uses only atomic ivar assignment
|
|
87
|
+
# and `Thread::Queue#close`).
|
|
88
|
+
def stop: () -> untyped
|
|
89
|
+
|
|
90
|
+
# Request an immediate shutdown.
|
|
91
|
+
#
|
|
92
|
+
# Like `#stop`, but the streaming connection is closed immediately
|
|
93
|
+
# during teardown (rather than after workers drain), so the server
|
|
94
|
+
# re-dispatches any in-flight jobs after its visibility timeout. Use
|
|
95
|
+
# this when `#stop` has been given adequate time and still hasn't
|
|
96
|
+
# returned.
|
|
97
|
+
#
|
|
98
|
+
# In-progress jobs on worker threads continue to completion — we
|
|
99
|
+
# don't interrupt user code mid-execution — but no new jobs are
|
|
100
|
+
# pulled from the queue and cleanup uses short deadlines.
|
|
101
|
+
#
|
|
102
|
+
# Safe to call from a signal handler.
|
|
103
|
+
def kill: () -> untyped
|
|
104
|
+
|
|
105
|
+
# Start the worker.
|
|
106
|
+
#
|
|
107
|
+
# Spawns the desired number of worker threads and fibers, distributes
|
|
108
|
+
# jobs to those workers and then blocks until shutdown. Safe to call
|
|
109
|
+
# multiple times on the same Worker instance — all mutable runtime
|
|
110
|
+
# state (lifecycle, dispatch queue, ack processor, backoff) is reset
|
|
111
|
+
# at the start of each run.
|
|
112
|
+
def run: () -> untyped
|
|
113
|
+
|
|
114
|
+
private
|
|
115
|
+
|
|
116
|
+
# Reset all mutable runtime state so `#run` can be called multiple
|
|
117
|
+
# times on the same Worker instance. Called from `#initialize` and
|
|
118
|
+
# from the top of `#run`.
|
|
119
|
+
def reset_runtime_state: () -> untyped
|
|
120
|
+
|
|
121
|
+
def start_producer_thread: () -> untyped
|
|
122
|
+
|
|
123
|
+
def start_worker_threads: () -> untyped
|
|
124
|
+
|
|
125
|
+
# Internal worker run loop.
|
|
126
|
+
#
|
|
127
|
+
# Each worker thread or fiber continually pops jobs from the internal queue
|
|
128
|
+
# and dispatches them to the correct job class until the queue is closed
|
|
129
|
+
# and drained.
|
|
130
|
+
def run_loop: (untyped thread_idx, untyped fiber_idx) -> untyped
|
|
131
|
+
|
|
132
|
+
# Fiber-based worker loop. Requires the `async` gem.
|
|
133
|
+
def run_fiber_workers: (untyped thread_idx) -> untyped
|
|
134
|
+
|
|
135
|
+
# Process a single job.
|
|
136
|
+
#
|
|
137
|
+
# Delegates to the configured dispatcher (default: `Zizq::Job.dispatch`)
|
|
138
|
+
# and reports success or failure.
|
|
139
|
+
def dispatch: (untyped job, untyped worker_id) -> untyped
|
|
140
|
+
|
|
141
|
+
# @rbs job_id: String
|
|
142
|
+
# @rbs return: void
|
|
143
|
+
def push_ack: (String job_id) -> void
|
|
144
|
+
|
|
145
|
+
# @rbs job_id: String
|
|
146
|
+
# @rbs error: Exception
|
|
147
|
+
# @rbs return: void
|
|
148
|
+
def push_nack: (String job_id, Exception error) -> void
|
|
149
|
+
|
|
150
|
+
def resolve_worker_id: (untyped thread_idx, untyped fiber_idx) -> untyped
|
|
151
|
+
end
|
|
152
|
+
end
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Generated from lib/zizq.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
# Sentinel indicating a field should not be included in the request.
|
|
5
|
+
# Used as the default for update parameters.
|
|
6
|
+
module UNCHANGED
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Sentinel indicating a field should be sent as null to reset to server default.
|
|
10
|
+
module RESET
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Returns the client configuration.
|
|
14
|
+
#
|
|
15
|
+
# The configuration can be updated by calling [`Zizq::configure`].
|
|
16
|
+
#
|
|
17
|
+
# This configuration is for the client only. Worker parameters are
|
|
18
|
+
# configured on a per-run basis for flexibility.
|
|
19
|
+
def self.configuration: () -> untyped
|
|
20
|
+
|
|
21
|
+
# Yields the global configuration ready for updates, which should be done
|
|
22
|
+
# during application initialization, before any jobs are enqueued or
|
|
23
|
+
# worked.
|
|
24
|
+
#
|
|
25
|
+
# Zizq.configure do |c|
|
|
26
|
+
# c.url = "http://localhost:7890"
|
|
27
|
+
# c.format = :msgpack
|
|
28
|
+
# c.dequeue_middleware.use(MyDequeueMiddleware.new)
|
|
29
|
+
# end
|
|
30
|
+
def self.configure: () -> untyped
|
|
31
|
+
|
|
32
|
+
# Returns a shared client instance built from the global configuration.
|
|
33
|
+
#
|
|
34
|
+
# The client is memoized so that persistent HTTP connections are reused
|
|
35
|
+
# across calls, reducing TCP connection overhead.
|
|
36
|
+
def self.client: () -> untyped
|
|
37
|
+
|
|
38
|
+
# Resets all global state: configuration and shared client.
|
|
39
|
+
# Intended for use in tests.
|
|
40
|
+
def self.reset!: () -> untyped
|
|
41
|
+
|
|
42
|
+
# Server version string.
|
|
43
|
+
def self.server_version: () -> untyped
|
|
44
|
+
|
|
45
|
+
# List all distinct queue names on the server.
|
|
46
|
+
def self.queues: () -> untyped
|
|
47
|
+
|
|
48
|
+
# Start a query to retrieve or modify job data.
|
|
49
|
+
#
|
|
50
|
+
# @rbs id: (String | Array[String])?
|
|
51
|
+
# @rbs queue: (String | Array[String])?
|
|
52
|
+
# @rbs type: (String | Array[String])?
|
|
53
|
+
# @rbs status: (String | Array[String])?
|
|
54
|
+
# @rbs jq_filter: String?
|
|
55
|
+
# @rbs order: Zizq::sort_direction?
|
|
56
|
+
# @rbs limit: Integer?
|
|
57
|
+
# @rbs page_size: Integer?
|
|
58
|
+
# @rbs return: Zizq::Query
|
|
59
|
+
def self.query: () -> Zizq::Query
|
|
60
|
+
|
|
61
|
+
# Enqueue a job by class with positional and keyword arguments.
|
|
62
|
+
#
|
|
63
|
+
# By default all arguments are serialized as JSON, which means hashes with
|
|
64
|
+
# symbol keys will become hashes with string keys. The serialization
|
|
65
|
+
# behaviour can be changed by implementing `::zizq_serialize` and
|
|
66
|
+
# `::zizq_deserialize` as class methods on the job class.
|
|
67
|
+
#
|
|
68
|
+
# Default job options can be overridden at enqueue-time by providing a
|
|
69
|
+
# block which receives a mutable `Zizq::EnqueueRequest` instance.
|
|
70
|
+
#
|
|
71
|
+
# Zizq.enqueue(SendEmailJob, 42, template: "welcome")
|
|
72
|
+
# Zizq.enqueue(SendEmailJob, 42) { |o| o.queue = "priority" }
|
|
73
|
+
#
|
|
74
|
+
# Job classes may also override `::zizq_enqueue_options` to implement
|
|
75
|
+
# dynamically computed options, such as dynamic prioritisation. This class
|
|
76
|
+
# method accepts the same arguments as the `#perform` method and returns an
|
|
77
|
+
# instance of `Zizq::EnqueueRequest`. Any overrides may call `super` and
|
|
78
|
+
# modify the result.
|
|
79
|
+
#
|
|
80
|
+
# class SendEmailJob
|
|
81
|
+
# include Zizq::Job
|
|
82
|
+
#
|
|
83
|
+
# zizq_priority 1000
|
|
84
|
+
#
|
|
85
|
+
# def self.zizq_enqueue_options(user_id, template:)
|
|
86
|
+
# opts = super
|
|
87
|
+
# opts.priority /= 2 if template == "welcome"
|
|
88
|
+
# opts
|
|
89
|
+
# end
|
|
90
|
+
#
|
|
91
|
+
# def perform(user_id, template:)
|
|
92
|
+
# # ...
|
|
93
|
+
# end
|
|
94
|
+
# end
|
|
95
|
+
#
|
|
96
|
+
# @rbs job_class: Class & Zizq::job_class
|
|
97
|
+
# @rbs args: Array[untyped]
|
|
98
|
+
# @rbs kwargs: Hash[Symbol, untyped]
|
|
99
|
+
# @rbs &block: ?(EnqueueRequest) -> void
|
|
100
|
+
# @rbs return: Resources::Job
|
|
101
|
+
def self.enqueue: (Class & Zizq::job_class job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> Resources::Job
|
|
102
|
+
|
|
103
|
+
# Enqueue a job by providing raw inputs to the Zizq server.
|
|
104
|
+
#
|
|
105
|
+
# This is for advanced use cases such as enqueueing jobs for consumption in
|
|
106
|
+
# other programming languages.
|
|
107
|
+
#
|
|
108
|
+
# Zizq.enqueue_raw(
|
|
109
|
+
# queue: "emails",
|
|
110
|
+
# type: "send_email",
|
|
111
|
+
# payload: {user_id: 42, template: "welcome"}
|
|
112
|
+
# )
|
|
113
|
+
#
|
|
114
|
+
# If using this method to enqueue a job that is intended for consumption in
|
|
115
|
+
# the Ruby client itself a custom dispatcher implementation is likely
|
|
116
|
+
# required:
|
|
117
|
+
#
|
|
118
|
+
# Zizq.configure do |c|
|
|
119
|
+
# c.dispatcher = MyDispatcher.new
|
|
120
|
+
# end
|
|
121
|
+
#
|
|
122
|
+
# @rbs queue: String
|
|
123
|
+
# @rbs type: String
|
|
124
|
+
# @rbs payload: untyped
|
|
125
|
+
# @rbs priority: Integer?
|
|
126
|
+
# @rbs ready_at: Zizq::to_f?
|
|
127
|
+
# @rbs retry_limit: Integer?
|
|
128
|
+
# @rbs backoff: Zizq::backoff?
|
|
129
|
+
# @rbs retention: Zizq::retention?
|
|
130
|
+
# @rbs unique_key: String?
|
|
131
|
+
# @rbs unique_while: Zizq::unique_scope?
|
|
132
|
+
# @rbs return: Resources::Job
|
|
133
|
+
def self.enqueue_raw: (queue: String, type: String, payload: untyped, **untyped opts) -> Resources::Job
|
|
134
|
+
|
|
135
|
+
# Enqueue multiple jobs atomically in a single bulk request.
|
|
136
|
+
#
|
|
137
|
+
# This can significantly imprive throughput when many jobs need to be
|
|
138
|
+
# enqueued collectively. There is no upper limit on the number of jobs in
|
|
139
|
+
# the request though generally it is probably wise to keep this to less
|
|
140
|
+
# than 1000 jobs unless you have strong atomicity requuirements for a
|
|
141
|
+
# larger number of jobs..
|
|
142
|
+
#
|
|
143
|
+
# Yields a builder object whose `#enqueue` method accepts the same
|
|
144
|
+
# arguments as `Zizq.enqueue`. All collected jobs are sent as a
|
|
145
|
+
# single `POST /jobs/bulk` request and an array of jobs is returned in the
|
|
146
|
+
# same order as the inputs.
|
|
147
|
+
#
|
|
148
|
+
# Zizq.enqueue_bulk do |b|
|
|
149
|
+
# b.enqueue(ProcessPaymentJob, 7)
|
|
150
|
+
# b.enqueue(SendEmailJob, 42, template: "welcome")
|
|
151
|
+
# b.enqueue(SendEmailJob, 42) { |o| o.queue = "priority" }
|
|
152
|
+
# end
|
|
153
|
+
#
|
|
154
|
+
# Build a scoped enqueue helper that applies the given option overrides
|
|
155
|
+
# to every enqueue routed through it. Equivalent to using the block
|
|
156
|
+
# form of `Zizq.enqueue`, but composable and reusable.
|
|
157
|
+
#
|
|
158
|
+
# Zizq.enqueue_with(ready_at: Time.now + 3600).enqueue(MyJob, 42)
|
|
159
|
+
# Zizq.enqueue_with(priority: 0).enqueue_bulk { |b| ... }
|
|
160
|
+
#
|
|
161
|
+
# See `Zizq::EnqueueWith` for details.
|
|
162
|
+
#
|
|
163
|
+
# @rbs overrides: Hash[Symbol, untyped]
|
|
164
|
+
# @rbs return: EnqueueWith
|
|
165
|
+
def self.enqueue_with: (**untyped overrides) -> EnqueueWith
|
|
166
|
+
|
|
167
|
+
# @rbs &block: (BulkEnqueue) -> void
|
|
168
|
+
# @rbs return: Array[Resources::Job]
|
|
169
|
+
def self.enqueue_bulk: () { (BulkEnqueue) -> void } -> Array[Resources::Job]
|
|
170
|
+
|
|
171
|
+
# @api private
|
|
172
|
+
# Build an EnqueueRequest for a single job class enqueue.
|
|
173
|
+
#
|
|
174
|
+
# @rbs job_class: Class & Zizq::job_class
|
|
175
|
+
# @rbs args: Array[untyped]
|
|
176
|
+
# @rbs kwargs: Hash[Symbol, untyped]
|
|
177
|
+
# @rbs &block: ?(EnqueueRequest) -> void
|
|
178
|
+
# @rbs return: EnqueueRequest
|
|
179
|
+
def self.build_enqueue_request: (Class & Zizq::job_class job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> EnqueueRequest
|
|
180
|
+
end
|
data/sig/zizq.rbs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Copyright (c) 2026 Chris Corbyn <chris@zizq.io>
|
|
2
|
+
# Licensed under the MIT License. See LICENSE file for details.
|
|
3
|
+
|
|
4
|
+
# Manual RBS declarations that rbs-inline can't generate.
|
|
5
|
+
|
|
6
|
+
module Zizq
|
|
7
|
+
# Any object that can be converted to a Float (Time, Duration, Numeric, etc).
|
|
8
|
+
interface _ToF
|
|
9
|
+
def to_f: () -> Float
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
type to_f = _ToF
|
|
13
|
+
|
|
14
|
+
# Serialization format for communication with the server.
|
|
15
|
+
type format = :json | :msgpack
|
|
16
|
+
|
|
17
|
+
# Sort direction for paginated list endpoints.
|
|
18
|
+
type sort_direction = :asc | :desc
|
|
19
|
+
|
|
20
|
+
# Backoff configuration expressed in fractional seconds.
|
|
21
|
+
type backoff = { exponent: Float, base: Float, jitter: Float }
|
|
22
|
+
|
|
23
|
+
# Retention configuration expressed in fractional seconds.
|
|
24
|
+
type retention = { ?completed: Float, ?dead: Float }
|
|
25
|
+
|
|
26
|
+
# Uniqueness scope for deduplication at enqueue time.
|
|
27
|
+
type unique_scope = :queued | :active | :exists
|
|
28
|
+
|
|
29
|
+
# Filter parameters for bulk operations (delete, update) and list queries.
|
|
30
|
+
type where_params = {
|
|
31
|
+
?id: (String | Array[String])?,
|
|
32
|
+
?status: (String | Array[String])?,
|
|
33
|
+
?queue: (String | Array[String])?,
|
|
34
|
+
?type: (String | Array[String])?,
|
|
35
|
+
?filter: String?
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Update parameters for single and bulk update operations.
|
|
39
|
+
type apply_params = {
|
|
40
|
+
?queue: (String | singleton(UNCHANGED))?,
|
|
41
|
+
?priority: (Integer | singleton(UNCHANGED))?,
|
|
42
|
+
?ready_at: (to_f | singleton(RESET) | singleton(UNCHANGED))?,
|
|
43
|
+
?retry_limit: (Integer | singleton(RESET) | singleton(UNCHANGED))?,
|
|
44
|
+
?backoff: (backoff | singleton(RESET) | singleton(UNCHANGED))?,
|
|
45
|
+
?retention: (retention | singleton(RESET) | singleton(UNCHANGED))?
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# TLS options for connecting over HTTPS. Values are PEM strings or file paths.
|
|
49
|
+
type tls_options = { ?ca: String, ?client_cert: String, ?client_key: String }
|
|
50
|
+
|
|
51
|
+
# Any object that can dispatch a job. Must respond to #call(job).
|
|
52
|
+
interface _Dispatcher
|
|
53
|
+
def call: (Resources::Job) -> void
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Type alias for dispatcher configuration.
|
|
57
|
+
type dispatcher = _Dispatcher
|
|
58
|
+
|
|
59
|
+
# Structural type for a class that includes Zizq::Job.
|
|
60
|
+
#
|
|
61
|
+
# When a class includes Zizq::Job, the `included` callback extends
|
|
62
|
+
# ClassMethods onto the class. Steep can't infer this from the runtime
|
|
63
|
+
# `extend` call, so we describe the resulting shape as an interface.
|
|
64
|
+
#
|
|
65
|
+
# The `_` prefix is mandatory RBS syntax for interfaces. The `job_class`
|
|
66
|
+
# type alias below provides a cleaner name for use in source annotations.
|
|
67
|
+
interface _JobClass
|
|
68
|
+
def zizq_queue: (?String?) -> String
|
|
69
|
+
def zizq_retry_limit: (?Integer?) -> Integer?
|
|
70
|
+
def zizq_backoff: (?exponent: Numeric?, ?base: Numeric?, ?jitter: Numeric?) -> backoff?
|
|
71
|
+
def zizq_retention: (?completed: Numeric?, ?dead: Numeric?) -> retention?
|
|
72
|
+
def zizq_unique: (?bool?, ?scope: unique_scope?) -> bool
|
|
73
|
+
def zizq_unique_scope: (?unique_scope?) -> unique_scope?
|
|
74
|
+
def zizq_unique_key: (*untyped, **untyped) -> String
|
|
75
|
+
def zizq_serialize: (*untyped, **untyped) -> Hash[String, untyped]
|
|
76
|
+
def zizq_deserialize: (Hash[String, untyped]) -> [Array[untyped], Hash[Symbol, untyped]]
|
|
77
|
+
def zizq_payload_filter: (*untyped, **untyped) -> String
|
|
78
|
+
def zizq_payload_subset_filter: (*untyped, **untyped) -> String
|
|
79
|
+
def zizq_enqueue_request: (*untyped, **untyped) -> EnqueueRequest
|
|
80
|
+
def name: () -> String?
|
|
81
|
+
def new: () -> Job
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Alias so source code can write `Zizq::job_class` instead of `_JobClass`.
|
|
85
|
+
type job_class = _JobClass
|
|
86
|
+
|
|
87
|
+
# Structural type for anything that `Zizq::EnqueueWith` can forward to —
|
|
88
|
+
# both the top-level `Zizq` module and `Zizq::BulkEnqueue` instances
|
|
89
|
+
# satisfy this. `BulkEnqueue#enqueue_bulk` is a no-op that just yields
|
|
90
|
+
# itself, so nested `enqueue_with(...).enqueue_bulk { ... }` calls
|
|
91
|
+
# inside an existing bulk block compose naturally.
|
|
92
|
+
interface _EnqueueTarget
|
|
93
|
+
def enqueue: (
|
|
94
|
+
Class & job_class,
|
|
95
|
+
*untyped,
|
|
96
|
+
**untyped
|
|
97
|
+
) ?{ (EnqueueRequest) -> void } -> untyped
|
|
98
|
+
|
|
99
|
+
def enqueue_raw: (
|
|
100
|
+
queue: String,
|
|
101
|
+
type: String,
|
|
102
|
+
payload: untyped,
|
|
103
|
+
**untyped
|
|
104
|
+
) -> untyped
|
|
105
|
+
|
|
106
|
+
def enqueue_bulk: () { (_EnqueueTarget) -> void } -> untyped
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Alias so source code can write `Zizq::enqueue_target`.
|
|
110
|
+
type enqueue_target = _EnqueueTarget
|
|
111
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: zizq
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Chris Corbyn <chris@zizq.io>
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-04-25 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: async-http
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.82'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.82'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: msgpack
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.7'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.7'
|
|
41
|
+
description: |-
|
|
42
|
+
This is the Ruby client for the Zizq job queue server.
|
|
43
|
+
|
|
44
|
+
[Zizq](https://zizq.io/) is a simple, single binary, zero dependency, language agnostic job queue.
|
|
45
|
+
|
|
46
|
+
This client supports multi-threaded and/or multi-fiber concurrency and is very fast. The Zizq server provides everything needed. There are no separate external storage dependencies to configure.
|
|
47
|
+
email:
|
|
48
|
+
executables:
|
|
49
|
+
- zizq-worker
|
|
50
|
+
extensions: []
|
|
51
|
+
extra_rdoc_files: []
|
|
52
|
+
files:
|
|
53
|
+
- LICENSE
|
|
54
|
+
- README.md
|
|
55
|
+
- bin/profile-worker
|
|
56
|
+
- bin/zizq-worker
|
|
57
|
+
- lib/active_job/queue_adapters/zizq_adapter.rb
|
|
58
|
+
- lib/zizq.rb
|
|
59
|
+
- lib/zizq/ack_processor.rb
|
|
60
|
+
- lib/zizq/active_job_config.rb
|
|
61
|
+
- lib/zizq/backoff.rb
|
|
62
|
+
- lib/zizq/bulk_enqueue.rb
|
|
63
|
+
- lib/zizq/client.rb
|
|
64
|
+
- lib/zizq/configuration.rb
|
|
65
|
+
- lib/zizq/enqueue_request.rb
|
|
66
|
+
- lib/zizq/enqueue_with.rb
|
|
67
|
+
- lib/zizq/error.rb
|
|
68
|
+
- lib/zizq/job.rb
|
|
69
|
+
- lib/zizq/job_config.rb
|
|
70
|
+
- lib/zizq/lifecycle.rb
|
|
71
|
+
- lib/zizq/middleware.rb
|
|
72
|
+
- lib/zizq/query.rb
|
|
73
|
+
- lib/zizq/resources.rb
|
|
74
|
+
- lib/zizq/resources/error_enumerator.rb
|
|
75
|
+
- lib/zizq/resources/error_page.rb
|
|
76
|
+
- lib/zizq/resources/error_record.rb
|
|
77
|
+
- lib/zizq/resources/job.rb
|
|
78
|
+
- lib/zizq/resources/job_page.rb
|
|
79
|
+
- lib/zizq/resources/page.rb
|
|
80
|
+
- lib/zizq/resources/resource.rb
|
|
81
|
+
- lib/zizq/version.rb
|
|
82
|
+
- lib/zizq/worker.rb
|
|
83
|
+
- sig/generated/zizq.rbs
|
|
84
|
+
- sig/generated/zizq/ack_processor.rbs
|
|
85
|
+
- sig/generated/zizq/active_job_config.rbs
|
|
86
|
+
- sig/generated/zizq/backoff.rbs
|
|
87
|
+
- sig/generated/zizq/bulk_enqueue.rbs
|
|
88
|
+
- sig/generated/zizq/client.rbs
|
|
89
|
+
- sig/generated/zizq/configuration.rbs
|
|
90
|
+
- sig/generated/zizq/enqueue_request.rbs
|
|
91
|
+
- sig/generated/zizq/enqueue_with.rbs
|
|
92
|
+
- sig/generated/zizq/error.rbs
|
|
93
|
+
- sig/generated/zizq/job.rbs
|
|
94
|
+
- sig/generated/zizq/job_config.rbs
|
|
95
|
+
- sig/generated/zizq/lifecycle.rbs
|
|
96
|
+
- sig/generated/zizq/middleware.rbs
|
|
97
|
+
- sig/generated/zizq/query.rbs
|
|
98
|
+
- sig/generated/zizq/resources/error_enumerator.rbs
|
|
99
|
+
- sig/generated/zizq/resources/error_page.rbs
|
|
100
|
+
- sig/generated/zizq/resources/error_record.rbs
|
|
101
|
+
- sig/generated/zizq/resources/job.rbs
|
|
102
|
+
- sig/generated/zizq/resources/job_page.rbs
|
|
103
|
+
- sig/generated/zizq/resources/page.rbs
|
|
104
|
+
- sig/generated/zizq/resources/resource.rbs
|
|
105
|
+
- sig/generated/zizq/version.rbs
|
|
106
|
+
- sig/generated/zizq/worker.rbs
|
|
107
|
+
- sig/zizq.rbs
|
|
108
|
+
homepage: https://zizq.io
|
|
109
|
+
licenses:
|
|
110
|
+
- MIT
|
|
111
|
+
metadata:
|
|
112
|
+
source_code_uri: https://github.com/zizq-labs/zizq-ruby
|
|
113
|
+
documentation_uri: https://zizq.io/docs/clients/ruby/
|
|
114
|
+
homepage_uri: https://zizq.io
|
|
115
|
+
post_install_message:
|
|
116
|
+
rdoc_options: []
|
|
117
|
+
require_paths:
|
|
118
|
+
- lib
|
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: 3.2.8
|
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
|
+
requirements:
|
|
126
|
+
- - ">="
|
|
127
|
+
- !ruby/object:Gem::Version
|
|
128
|
+
version: '0'
|
|
129
|
+
requirements: []
|
|
130
|
+
rubygems_version: 3.5.22
|
|
131
|
+
signing_key:
|
|
132
|
+
specification_version: 4
|
|
133
|
+
summary: The official Ruby client for the Zizq job queue
|
|
134
|
+
test_files: []
|