Skip to content

Commit

Permalink
make max_wait_timeout configurable (#123)
Browse files Browse the repository at this point in the history
* make max_wait_timeout configurable
  • Loading branch information
alinagrishchuk authored Mar 21, 2023
1 parent f595df9 commit 45eaf82
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/streamy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module Streamy
require "streamy/message_buses/message_bus"

class << self
attr_accessor :message_bus, :logger, :dispatcher, :notifications_bus, :notifications_bus_namespace
attr_accessor :message_bus, :logger, :dispatcher, :notifications_bus,
:notifications_bus_namespace, :max_wait_timeout

def shutdown
message_bus.try(:shutdown)
Expand All @@ -44,6 +45,7 @@ def shutdown
self.dispatcher = Dispatcher
self.notifications_bus = ::ActiveSupport::Notifications
self.notifications_bus_namespace = :kafka
self.max_wait_timeout = 5

def self.configuration
@configuration ||= Configuration.new
Expand Down
7 changes: 4 additions & 3 deletions lib/streamy/errors/publication_failed_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ class PublicationFailedError < StandardError

def initialize(original_error, event)
@event_params = event.to_params
message = %( Failed publishing event: #{event_params}
#{original_error.class} - #{original_error.message}, caused by #{original_error.try(:cause)}
)
message = <<~TEXT
Failed publishing event: #{event_params}
#{original_error.class} - #{original_error.message}, caused by #{original_error.try(:cause)}
TEXT
super message
end
end
Expand Down
5 changes: 5 additions & 0 deletions lib/streamy/message_buses/kafka_message_bus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def build_producer(kafka_config)
Streamy.notifications_bus_namespace
)
producer_config.kafka = kafka_config
producer_config.max_wait_timeout = max_wait_timeout
end
end

Expand All @@ -95,6 +96,10 @@ def sync_producers
def logger
::Streamy.logger
end

def max_wait_timeout
::Streamy.max_wait_timeout
end
end
end
end
2 changes: 1 addition & 1 deletion lib/streamy/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Streamy
VERSION = "3.0.1".freeze
VERSION = "3.0.2".freeze
end

0 comments on commit 45eaf82

Please sign in to comment.