jetstream_bridge 4.6.0 → 5.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1c096b0554cb1a7800a2da1c6ddd39067014bff67169d12d5669159f7253c32
4
- data.tar.gz: 5e8ee34b68ad114c72d2e754b8d1985eefe267fe2674e55631f3300dd91438db
3
+ metadata.gz: 57dcefdf122e13d34d7e913de043e5364d96f806f10186fb436006aad766fc06
4
+ data.tar.gz: 0bd04edc07f63b58751485185a1f6fa1d1126d82b820cdb710ff11fcda069011
5
5
  SHA512:
6
- metadata.gz: 0bd796f2987bd962f4ea5a871302e2a38ace2027164469c827cdd6e203f722a1a6457aa3dbb003f2095dfb9cef365436ca5cfea8697ec7e59222a631b2768fdf
7
- data.tar.gz: a6fc7288fe11ad05d9bd80e853f128fd303cd7d22bf49aff3f0adaa092bec4c8ebcaad63cbf2cb8c1d0ba2ce05e66097483f94b5579b357de67eb877398e1274
6
+ metadata.gz: '029e51b5542c45f2640626fe87e8c09aee28cd4a2f76b71df227dac3460fe480a3e72bae04ec6a829789b910e1bf36a2728b907a32aeaea726228db3ec057a54'
7
+ data.tar.gz: 70ffe09b2ab397d53179607d708bf8ff6dbf17bb8405836b292098c894ee2d955a4d3e74efdca5502c8bbb7caf7ce8b627768601e1bb0890953ce01c5c3ddbcc
data/README.md CHANGED
@@ -34,7 +34,7 @@ Production-ready NATS JetStream bridge for Ruby/Rails with outbox, inbox, DLQ, a
34
34
 
35
35
  ```ruby
36
36
  # Gemfile
37
- gem "jetstream_bridge", "~> 4.5"
37
+ gem "jetstream_bridge", "~> 5.0"
38
38
  ```
39
39
 
40
40
  ```bash
@@ -6,7 +6,7 @@ This guide covers installation, Rails setup, configuration, and basic publish/co
6
6
 
7
7
  ```ruby
8
8
  # Gemfile
9
- gem "jetstream_bridge", "~> 4.5"
9
+ gem "jetstream_bridge", "~> 5.0"
10
10
  ```
11
11
 
12
12
  ```bash
@@ -662,7 +662,7 @@ subscribe: { allow: ["pwas.>"] }
662
662
 
663
663
  If you have any influence over NATS permissions, you have two options:
664
664
 
665
- ### Option 1: Pull Consumers (Default)
665
+ ### Option 1: Pull Consumers (Default) - Summary
666
666
 
667
667
  Request minimal JetStream API permissions:
668
668
 
@@ -16,7 +16,9 @@ JetstreamBridge.configure do |config|
16
16
  # Stream name (required) - managed separately from runtime credentials
17
17
  config.stream_name = ENV.fetch('JETSTREAM_STREAM_NAME', 'jetstream-bridge-stream')
18
18
 
19
- # Application name (used in subject routing)
19
+ # Application name (used in subject routing and consumer naming)
20
+ # IMPORTANT: Do not include environment identifiers (e.g., use "myapp" not "myapp-production")
21
+ # Consumer names are shared across environments for the same application
20
22
  config.app_name = ENV.fetch('APP_NAME', Rails.application.class.module_parent_name.underscore)
21
23
 
22
24
  # Destination app for cross-app sync (REQUIRED for publishing/consuming)
@@ -8,6 +8,10 @@ module JetstreamBridge
8
8
  # Holds all configuration settings including NATS connection details,
9
9
  # application identifiers, reliability features, and consumer tuning.
10
10
  #
11
+ # IMPORTANT: app_name should not include environment identifiers
12
+ # (e.g., use "api" not "api-production") as consumer names are
13
+ # shared across environments for the same application.
14
+ #
11
15
  # @example Basic configuration
12
16
  # JetstreamBridge.configure do |config|
13
17
  # config.nats_urls = "nats://localhost:4222"
@@ -54,7 +58,8 @@ module JetstreamBridge
54
58
  # JetStream stream name (required)
55
59
  # @return [String]
56
60
  attr_accessor :stream_name
57
- # Application name for subject routing
61
+ # Application name for subject routing and consumer naming.
62
+ # Should not include environment identifiers (e.g., use "api" not "api-production").
58
63
  # @return [String]
59
64
  attr_accessor :app_name
60
65
  # Maximum delivery attempts before moving to DLQ
@@ -193,6 +198,15 @@ module JetstreamBridge
193
198
 
194
199
  # Get the durable consumer name for this application.
195
200
  #
201
+ # Returns the app_name with "-workers" suffix. Consumer names are
202
+ # shared across environments, so app_name should not include
203
+ # environment identifiers (e.g., use "myapp" not "myapp-production").
204
+ #
205
+ # @return [String] Durable consumer name
206
+ # @example
207
+ # config.app_name = "notifications"
208
+ # config.durable_name # => "notifications-workers"
209
+ #
196
210
  def durable_name
197
211
  "#{app_name}-workers"
198
212
  end
@@ -280,6 +294,8 @@ module JetstreamBridge
280
294
  end
281
295
 
282
296
  def validate_consumer_mode!(errors)
297
+ return errors << 'consumer_mode must be :pull or :push' if consumer_mode.nil?
298
+
283
299
  errors << 'consumer_mode must be :pull or :push' unless [:pull, :push].include?(consumer_mode.to_sym)
284
300
  end
285
301
  end
@@ -25,8 +25,8 @@ module JetstreamBridge
25
25
  def ensure!(jts: nil, ensure_consumer: true)
26
26
  js = jts || Connection.connect!(verify_js: true)
27
27
 
28
- ensure_stream!(js)
29
- ensure_consumer!(js) if ensure_consumer
28
+ ensure_stream!(jts: js)
29
+ ensure_consumer!(jts: js) if ensure_consumer
30
30
 
31
31
  Logging.info(
32
32
  "Provisioned stream=#{@config.stream_name} consumer=#{@config.durable_name if ensure_consumer}",
@@ -4,5 +4,5 @@
4
4
  #
5
5
  # Version constant for the gem.
6
6
  module JetstreamBridge
7
- VERSION = '4.6.0'
7
+ VERSION = '5.0.0'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jetstream_bridge
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Attara