Module: JetstreamBridge
- Defined in:
- lib/jetstream_bridge.rb,
lib/jetstream_bridge/errors.rb,
lib/jetstream_bridge/railtie.rb,
lib/jetstream_bridge/version.rb,
lib/jetstream_bridge/core/config.rb,
lib/jetstream_bridge/inbox_event.rb,
lib/jetstream_bridge/core/logging.rb,
lib/jetstream_bridge/outbox_event.rb,
lib/jetstream_bridge/core/duration.rb,
lib/jetstream_bridge/models/subject.rb,
lib/jetstream_bridge/core/connection.rb,
lib/jetstream_bridge/topology/stream.rb,
lib/jetstream_bridge/core/model_utils.rb,
lib/jetstream_bridge/consumer/consumer.rb,
lib/jetstream_bridge/core/debug_helper.rb,
lib/jetstream_bridge/topology/topology.rb,
lib/jetstream_bridge/core/retry_strategy.rb,
lib/jetstream_bridge/publisher/publisher.rb,
lib/jetstream_bridge/models/event_envelope.rb,
lib/jetstream_bridge/consumer/dlq_publisher.rb,
lib/jetstream_bridge/core/model_codec_setup.rb,
lib/jetstream_bridge/topology/overlap_guard.rb,
lib/jetstream_bridge/core/connection_factory.rb,
lib/jetstream_bridge/topology/subject_matcher.rb,
lib/jetstream_bridge/consumer/message_processor.rb,
lib/jetstream_bridge/publisher/outbox_repository.rb,
lib/jetstream_bridge/consumer/inbox/inbox_message.rb,
lib/jetstream_bridge/consumer/subscription_manager.rb,
lib/jetstream_bridge/consumer/inbox/inbox_processor.rb,
lib/jetstream_bridge/consumer/inbox/inbox_repository.rb,
lib/generators/jetstream_bridge/install/install_generator.rb,
lib/generators/jetstream_bridge/migrations/migrations_generator.rb,
lib/generators/jetstream_bridge/initializer/initializer_generator.rb,
lib/generators/jetstream_bridge/health_check/health_check_generator.rb
Overview
JetstreamBridge
Defined Under Namespace
Modules: Core, DebugHelper, Duration, Generators, Logging, ModelCodecSetup, ModelUtils, Models, StreamSupport, SubjectMatcher Classes: BackoffStrategy, Config, ConfigurationError, Connection, ConnectionError, ConnectionNotEstablishedError, Consumer, ConsumerError, DlqError, DlqPublishFailedError, DlqPublisher, Error, ExponentialBackoffStrategy, HandlerError, HealthCheckFailedError, InboxError, InboxEvent, InboxMessage, InboxProcessor, InboxRepository, InvalidSubjectError, LinearBackoffStrategy, MessageContext, MessageProcessor, MissingConfigurationError, OutboxError, OutboxEvent, OutboxRepository, OverlapGuard, PublishError, PublishFailedError, Publisher, PublisherRetryStrategy, Railtie, RetryStrategy, Stream, StreamCreationFailedError, StreamNotFoundError, SubjectOverlapError, SubscriptionManager, Topology, TopologyError
Constant Summary collapse
- VERSION =
'3.0.2'
Class Method Summary collapse
- .config ⇒ Object
- .configure(overrides = {}) {|cfg| ... } ⇒ Object
-
.connected? ⇒ Boolean
Check if connected to NATS.
-
.ensure_topology! ⇒ Object
Establishes a connection and ensures stream topology.
-
.health_check ⇒ Hash
Health check for monitoring and readiness probes.
- .reset! ⇒ Object
-
.stream_info ⇒ Hash
Get stream information for the configured stream.
- .use_dlq? ⇒ Boolean
- .use_inbox? ⇒ Boolean
- .use_outbox? ⇒ Boolean
Class Method Details
.config ⇒ Object
21 22 23 |
# File 'lib/jetstream_bridge.rb', line 21 def config @config ||= Config.new end |
.configure(overrides = {}) {|cfg| ... } ⇒ Object
25 26 27 28 29 30 |
# File 'lib/jetstream_bridge.rb', line 25 def configure(overrides = {}) cfg = config overrides.each { |k, v| assign!(cfg, k, v) } unless overrides.nil? || overrides.empty? yield(cfg) if block_given? cfg end |
.connected? ⇒ Boolean
Check if connected to NATS
91 92 93 94 95 |
# File 'lib/jetstream_bridge.rb', line 91 def connected? Connection.instance.connected? rescue StandardError false end |
.ensure_topology! ⇒ Object
Establishes a connection and ensures stream topology.
51 52 53 54 |
# File 'lib/jetstream_bridge.rb', line 51 def ensure_topology! Connection.connect! Connection.jetstream end |
.health_check ⇒ Hash
Health check for monitoring and readiness probes
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/jetstream_bridge.rb', line 59 def health_check conn_instance = Connection.instance connected = conn_instance.connected? connected_at = conn_instance.connected_at stream_info = fetch_stream_info if connected { healthy: connected && stream_info[:exists], nats_connected: connected, connected_at: connected_at&.iso8601, stream: stream_info, config: { env: config.env, app_name: config.app_name, destination_app: config.destination_app, use_outbox: config.use_outbox, use_inbox: config.use_inbox, use_dlq: config.use_dlq }, version: JetstreamBridge::VERSION } rescue StandardError => e { healthy: false, error: "#{e.class}: #{e.}" } end |
.reset! ⇒ Object
32 33 34 |
# File 'lib/jetstream_bridge.rb', line 32 def reset! @config = nil end |
.stream_info ⇒ Hash
Get stream information for the configured stream
100 101 102 |
# File 'lib/jetstream_bridge.rb', line 100 def stream_info fetch_stream_info end |
.use_dlq? ⇒ Boolean
44 45 46 |
# File 'lib/jetstream_bridge.rb', line 44 def use_dlq? config.use_dlq end |
.use_inbox? ⇒ Boolean
40 41 42 |
# File 'lib/jetstream_bridge.rb', line 40 def use_inbox? config.use_inbox end |
.use_outbox? ⇒ Boolean
36 37 38 |
# File 'lib/jetstream_bridge.rb', line 36 def use_outbox? config.use_outbox end |