Module: Sbmt::Outbox
- Defined in:
- lib/sbmt/outbox.rb,
lib/sbmt/outbox/cli.rb,
lib/sbmt/outbox/engine.rb,
lib/sbmt/outbox/errors.rb,
lib/sbmt/outbox/logger.rb,
lib/sbmt/outbox/version.rb,
lib/sbmt/outbox/ascii_art.rb,
lib/sbmt/outbox/v1/worker.rb,
lib/sbmt/outbox/v2/poller.rb,
lib/sbmt/outbox/v2/worker.rb,
lib/sbmt/outbox/probes/probe.rb,
lib/sbmt/outbox/v1/throttler.rb,
lib/sbmt/outbox/v2/processor.rb,
lib/sbmt/outbox/v2/redis_job.rb,
lib/sbmt/outbox/v2/throttler.rb,
lib/sbmt/outbox/error_tracker.rb,
lib/sbmt/outbox/metrics/utils.rb,
lib/sbmt/outbox/v2/tasks/base.rb,
lib/sbmt/outbox/v2/tasks/poll.rb,
lib/sbmt/outbox/probes/metrics.rb,
lib/sbmt/outbox/v1/thread_pool.rb,
lib/sbmt/outbox/v2/thread_pool.rb,
app/models/sbmt/outbox/base_item.rb,
lib/sbmt/outbox/v2/box_processor.rb,
lib/sbmt/outbox/v2/tasks/default.rb,
lib/sbmt/outbox/v2/tasks/process.rb,
app/models/sbmt/outbox/inbox_item.rb,
lib/sbmt/outbox/database_switcher.rb,
lib/sbmt/outbox/middleware/runner.rb,
lib/sbmt/outbox/v2/poll_throttler.rb,
app/models/sbmt/outbox/outbox_item.rb,
lib/sbmt/outbox/middleware/builder.rb,
app/models/sbmt/outbox/api/box_class.rb,
lib/sbmt/outbox/redis_client_factory.rb,
app/models/sbmt/outbox/api/inbox_class.rb,
lib/sbmt/outbox/v2/poll_throttler/base.rb,
lib/sbmt/outbox/v2/poll_throttler/noop.rb,
app/models/sbmt/outbox/api/outbox_class.rb,
app/models/sbmt/outbox/base_item_config.rb,
app/interactors/sbmt/outbox/process_item.rb,
app/models/sbmt/outbox/inbox_item_config.rb,
app/models/sbmt/outbox/outbox_item_config.rb,
app/interactors/sbmt/outbox/dry_interactor.rb,
app/controllers/sbmt/outbox/root_controller.rb,
lib/sbmt/outbox/v2/poll_throttler/composite.rb,
app/interactors/sbmt/outbox/base_create_item.rb,
lib/sbmt/outbox/v2/poll_throttler/paused_box.rb,
app/interactors/sbmt/outbox/create_inbox_item.rb,
app/models/sbmt/outbox/api/application_record.rb,
lib/sbmt/outbox/middleware/sentry/transaction.rb,
lib/sbmt/outbox/v2/poll_throttler/fixed_delay.rb,
app/interactors/sbmt/outbox/create_outbox_item.rb,
lib/sbmt/outbox/v2/poll_throttler/rate_limited.rb,
app/controllers/sbmt/outbox/api/base_controller.rb,
app/interactors/sbmt/outbox/create_outbox_batch.rb,
app/jobs/sbmt/outbox/base_delete_stale_items_job.rb,
app/interactors/sbmt/outbox/retry_strategies/base.rb,
app/jobs/sbmt/outbox/delete_stale_inbox_items_job.rb,
app/jobs/sbmt/outbox/delete_stale_outbox_items_job.rb,
lib/sbmt/outbox/v2/poll_throttler/redis_queue_size.rb,
app/interactors/sbmt/outbox/retry_strategies/no_delay.rb,
lib/sbmt/outbox/instrumentation/open_telemetry_loader.rb,
lib/sbmt/outbox/v2/poll_throttler/redis_queue_time_lag.rb,
app/controllers/sbmt/outbox/api/inbox_classes_controller.rb,
app/controllers/sbmt/outbox/api/outbox_classes_controller.rb,
app/interactors/sbmt/outbox/retry_strategies/compacted_log.rb,
app/interactors/sbmt/outbox/retry_strategies/latest_available.rb,
app/interactors/sbmt/outbox/retry_strategies/exponential_backoff.rb,
lib/sbmt/outbox/middleware/sentry/tracing_item_process_middleware.rb,
app/interactors/sbmt/outbox/partition_strategies/hash_partitioning.rb,
lib/sbmt/outbox/middleware/sentry/tracing_batch_process_middleware.rb,
app/interactors/sbmt/outbox/partition_strategies/number_partitioning.rb,
lib/sbmt/outbox/middleware/open_telemetry/tracing_create_item_middleware.rb,
lib/sbmt/outbox/middleware/open_telemetry/tracing_create_batch_middleware.rb,
lib/sbmt/outbox/middleware/open_telemetry/tracing_item_process_middleware.rb,
lib/sbmt/outbox/middleware/execution_context/context_item_process_middleware.rb
Defined Under Namespace
Modules: Api, AsciiArt, Instrumentation, Metrics, Middleware, PartitionStrategies, Probes, RedisClientFactory, RetryStrategies, V1, V2
Classes: BaseCreateItem, BaseDeleteStaleItemsJob, BaseItem, BaseItemConfig, CLI, ConfigError, CreateInboxItem, CreateOutboxBatch, CreateOutboxItem, DatabaseError, DatabaseSwitcher, DeleteStaleInboxItemsJob, DeleteStaleOutboxItemsJob, DryInteractor, Engine, Error, ErrorTracker, InboxItem, InboxItemConfig, Logger, OutboxItem, OutboxItemConfig, ProcessItem, RootController
Constant Summary
collapse
- VERSION =
"6.10.5"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.current_worker ⇒ Object
Returns the value of attribute current_worker.
47
48
49
|
# File 'lib/sbmt/outbox.rb', line 47
def current_worker
@current_worker
end
|
Class Method Details
.action_controller_api_base_class ⇒ Object
80
81
82
|
# File 'lib/sbmt/outbox.rb', line 80
def action_controller_api_base_class
@action_controller_api_base_class ||= config.action_controller_api_base_class.safe_constantize || ::ActionController::API
end
|
.action_controller_base_class ⇒ Object
84
85
86
|
# File 'lib/sbmt/outbox.rb', line 84
def action_controller_base_class
@action_controller_base_class ||= config.action_controller_base_class.safe_constantize || ::ActionController::Base
end
|
.active_job_base_class ⇒ Object
76
77
78
|
# File 'lib/sbmt/outbox.rb', line 76
def active_job_base_class
@active_job_base_class ||= config.active_job_base_class.safe_constantize || ::ActiveJob::Base
end
|
.active_record_base_class ⇒ Object
72
73
74
|
# File 'lib/sbmt/outbox.rb', line 72
def active_record_base_class
@active_record_base_class ||= config.active_record_base_class.safe_constantize || ::ActiveRecord::Base
end
|
.batch_process_middlewares ⇒ Object
158
159
160
|
# File 'lib/sbmt/outbox.rb', line 158
def batch_process_middlewares
@batch_process_middlewares ||= config.batch_process_middlewares.map(&:constantize)
end
|
.config ⇒ Object
52
53
54
|
# File 'lib/sbmt/outbox.rb', line 52
def config
@config ||= Rails.application.config.outbox
end
|
.create_batch_middlewares ⇒ Object
170
171
172
|
# File 'lib/sbmt/outbox.rb', line 170
def create_batch_middlewares
@create_batch_middlewares ||= config.create_batch_middlewares.map(&:constantize)
end
|
.create_item_middlewares ⇒ Object
166
167
168
|
# File 'lib/sbmt/outbox.rb', line 166
def create_item_middlewares
@create_item_middlewares ||= config.create_item_middlewares.map(&:constantize)
end
|
.database_switcher ⇒ Object
92
93
94
|
# File 'lib/sbmt/outbox.rb', line 92
def database_switcher
@database_switcher ||= config.database_switcher.constantize
end
|
.default_worker_version ⇒ Object
68
69
70
|
# File 'lib/sbmt/outbox.rb', line 68
def default_worker_version
@default_worker_version ||= config.default_worker_version&.to_i || 2
end
|
.error_tracker ⇒ Object
88
89
90
|
# File 'lib/sbmt/outbox.rb', line 88
def error_tracker
@error_tracker ||= config.error_tracker.constantize
end
|
.inbox_item_classes ⇒ Object
114
115
116
117
118
119
120
|
# File 'lib/sbmt/outbox.rb', line 114
def inbox_item_classes
@inbox_item_classes ||= if config.inbox_item_classes.empty?
(yaml_config[:inbox_items] || {}).keys.map { |name| name.camelize.constantize }
else
config.inbox_item_classes.map(&:constantize)
end
end
|
.item_classes ⇒ Object
122
123
124
|
# File 'lib/sbmt/outbox.rb', line 122
def item_classes
@item_classes ||= outbox_item_classes + inbox_item_classes
end
|
.item_classes_by_name ⇒ Object
126
127
128
|
# File 'lib/sbmt/outbox.rb', line 126
def item_classes_by_name
@item_classes_by_name ||= item_classes.index_by(&:box_name)
end
|
.item_process_middlewares ⇒ Object
162
163
164
|
# File 'lib/sbmt/outbox.rb', line 162
def item_process_middlewares
@item_process_middlewares ||= config.item_process_middlewares.map(&:constantize)
end
|
.load_yaml(path) ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/sbmt/outbox.rb', line 146
def load_yaml(path)
data = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("4.0.0")
YAML.safe_load(ERB.new(File.read(path)).result, aliases: true)
else
YAML.safe_load(ERB.new(File.read(path)).result, [], [], true)
end
data
.with_indifferent_access
.fetch(Rails.env, {})
end
|
.logger ⇒ Object
56
57
58
|
# File 'lib/sbmt/outbox.rb', line 56
def logger
@logger ||= Sbmt::Outbox::Logger.new
end
|
.memory_store ⇒ Object
102
103
104
|
# File 'lib/sbmt/outbox.rb', line 102
def memory_store
@memory_store ||= ActiveSupport::Cache::MemoryStore.new
end
|
.outbox_item_classes ⇒ Object
106
107
108
109
110
111
112
|
# File 'lib/sbmt/outbox.rb', line 106
def outbox_item_classes
@outbox_item_classes ||= if config.outbox_item_classes.empty?
(yaml_config[:outbox_items] || {}).keys.map { |name| name.camelize.constantize }
else
config.outbox_item_classes.map(&:constantize)
end
end
|
.poller_config ⇒ Object
60
61
62
|
# File 'lib/sbmt/outbox.rb', line 60
def poller_config
@poller_config ||= config.poller
end
|
.processor_config ⇒ Object
64
65
66
|
# File 'lib/sbmt/outbox.rb', line 64
def processor_config
@processor_config ||= config.processor
end
|
.redis ⇒ Object
96
97
98
99
100
|
# File 'lib/sbmt/outbox.rb', line 96
def redis
@redis ||= ConnectionPool::Wrapper.new(size: ENV.fetch("RAILS_MAX_THREADS", 5).to_i) do
RedisClientFactory.build(config.redis)
end
end
|
.yaml_config ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/sbmt/outbox.rb', line 130
def yaml_config
return @yaml_config if defined?(@yaml_config)
paths = if config.paths.empty?
[Rails.root.join("config/outbox.yml").to_s]
else
config.paths
end
@yaml_config = paths.each_with_object({}.with_indifferent_access) do |path, memo|
memo.deep_merge!(
load_yaml(path)
)
end
end
|