pgmq-ruby 0.8.0 → 0.8.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e359ff6e278f15f414b12524d8922c6f7ae7cfb274ce770250ca347a88c160d
4
- data.tar.gz: 821beca651d6115f7c1f9ef46efe63b5985eb07ac8f77ed3b31a26e51ff85b23
3
+ metadata.gz: 943d0ebf4cffa43c1163f651575cbfb0e9785fc675f388ef7b208538e9dab8a3
4
+ data.tar.gz: fd9ab2693a0bf87c6230330ac8c4e046c585c420ecbdce0b77b06a6b652fd266
5
5
  SHA512:
6
- metadata.gz: 31215de55d5ae155d1e364263c36c1fce1bcbf1d07774c8afbd9bde05e8e607dbf0bdb1c4bd62db527431dc9332e3828f78109ad4361963319a61db3a5a23520
7
- data.tar.gz: e52b05c020270c1d90f50c238d95e042af6e8d1b69849f483de1e62695cd1f085bac5b762de76c3d35466355d52fc3fa9bbca316a576bbbab577beaa45beca71
6
+ metadata.gz: 6cc612c51d2b89e7ecfd3ea6879eb3e731a8ce96cba961863119a34b9dd094b0e5c139045d0c0cdf0df964130ec0e65a9df4961defe6843603767e9369b60800
7
+ data.tar.gz: ff1caf1d8012504204f5d793b577c0c3603ba2d156257786a32fab73618d52971d0c49edfba0860f9a5ad9dd56e34dca272891e594b55521761f514fd8fdc053
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.2 (2026-11-02)
4
+
5
+ ### Queue Naming
6
+ - **[Fix]** The `InvalidQueueNameError` message for a too-long queue name states the real limit: "exceeds maximum
7
+ length of 47 characters" (was 48; a 48-character name was already rejected). The README now gives 47 as the maximum
8
+ and no longer calls queue names case-sensitive: names differing only in case share one table (PGMQ lower-cases
9
+ table names) but get separate `pgmq.meta` rows, so use one spelling per queue.### Documentation
10
+ - **[Fix]** The README `wait_for_notify` example said the call returns the notification payload; it returns the
11
+ channel name (`nil` on timeout).
12
+
13
+ ## 0.8.1 (2026-10-30)
14
+
15
+ ### Producer
16
+ - **[Fix]** A whole-second `ActiveSupport::Duration` delay (`delay: 5.minutes`) works again in `produce`, `produce_batch`
17
+ and `produce_batch_topic`; 0.8.0 raised `NoMethodError: undefined method 'to_time'`. A fractional one
18
+ (`delay: 1.5.seconds`) now works in all four producers, `produce_topic` included, and stays fractional. A Duration is
19
+ bound as its number of seconds.
20
+
21
+ ### Testing
22
+ - **[Feature]** `bin/integrations` runs a spec in a `*_pristine` directory in its own bundle from that directory's
23
+ `Gemfile`. The ActiveSupport delay spec uses it to test with real activesupport, which the main Gemfile does not
24
+ have.
25
+
3
26
  ## 0.8.0 (2026-10-25)
4
27
 
5
28
  ### Consumer
