Class: GorgService

Inherits:
Object
  • Object
show all
Defined in:
lib/gorg_service/configuration.rb,
lib/gorg_service.rb,
lib/gorg_service/message.rb,
lib/gorg_service/version.rb,
lib/gorg_service/consumer.rb,
lib/gorg_service/producer.rb,
lib/gorg_service/consumer/errors.rb,
lib/gorg_service/consumer/listener.rb,
lib/gorg_service/message/error_log.rb,
lib/gorg_service/message/json_schema.rb,
lib/gorg_service/rabbitmq_env_builder.rb,
lib/gorg_service/consumer/message_router.rb,
lib/gorg_service/consumer/message_handler.rb,
lib/gorg_service/consumer/message_handler/base.rb,
lib/gorg_service/consumer/message_handler/event_handler.rb,
lib/gorg_service/consumer/message_handler/reply_handler.rb,
lib/gorg_service/consumer/message_handler/request_handler.rb,
lib/gorg_service/consumer/message_handler/exception_manager.rb

Overview

Add configuration features to GorgService

Defined Under Namespace

Classes: Configuration, Consumer, Message, Producer, RabbitmqEnvBuilder

Constant Summary collapse

VERSION =
"5.3.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



6
7
8
# File 'lib/gorg_service/configuration.rb', line 6

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



11
12
13
14
# File 'lib/gorg_service/configuration.rb', line 11

def configure
  @configuration = Configuration.new
  yield(configuration)
end

.connectionObject

Connection shared across Consumers and Producers (thread safe)



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gorg_service.rb', line 14

def connection
  @bunny_session||=GorgService.configuration.rabbitmq_client_class.new(
      :hostname => GorgService.configuration.rabbitmq_host,
      :port => GorgService.configuration.rabbitmq_port,
      :user => GorgService.configuration.rabbitmq_user,
      :pass => GorgService.configuration.rabbitmq_password,
      :vhost => GorgService.configuration.rabbitmq_vhost
  )
  @bunny_session.start unless @bunny_session.connected?
  @bunny_session
end

.environmentObject

Environment buidler. Don’t share across threads since channels are not thread safe



27
28
29
30
31
32
33
34
35
36
# File 'lib/gorg_service.rb', line 27

def environment
  RabbitmqEnvBuilder.new(
      conn: connection,
      event_exchange: GorgService.configuration.rabbitmq_event_exchange_name,
      app_id: GorgService.configuration.application_id,
      deferred_time: GorgService.configuration.rabbitmq_deferred_time.to_i,
      listened_routing_keys: Consumer::MessageRouter.listened_keys,
      prefetch: GorgService.configuration.prefetch_count,
  )
end

.loggerObject



38
39
40
# File 'lib/gorg_service.rb', line 38

def logger
  GorgService.configuration.logger
end