Module: JetstreamBridge::ConfigPreset

Defined in:
lib/jetstream_bridge/core/config_preset.rb

Overview

Configuration presets for common scenarios

Class Method Summary collapse

Class Method Details

.apply(config, preset_name) ⇒ Object

Apply a preset by name

Parameters:

  • config (Config)

    Configuration object

  • preset_name (Symbol, String)

    Name of preset to apply

Raises:

  • (ArgumentError)

    If preset name is unknown



90
91
92
93
94
95
96
97
# File 'lib/jetstream_bridge/core/config_preset.rb', line 90

def self.apply(config, preset_name)
  preset_method = preset_name.to_sym
  unless available_presets.include?(preset_method)
    raise ArgumentError, "Unknown preset: #{preset_name}. Available: #{available_presets.join(', ')}"
  end

  public_send(preset_method, config)
end

.available_presetsArray<Symbol>

Get available preset names

Returns:

  • (Array<Symbol>)

    List of available preset names



81
82
83
# File 'lib/jetstream_bridge/core/config_preset.rb', line 81

def self.available_presets
  [:development, :test, :production, :staging, :high_throughput, :maximum_reliability]
end

.development(config) ⇒ Object

Development preset: minimal features for fast local development

Parameters:

  • config (Config)

    Configuration object to apply preset to



9
10
11
12
13
14
15
16
# File 'lib/jetstream_bridge/core/config_preset.rb', line 9

def self.development(config)
  config.use_outbox = false
  config.use_inbox = false
  config.use_dlq = false
  config.max_deliver = 3
  config.ack_wait = '10s'
  config.backoff = %w[1s 2s 5s]
end

.high_throughput(config) ⇒ Object

High throughput preset: optimized for volume over reliability

Parameters:

  • config (Config)

    Configuration object to apply preset to



57
58
59
60
61
62
63
64
# File 'lib/jetstream_bridge/core/config_preset.rb', line 57

def self.high_throughput(config)
  config.use_outbox = false # Skip DB writes
  config.use_inbox = false # Skip deduplication
  config.use_dlq = true # But keep DLQ for visibility
  config.max_deliver = 3
  config.ack_wait = '10s'
  config.backoff = %w[1s 2s 5s]
end

.maximum_reliability(config) ⇒ Object

Maximum reliability preset: every safety feature enabled

Parameters:

  • config (Config)

    Configuration object to apply preset to



69
70
71
72
73
74
75
76
# File 'lib/jetstream_bridge/core/config_preset.rb', line 69

def self.maximum_reliability(config)
  config.use_outbox = true
  config.use_inbox = true
  config.use_dlq = true
  config.max_deliver = 10
  config.ack_wait = '60s'
  config.backoff = %w[1s 5s 15s 30s 60s 120s 300s 600s 1200s 1800s]
end

.production(config) ⇒ Object

Production preset: all reliability features enabled

Parameters:

  • config (Config)

    Configuration object to apply preset to



33
34
35
36
37
38
39
40
# File 'lib/jetstream_bridge/core/config_preset.rb', line 33

def self.production(config)
  config.use_outbox = true
  config.use_inbox = true
  config.use_dlq = true
  config.max_deliver = 5
  config.ack_wait = '30s'
  config.backoff = %w[1s 5s 15s 30s 60s]
end

.staging(config) ⇒ Object

Staging preset: production-like but with faster retries

Parameters:

  • config (Config)

    Configuration object to apply preset to



45
46
47
48
49
50
51
52
# File 'lib/jetstream_bridge/core/config_preset.rb', line 45

def self.staging(config)
  config.use_outbox = true
  config.use_inbox = true
  config.use_dlq = true
  config.max_deliver = 3
  config.ack_wait = '15s'
  config.backoff = %w[1s 5s 15s]
end

.test(config) ⇒ Object

Test preset: similar to development but with synchronous behavior

Parameters:

  • config (Config)

    Configuration object to apply preset to



21
22
23
24
25
26
27
28
# File 'lib/jetstream_bridge/core/config_preset.rb', line 21

def self.test(config)
  config.use_outbox = false
  config.use_inbox = false
  config.use_dlq = false
  config.max_deliver = 2
  config.ack_wait = '5s'
  config.backoff = %w[0.1s 0.5s]
end