data/README.md CHANGED
@@ -23,7 +23,7 @@ PGMQ-Ruby is a Ruby client for PGMQ (PostgreSQL Message Queue). It provides dire
23
23
  - [Requirements](#requirements)
24
24
  - [Installation](#installation)
25
25
  - [Quick Start](#quick-start)
26
- - [Configuration](#configuration)
26
+ - [Connection Options](#connection-options)
27
27
  - [API Reference](#api-reference)
28
28
  - [Queue Management](#queue-management)
29
29
  - [Sending Messages](#sending-messages)
@@ -91,7 +91,7 @@ This gem provides complete support for all core PGMQ SQL functions. Based on the
91
91
  | | Conditional Filtering | Server-side JSONB filtering with `conditional:` | ✅ |
92
92
  | | Multi-Queue Ops | Read/pop/delete/archive from multiple queues | ✅ |
93
93
  | | Consumer | Minimal single-threaded `PGMQ::Consumer` loop over one or more queues with ack on success | ✅ |
94
- | | Queue Validation | 48-character limit and name validation | ✅ |
94
+ | | Queue Validation | 47-character limit and name validation | ✅ |
95
95
  | | Connection Pooling | Thread-safe connection pool for concurrency | ✅ |
96
96
  | | Pluggable Serializers | JSON (default) with custom serializer support | ✅ |
97
97
 
@@ -357,7 +357,7 @@ PGMQ::Connection.reconnectable_error_patterns = [
357
357
  ]
358
358
 
359
359
  # Any Exception subclass is accepted. Subclasses also match.
360
- PGMQ::Connection.reconnectable_error_classes = [PG::ConnectionRefused]
360
+ PGMQ::Connection.reconnectable_error_classes = [PG::ConnectionFailure]
361
361
  ```
362
362
 
363
363
  The built-in defaults are always kept - your patterns and classes are
@@ -427,10 +427,11 @@ queues = client.list_queues
427
427
 
428
428
  Queue names must follow PostgreSQL identifier rules with PGMQ-specific constraints:
429
429
 
430
- - **Maximum 48 characters** (PGMQ enforces this limit for table prefixes)
430
+ - **Maximum 47 characters** (PGMQ enforces this limit for table prefixes)
431
431
  - Must start with a letter or underscore
432
432
  - Can contain only letters, digits, and underscores
433
- - Case-sensitive
433
+ - Names that differ only in case (`Orders`, `orders`) share one message table, because PGMQ lower-cases table names.
434
+ PGMQ still registers each spelling separately in `pgmq.meta`, so always use one spelling per queue (e.g. lower case)
434
435
 
435
436
  **Valid Queue Names:**
436
437
 
@@ -881,7 +882,7 @@ end
881
882
  client.disable_notify_insert("queue_name")
882
883
 
883
884
  # Block until a NOTIFY arrives on the queue's channel (or timeout expires)
884
- # Returns the payload string on notification, nil on timeout
885
+ # Returns the channel name on notification, nil on timeout
885
886
  client.wait_for_notify("queue_name", timeout: 5)
886
887
 
887
888
  # Block form — inspect notification metadata
@@ -12,9 +12,9 @@ module PGMQ
12
12
  # @param queue_name [String] name of the queue
13
13
  # @param message [String] message as JSON string (for PostgreSQL JSONB)
14
14
  # @param headers [String, nil] optional headers as JSON string (for metadata, routing, tracing)
15
- # @param delay [Numeric, Time] delay in seconds before message becomes visible (integer or float;
16
- # a float such as 1.5 needs PGMQ v1.10.0+), or an absolute Time at which the message becomes visible,
17
- # including ActiveSupport::TimeWithZone (PGMQ v1.10.0+)
15
+ # @param delay [Numeric, ActiveSupport::Duration, Time] delay in seconds before message becomes visible (integer,
16
+ # float or Duration; a float such as 1.5 needs PGMQ v1.10.0+), or an absolute Time at which the message
17
+ # becomes visible, including ActiveSupport::TimeWithZone (PGMQ v1.10.0+)
18
18
  # @return [String] message ID as string
19
19
  # @raise [PGMQ::Errors::MessageInvalidError] if message is not a String, or headers is neither a String nor
20
20
  # nil
@@ -71,9 +71,9 @@ module PGMQ
71
71
  # @param queue_name [String] name of the queue
72
72
  # @param messages [Array<String>] array of message payloads as JSON strings
73
73
  # @param headers [Array<String>, nil] optional array of headers as JSON strings (must match messages length)
74
- # @param delay [Numeric, Time] delay in seconds before messages become visible (integer or float;
75
- # a float such as 1.5 needs PGMQ v1.10.0+), or an absolute Time at which the messages become visible,
76
- # including ActiveSupport::TimeWithZone (PGMQ v1.10.0+)
74
+ # @param delay [Numeric, ActiveSupport::Duration, Time] delay in seconds before messages become visible (integer,
75
+ # float or Duration; a float such as 1.5 needs PGMQ v1.10.0+), or an absolute Time at which the messages
76
+ # become visible, including ActiveSupport::TimeWithZone (PGMQ v1.10.0+)
77
77
  # @return [Array<String>] array of message IDs
78
78
  # @raise [PGMQ::Errors::MessageInvalidError] if messages is not an Array, headers is neither an Array nor nil,
79
79
  # headers length doesn't match messages length, a message is not a String, or a header is neither a String
@@ -70,8 +70,8 @@ module PGMQ
70
70
  # @param routing_key [String] dot-separated routing key (e.g., "orders.new.priority")
71
71
  # @param message [String] message as JSON string
72
72
  # @param headers [String, nil] optional headers as JSON string
73
- # @param delay [Numeric] delay in seconds before message becomes visible (integer or float; a float such as
74
- # 1.5 needs PGMQ v1.10.0+)
73
+ # @param delay [Numeric, ActiveSupport::Duration] delay in seconds before message becomes visible (integer,
74
+ # float or Duration; a float such as 1.5 needs PGMQ v1.10.0+)
75
75
  # @return [Integer] count of queues the message was delivered to
76
76
  #
77
77
  # @example Basic topic send
@@ -117,9 +117,9 @@ module PGMQ
117
117
  # @param routing_key [String] dot-separated routing key
118
118
  # @param messages [Array<String>] array of message payloads as JSON strings
119
119
  # @param headers [Array<String>, nil] optional array of headers as JSON strings
120
- # @param delay [Numeric, Time] delay in seconds before messages become visible (integer or float;
121
- # a float such as 1.5 needs PGMQ v1.10.0+), or an absolute Time at which the messages become visible,
122
- # including ActiveSupport::TimeWithZone (PGMQ v1.10.0+)
120
+ # @param delay [Numeric, ActiveSupport::Duration, Time] delay in seconds before messages become visible (integer,
121
+ # float or Duration; a float such as 1.5 needs PGMQ v1.10.0+), or an absolute Time at which the messages
122
+ # become visible, including ActiveSupport::TimeWithZone (PGMQ v1.10.0+)
123
123
  # @return [Array<Hash>] array of hashes with :queue_name and :msg_id
124
124
  # @raise [PGMQ::Errors::MessageInvalidError] if messages is not an Array, headers is neither an Array nor nil,
125
125
  # or headers length doesn't match messages length
data/lib/pgmq/client.rb CHANGED
@@ -179,7 +179,11 @@ module PGMQ
179
179
  # +timestamptz+ overload as +clock_timestamp()+ plus the delay. This is how PGMQ itself turns an integer delay
180
180
  # into a visibility time, so the database clock is used in both cases.
181
181
  #
182
- # @param delay [Numeric, Time] delay in seconds or an absolute Time
182
+ # +ActiveSupport::Duration+ (+5.minutes+) answers +is_a?+ for its value but is not a Numeric, so
183
+ # +Integer === 5.minutes+ is false and it reaches the last branch. It is converted there to a plain number, which
184
+ # keeps the +is_a?+ calls off the path of a plain Integer or Float.
185
+ #
186
+ # @param delay [Numeric, ActiveSupport::Duration, Time] delay in seconds or an absolute Time
183
187
  # @param index [Integer] position of the delay bind parameter in the query
184
188
  # @return [Array(String, Object)] SQL argument and its bind value
185
189
  def delay_argument(delay, index)
@@ -189,6 +193,8 @@ module PGMQ
189
193
  when Numeric
190
194
  ["clock_timestamp() + make_interval(secs => $#{index}::double precision)", delay.to_f]
191
195
  else
196
+ return delay_argument(delay.is_a?(Integer) ? delay.to_i : delay.to_f, index) if delay.is_a?(Numeric)
197
+
192
198
  ["$#{index}::timestamptz", delay.to_time.utc.iso8601(6)]
193
199
  end
194
200
  end
@@ -53,7 +53,7 @@ module PGMQ
53
53
  #
54
54
  # @return [Array<Class>]
55
55
  # @example
56
- # PGMQ::Connection.reconnectable_error_classes = [PG::ConnectionRefused]
56
+ # PGMQ::Connection.reconnectable_error_classes = [PG::ConnectionFailure]
57
57
  attr_reader :reconnectable_error_classes
58
58
 
59
59
  # Replaces the extra reconnectable error patterns.
@@ -28,8 +28,8 @@ module PGMQ
28
28
  # PGMQ::QueueName.sanitize!("!!!") # => raises InvalidQueueNameError
29
29
  # PGMQ::QueueName.sanitize("99 Problems!") # => "q_99_problems"
30
30
  module QueueName
31
- # Maximum queue name length. PGMQ creates tables with prefixes (+q_+, +a_+) and PostgreSQL caps identifiers at 63
32
- # characters; PGMQ enforces 48 to leave room for those prefixes and suffixes.
31
+ # Queue names must be shorter than this. PGMQ creates tables with prefixes (+q_+, +a_+) and PostgreSQL caps
32
+ # identifiers at 63 characters; PGMQ rejects names of 48+ characters to leave room for those prefixes and suffixes.
33
33
  MAX_LENGTH = 48
34
34
 
35
35
  # A valid queue name: starts with a letter or underscore, then letters, digits, or underscores.
@@ -67,7 +67,7 @@ module PGMQ
67
67
 
68
68
  if str.length >= MAX_LENGTH
69
69
  raise Errors::InvalidQueueNameError,
70
- "Queue name '#{str}' exceeds maximum length of #{MAX_LENGTH} characters " \
70
+ "Queue name '#{str}' exceeds maximum length of #{MAX_LENGTH - 1} characters " \
71
71
  "(current length: #{str.length})"
72
72
  end
73
73
 
data/lib/pgmq/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module PGMQ
4
4
  # Current version of the pgmq-ruby gem
5
- VERSION = "0.8.0"
5
+ VERSION = "0.8.2"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgmq-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld