zizq 0.2.1 → 0.3.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.
@@ -58,12 +58,12 @@ module Zizq
58
58
  # Enqueue a job class via the underlying target, applying the scoped
59
59
  # overrides before invoking any caller-supplied block.
60
60
  #
61
- # @rbs job_class: Class & Zizq::job_class
61
+ # @rbs job_class: Class & Zizq::JobConfig
62
62
  # @rbs args: Array[untyped]
63
63
  # @rbs kwargs: Hash[Symbol, untyped]
64
64
  # @rbs &block: ?(EnqueueRequest) -> void
65
65
  # @rbs return: untyped
66
- def enqueue: (Class & Zizq::job_class job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> untyped
66
+ def enqueue: (Class & Zizq::JobConfig job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> untyped
67
67
 
68
68
  # Enqueue a raw request via the underlying target, with overrides
69
69
  # merged into the kwargs (explicit kwargs take precedence).
@@ -118,11 +118,11 @@ module Zizq
118
118
  # Sets the type filter to the class name and adds a jq payload filter
119
119
  # for an exact match of the serialized arguments.
120
120
  #
121
- # @rbs job_class: Zizq::job_class
121
+ # @rbs job_class: Class && Zizq::JobConfig
122
122
  # @rbs *args: untyped
123
123
  # @rbs **kwargs: untyped
124
124
  # @rbs return: Query
125
- def by_job_class_and_args: (Zizq::job_class job_class, *untyped args, **untyped kwargs) -> Query
125
+ def by_job_class_and_args: (untyped job_class, *untyped args, **untyped kwargs) -> Query
126
126
 
127
127
  # Filter by job class and a subset of arguments.
128
128
  #
@@ -132,11 +132,11 @@ module Zizq
132
132
  # The job class must include `Zizq::Job` or for Active Job classes must
133
133
  # extend `Zizq::ActiveJobConfig`.
134
134
  #
135
- # @rbs job_class: Zizq::job_class
135
+ # @rbs job_class: Class & Zizq::JobConfig
136
136
  # @rbs *args: untyped
137
137
  # @rbs **kwargs: untyped
138
138
  # @rbs return: Query
139
- def by_job_class_and_args_subset: (Zizq::job_class job_class, *untyped args, **untyped kwargs) -> Query
139
+ def by_job_class_and_args_subset: (Class & Zizq::JobConfig job_class, *untyped args, **untyped kwargs) -> Query
140
140
 
141
141
  # Replace the jq payload filter expression.
142
142
  #
@@ -0,0 +1,29 @@
1
+ # Generated from lib/zizq/resources/cron_entry.rb with RBS::Inline
2
+
3
+ module Zizq
4
+ module Resources
5
+ # Typed wrapper around a cron entry response hash.
6
+ class CronEntry < Resource
7
+ def name: () -> untyped
8
+
9
+ def expression: () -> untyped
10
+
11
+ def timezone: () -> untyped
12
+
13
+ def paused: () -> untyped
14
+
15
+ def paused?: () -> untyped
16
+
17
+ def paused_at: () -> untyped
18
+
19
+ def resumed_at: () -> untyped
20
+
21
+ def next_enqueue_at: () -> untyped
22
+
23
+ def last_enqueue_at: () -> untyped
24
+
25
+ # Returns the job template for this entry.
26
+ def job: () -> untyped
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ # Generated from lib/zizq/resources/cron_group.rb with RBS::Inline
2
+
3
+ module Zizq
4
+ module Resources
5
+ # Typed wrapper around a cron group response hash.
6
+ class CronGroup < Resource
7
+ def name: () -> untyped
8
+
9
+ def paused: () -> untyped
10
+
11
+ def paused?: () -> untyped
12
+
13
+ def paused_at: () -> untyped
14
+
15
+ def resumed_at: () -> untyped
16
+
17
+ # Returns the entries in this group as typed resources.
18
+ def entries: () -> untyped
19
+ end
20
+ end
21
+ end
@@ -4,48 +4,26 @@ module Zizq
4
4
  module Resources
5
5
  # Typed wrapper around a job response hash.
6
6
  #
7
- # Exposes named accessor methods with Ruby-idiomatic types (fractional
8
- # seconds instead of milliseconds) and link methods that follow related
9
- # resources through the Client.
10
- class Job < Resource
7
+ # Inherits template fields (type, queue, priority, payload, backoff,
8
+ # retention, unique_key, unique_while) from JobTemplate and adds
9
+ # lifecycle fields and action methods.
10
+ class Job < JobTemplate
11
11
  def id: () -> untyped
12
12
 
13
- def type: () -> untyped
14
-
15
- def queue: () -> untyped
16
-
17
- def priority: () -> untyped
18
-
19
13
  def status: () -> untyped
20
14
 
21
15
  def ready_at: () -> untyped
22
16
 
23
17
  def attempts: () -> untyped
24
18
 
25
- def payload: () -> untyped
26
-
27
19
  def dequeued_at: () -> untyped
28
20
 
29
21
  def failed_at: () -> untyped
30
22
 
31
23
  def completed_at: () -> untyped
32
24
 
33
- def retry_limit: () -> untyped
34
-
35
- def unique_key: () -> untyped
36
-
37
- def unique_while: () -> untyped
38
-
39
25
  def duplicate?: () -> untyped
40
26
 
41
- # Backoff configuration converted from the wire format (ms) to the
42
- # Ruby-idiomatic format (seconds), matching the Zizq::backoff type.
43
- def backoff: () -> untyped
44
-
45
- # Retention configuration converted from the wire format (ms) to the
46
- # Ruby-idiomatic format (seconds), matching the Zizq::retention type.
47
- def retention: () -> untyped
48
-
49
27
  # Fetch the error history for this job.
50
28
  #
51
29
  # @rbs order: Zizq::sort_direction?
@@ -0,0 +1,31 @@
1
+ # Generated from lib/zizq/resources/job_template.rb with RBS::Inline
2
+
3
+ module Zizq
4
+ module Resources
5
+ # Typed wrapper around a job template — the fields shared between
6
+ # live jobs and cron entry job definitions.
7
+ class JobTemplate < Resource
8
+ def type: () -> untyped
9
+
10
+ def queue: () -> untyped
11
+
12
+ def priority: () -> untyped
13
+
14
+ def payload: () -> untyped
15
+
16
+ def retry_limit: () -> untyped
17
+
18
+ def unique_key: () -> untyped
19
+
20
+ def unique_while: () -> untyped
21
+
22
+ # Backoff configuration converted from the wire format (ms) to the
23
+ # Ruby-idiomatic format (seconds), matching the Zizq::backoff type.
24
+ def backoff: () -> untyped
25
+
26
+ # Retention configuration converted from the wire format (ms) to the
27
+ # Ruby-idiomatic format (seconds), matching the Zizq::retention type.
28
+ def retention: () -> untyped
29
+ end
30
+ end
31
+ end
@@ -58,6 +58,80 @@ module Zizq
58
58
  # @rbs return: Zizq::Query
59
59
  def self.query: () -> Zizq::Query
60
60
 
61
+ # Return a list of all available Crontab schedules.
62
+ def self.crontabs: () -> untyped
63
+
64
+ # Define (or redefine) a Crontab schedule.
65
+ #
66
+ # This requires a Pro license on the Zizq server.
67
+ #
68
+ # Crontabs are used to define collections of recurring jobs that run on a
69
+ # specified schedule, such as at 2am on every Monday. Each entry on the
70
+ # Crontab is a single job enqueue, which the Zizq server automatically
71
+ # triggers at the correct point in time. Zizq uses standard Cron expression
72
+ # syntax (with support for seconds via 6-fields) to define entries.
73
+ #
74
+ # This is designed to be idempotent. You can define a schedule somewhere in
75
+ # your application startup process (after `Zizq.configure`) and it doesn't
76
+ # matter if multiple process all define the same schedule. Zizq is smart
77
+ # enough to handle this correctly.
78
+ #
79
+ # Entire schedules, and individual entries on a schedule, can be paused and
80
+ # resumed.
81
+ #
82
+ # By default schedules operate in the system time zone of the Zizq server
83
+ # but an explicit IANA timezone name can be specified when defining the
84
+ # Crontab.
85
+ #
86
+ # This method sends exactly *one* request to the Zizq server upon
87
+ # completion of the block. Any existing entries are retained. Any new
88
+ # entries are added, any absent entries are removed, and any modified
89
+ # entries are replaced. In short, whatever the block defines is what the
90
+ # entire resulting Crontab schedule will look like.
91
+ #
92
+ # Zizq.define_crontab("example", timezone: "Europe/Rome") do |cron|
93
+ # cron.define_entry(
94
+ # "refresh_data_warehose",
95
+ # "*/15 * * * *"
96
+ # ).enqueue(RefreshDataWarehoseJob, incremental: true)
97
+ #
98
+ # cron.define_entry(
99
+ # "expire_acess_tokens",
100
+ # "*/10 * * * * *"
101
+ # ).enqueue_raw(
102
+ # queue: "identity-server",
103
+ # type: "expire_access_tokens",
104
+ # priority: 100,
105
+ # payload: {},
106
+ # )
107
+ # end
108
+ #
109
+ # When jobs are pushed to the queue at their execution time, Zizq handles
110
+ # this atomically, so there is no risk of a duplicate enqueue for the same
111
+ # schedule tick. However, if you have long-running jobs that should not be
112
+ # permitted to overlap, such as in the case your schedule runs every 10
113
+ # seconds but jobs can take 30 seconds to execute, you should consider
114
+ # using unique jobs.
115
+ #
116
+ # @rbs name: String
117
+ # @rbs timezone: String?
118
+ # @rbs paused: bool?
119
+ # @rbs &block: (Zizq::CrontabBuilder) -> void
120
+ # @rbs return: Zizq::Crontab
121
+ def self.define_crontab: (String name, ?timezone: String?, ?paused: bool?) { (Zizq::CrontabBuilder) -> void } -> Zizq::Crontab
122
+
123
+ # Obtain a handle for the given Crontab schedule.
124
+ #
125
+ # This is a lazy operation. The schedule data is only fetched from the Zizq
126
+ # server upon first accessing data within the schedule.
127
+ #
128
+ # Zizq.crontab("default").paused?
129
+ # Zizq.crontab("default").resume!
130
+ #
131
+ # @rbs name: String
132
+ # @rbs return: Zizq::Crontab
133
+ def self.crontab: (String name) -> Zizq::Crontab
134
+
61
135
  # Enqueue a job by class with positional and keyword arguments.
62
136
  #
63
137
  # By default all arguments are serialized as JSON, which means hashes with
@@ -93,12 +167,12 @@ module Zizq
93
167
  # end
94
168
  # end
95
169
  #
96
- # @rbs job_class: Class & Zizq::job_class
170
+ # @rbs job_class: Class & Zizq::JobConfig
97
171
  # @rbs args: Array[untyped]
98
172
  # @rbs kwargs: Hash[Symbol, untyped]
99
173
  # @rbs &block: ?(EnqueueRequest) -> void
100
174
  # @rbs return: Resources::Job
101
- def self.enqueue: (Class & Zizq::job_class job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> Resources::Job
175
+ def self.enqueue: (Class & Zizq::JobConfig job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> Resources::Job
102
176
 
103
177
  # Enqueue a job by providing raw inputs to the Zizq server.
104
178
  #
@@ -171,10 +245,10 @@ module Zizq
171
245
  # @api private
172
246
  # Build an EnqueueRequest for a single job class enqueue.
173
247
  #
174
- # @rbs job_class: Class & Zizq::job_class
248
+ # @rbs job_class: Class & Zizq::JobConfig
175
249
  # @rbs args: Array[untyped]
176
250
  # @rbs kwargs: Hash[Symbol, untyped]
177
251
  # @rbs &block: ?(EnqueueRequest) -> void
178
252
  # @rbs return: EnqueueRequest
179
- def self.build_enqueue_request: (Class & Zizq::job_class job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> EnqueueRequest
253
+ def self.build_enqueue_request: (Class & Zizq::JobConfig job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> EnqueueRequest
180
254
  end
data/sig/zizq.rbs CHANGED
@@ -45,6 +45,28 @@ module Zizq
45
45
  ?retention: (retention | singleton(RESET) | singleton(UNCHANGED))?
46
46
  }
47
47
 
48
+ # Job template for cron entry definitions.
49
+ type cron_job_params = {
50
+ type: String,
51
+ queue: String,
52
+ payload: untyped,
53
+ ?priority: Integer?,
54
+ ?retry_limit: Integer?,
55
+ ?backoff: backoff?,
56
+ ?retention: retention?,
57
+ ?unique_key: String?,
58
+ ?unique_while: unique_scope?
59
+ }
60
+
61
+ # Parameters for a single cron entry.
62
+ type cron_entry_params = {
63
+ name: String,
64
+ expression: String,
65
+ job: cron_job_params,
66
+ ?timezone: String?,
67
+ ?paused: bool?
68
+ }
69
+
48
70
  # TLS options for connecting over HTTPS. Values are PEM strings or file paths.
49
71
  type tls_options = { ?ca: String, ?client_cert: String, ?client_key: String }
50
72
 
@@ -58,26 +80,11 @@ module Zizq
58
80
 
59
81
  # Structural type for a class that includes Zizq::Job.
60
82
  #
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.
83
+ # This serves only to ensure the class can be instantiated without args.
64
84
  #
65
85
  # The `_` prefix is mandatory RBS syntax for interfaces. The `job_class`
66
86
  # type alias below provides a cleaner name for use in source annotations.
67
87
  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
88
  def new: () -> Job
82
89
  end
83
90
 
@@ -91,7 +98,7 @@ module Zizq
91
98
  # inside an existing bulk block compose naturally.
92
99
  interface _EnqueueTarget
93
100
  def enqueue: (
94
- Class & job_class,
101
+ Class & JobConfig,
95
102
  *untyped,
96
103
  **untyped
97
104
  ) ?{ (EnqueueRequest) -> void } -> untyped
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zizq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Corbyn <chris@zizq.io>
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-02 00:00:00.000000000 Z
11
+ date: 2026-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http
@@ -38,12 +38,11 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.7'
41
- description: |-
42
- This is the Ruby client for the Zizq job queue server.
41
+ description: |+
42
+ This is the official Ruby client for the Zizq job queue server.
43
43
 
44
- [Zizq](https://zizq.io/) is a simple, single binary, zero dependency, language agnostic job queue.
44
+ Zizq is a simple, single binary, zero dependency, language agnostic job queue.
45
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
46
  email:
48
47
  executables:
49
48
  - zizq-worker
@@ -62,6 +61,10 @@ files:
62
61
  - lib/zizq/bulk_enqueue.rb
63
62
  - lib/zizq/client.rb
64
63
  - lib/zizq/configuration.rb
64
+ - lib/zizq/crontab.rb
65
+ - lib/zizq/crontab_builder.rb
66
+ - lib/zizq/crontab_entry.rb
67
+ - lib/zizq/crontab_entry_builder.rb
65
68
  - lib/zizq/enqueue_request.rb
66
69
  - lib/zizq/enqueue_with.rb
67
70
  - lib/zizq/error.rb
@@ -71,11 +74,14 @@ files:
71
74
  - lib/zizq/middleware.rb
72
75
  - lib/zizq/query.rb
73
76
  - lib/zizq/resources.rb
77
+ - lib/zizq/resources/cron_entry.rb
78
+ - lib/zizq/resources/cron_group.rb
74
79
  - lib/zizq/resources/error_enumerator.rb
75
80
  - lib/zizq/resources/error_page.rb
76
81
  - lib/zizq/resources/error_record.rb
77
82
  - lib/zizq/resources/job.rb
78
83
  - lib/zizq/resources/job_page.rb
84
+ - lib/zizq/resources/job_template.rb
79
85
  - lib/zizq/resources/page.rb
80
86
  - lib/zizq/resources/resource.rb
81
87
  - lib/zizq/version.rb
@@ -87,6 +93,10 @@ files:
87
93
  - sig/generated/zizq/bulk_enqueue.rbs
88
94
  - sig/generated/zizq/client.rbs
89
95
  - sig/generated/zizq/configuration.rbs
96
+ - sig/generated/zizq/crontab.rbs
97
+ - sig/generated/zizq/crontab_builder.rbs
98
+ - sig/generated/zizq/crontab_entry.rbs
99
+ - sig/generated/zizq/crontab_entry_builder.rbs
90
100
  - sig/generated/zizq/enqueue_request.rbs
91
101
  - sig/generated/zizq/enqueue_with.rbs
92
102
  - sig/generated/zizq/error.rbs
@@ -95,11 +105,14 @@ files:
95
105
  - sig/generated/zizq/lifecycle.rbs
96
106
  - sig/generated/zizq/middleware.rbs
97
107
  - sig/generated/zizq/query.rbs
108
+ - sig/generated/zizq/resources/cron_entry.rbs
109
+ - sig/generated/zizq/resources/cron_group.rbs
98
110
  - sig/generated/zizq/resources/error_enumerator.rbs
99
111
  - sig/generated/zizq/resources/error_page.rbs
100
112
  - sig/generated/zizq/resources/error_record.rbs
101
113
  - sig/generated/zizq/resources/job.rbs
102
114
  - sig/generated/zizq/resources/job_page.rbs
115
+ - sig/generated/zizq/resources/job_template.rbs
103
116
  - sig/generated/zizq/resources/page.rbs
104
117
  - sig/generated/zizq/resources/resource.rbs
105
118
  - sig/generated/zizq/version.rbs
@@ -132,3 +145,4 @@ signing_key:
132
145
  specification_version: 4
133
146
  summary: The official Ruby client for the Zizq job queue
134
147
  test_files: []
148
+ ...