Module: RServiceBus2
- Defined in:
- lib/rservicebus2.rb,
lib/rservicebus2/mq.rb,
lib/rservicebus2/host.rb,
lib/rservicebus2/agent.rb,
lib/rservicebus2/audit.rb,
lib/rservicebus2/config.rb,
lib/rservicebus2/mq/aws.rb,
lib/rservicebus2/message.rb,
lib/rservicebus2/monitor.rb,
lib/rservicebus2/mq/file.rb,
lib/rservicebus2/mq/redis.rb,
lib/rservicebus2/test/bus.rb,
lib/rservicebus2/saga/base.rb,
lib/rservicebus2/saga/data.rb,
lib/rservicebus2/appresource.rb,
lib/rservicebus2/monitor/dir.rb,
lib/rservicebus2/saga_loader.rb,
lib/rservicebus2/transporter.rb,
lib/rservicebus2/cron_manager.rb,
lib/rservicebus2/errormessage.rb,
lib/rservicebus2/mq/beanstalk.rb,
lib/rservicebus2/saga/manager.rb,
lib/rservicebus2/saga_storage.rb,
lib/rservicebus2/monitor/awss3.rb,
lib/rservicebus2/state_manager.rb,
lib/rservicebus2/state_storage.rb,
lib/rservicebus2/circuitbreaker.rb,
lib/rservicebus2/handler_loader.rb,
lib/rservicebus2/monitor/awssqs.rb,
lib/rservicebus2/monitor/xmldir.rb,
lib/rservicebus2/sendat_manager.rb,
lib/rservicebus2/sendat_storage.rb,
lib/rservicebus2/appresource/dir.rb,
lib/rservicebus2/endpointmapping.rb,
lib/rservicebus2/handler_manager.rb,
lib/rservicebus2/monitor/message.rb,
lib/rservicebus2/appresource/file.rb,
lib/rservicebus2/helper_functions.rb,
lib/rservicebus2/resource_manager.rb,
lib/rservicebus2/saga_storage/dir.rb,
lib/rservicebus2/appresource/awss3.rb,
lib/rservicebus2/monitor/beanstalk.rb,
lib/rservicebus2/monitor_configure.rb,
lib/rservicebus2/state_storage/dir.rb,
lib/rservicebus2/statistic_manager.rb,
lib/rservicebus2/appresource/awssqs.rb,
lib/rservicebus2/appresource/fluiddb.rb,
lib/rservicebus2/monitor/dirnotifier.rb,
lib/rservicebus2/sendat_storage/file.rb,
lib/rservicebus2/appresource/fluiddb2.rb,
lib/rservicebus2/message/subscription.rb,
lib/rservicebus2/subscription_manager.rb,
lib/rservicebus2/subscription_storage.rb,
lib/rservicebus2/appresource_configure.rb,
lib/rservicebus2/message/verboseoutput.rb,
lib/rservicebus2/saga_storage/inmemory.rb,
lib/rservicebus2/state_storage/inmemory.rb,
lib/rservicebus2/appresource/awsdynamodb.rb,
lib/rservicebus2/message/statisticoutput.rb,
lib/rservicebus2/sendat_storage/inmemory.rb,
lib/rservicebus2/usermessage/withpayload.rb,
lib/rservicebus2/subscription_storage/file.rb,
lib/rservicebus2/subscription_storage_configure.rb
Overview
Defined Under Namespace
Classes: Agent, AppResource, AppResourceAWSDynamoDb, AppResourceAWSS3, AppResourceAWSSQS, AppResourceDir, AppResourceFile, AppResourceFluidDb, AppResourceFluidDb2, Audit, CircuitBreaker, ClassNotFoundForMsg, Config, ConfigFromEnv, ConfigFromSetter, ConfigureAppResource, ConfigureMonitor, ConfigureSubscriptionStorage, CouldNotConnectToDestination, CronManager, EndpointMapping, ErrorMessage, Globber, HandlerLoader, HandlerManager, Host, JobTooBigError, MQ, MQAWS, MQBeanstalk, MQFile, MQRedis, Message, MessageArrivedWhileCricuitBroken, MessageStatisticOutputOff, MessageStatisticOutputOn, MessageSubscription, MessageVerboseOutputOff, MessageVerboseOutputOn, Monitor, MonitorAWSS3, MonitorAWSSQS, MonitorBeanstalk, MonitorDir, MonitorDirNotifier, MonitorMessage, MonitorXmlDir, NoHandlerFound, NoMatchingMsgForCron, NoMsgToProcess, PropertyNotSet, QueueNotFoundForMsg, ResourceManager, SagaBase, SagaData, SagaLoader, SagaManager, SagaStorage, SagaStorageDir, SagaStorageInMemory, SendAtManager, SendAtStorage, SendAtStorageFile, SendAtStorageInMemory, StateManager, StateStorage, StateStorageDir, StateStorageInMemory, StatisticManager, SubscriptionManager, SubscriptionStorage, SubscriptionStorageFile, TestBus, Transporter, UserMessageWithPayload
Class Method Summary
collapse
Class Method Details
.check_environment_variable(string) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
89
90
91
92
93
94
95
96
97
|
# File 'lib/rservicebus2/helper_functions.rb', line 89
def self.check_environment_variable(string)
return false if ENV[string].nil? || ENV[string] == ''
return true if ENV[string] == true || ENV[string] =~ (/(true|t|yes|y|1)$/i)
return false if ENV[string] == false ||
ENV[string].nil? ||
ENV[string] =~ (/(false|f|no|n|0)$/i)
raise ArgumentError, "invalid value for Environment Variable: \"#{string}\""
end
|
.check_for_reply(queue_name) ⇒ Object
rubocop:enable Metrics/MethodLength
74
75
76
77
78
79
80
81
|
# File 'lib/rservicebus2/helper_functions.rb', line 74
def self.check_for_reply(queue_name)
ENV['RSBMQ'] = 'beanstalk://localhost' if ENV['RSBMQ'].nil?
agent = RServiceBus2::Agent.new
msg = agent.check_for_reply(queue_name)
Audit.new(agent).audit_incoming(msg)
msg
end
|
.convert_dto_to_hash(obj) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/rservicebus2/helper_functions.rb', line 12
def self.convert_dto_to_hash(obj)
hash = {}
obj.instance_variables.each do |var|
hash[var.to_s.delete('@')] = obj.instance_variable_get(var)
end
hash
end
|
.convert_dto_to_json(obj) ⇒ Object
20
21
22
|
# File 'lib/rservicebus2/helper_functions.rb', line 20
def self.convert_dto_to_json(obj)
convert_dto_to_hash(obj).to_json
end
|
.create_anonymous_class(name_for_class) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/rservicebus2/helper_functions.rb', line 41
def self.create_anonymous_class(name_for_class)
Module.const_get(name_for_class)
rescue NameError
new_anonymous_class = Class.new(Object)
Object.const_set(name_for_class, new_anonymous_class)
Object.const_get(name_for_class).new
end
|
.get_value(name, default = nil) ⇒ Object
49
50
51
52
53
|
# File 'lib/rservicebus2/helper_functions.rb', line 49
def self.get_value(name, default = nil)
value = ENV[name].nil? || ENV[name] == '' ? default : ENV[name]
log "Env value: #{name}: #{value}"
value
end
|
.log(string, ver = false) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/rservicebus2/helper_functions.rb', line 24
def self.log(string, ver = false)
return if check_environment_variable('TESTING')
type = ver ? 'VERB' : 'INFO'
return unless check_environment_variable('VERBOSE') || !ver
timestamp = Time.new.strftime('%Y-%m-%d %H:%M:%S')
puts "[#{type}] #{timestamp} :: #{string}"
end
|
.rlog(string) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/rservicebus2/helper_functions.rb', line 34
def self.rlog(string)
return unless check_environment_variable('RSBVERBOSE')
timestamp = Time.new.strftime('%Y-%m-%d %H:%M:%S')
puts "[RSB] #{timestamp} :: #{string}"
end
|
.safe_load(body) ⇒ Object
7
8
9
10
|
# File 'lib/rservicebus2/helper_functions.rb', line 7
def self.safe_load(body)
YamlSafeLoader.instance.load(body)
end
|
.send_msg(msg, response_queue = 'agent') ⇒ Object
rubocop:disable Metrics/MethodLength
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/rservicebus2/helper_functions.rb', line 56
def self.send_msg(msg, response_queue = 'agent')
require 'rservicebus2/endpointmapping'
endpoint_mapping = EndpointMapping.new
endpoint_mapping.configure
queue_name = endpoint_mapping.get(msg.class.name)
ENV['RSBMQ'] = 'beanstalk://localhost' if ENV['RSBMQ'].nil?
agent = RServiceBus2::Agent.new
Audit.new(agent).audit_to_queue(msg)
agent.send_msg(msg, queue_name, response_queue)
rescue QueueNotFoundForMsg => e
raise StandardError, '' \
"*** Queue not found for, #{e.message}\n" \
"*** Ensure you have an environment variable set for this Message Type, eg, \n" \
"*** MESSAGE_ENDPOINT_MAPPINGS=#{e.message}:<QueueName>\n"
end
|
.tick(string) ⇒ Object
83
84
85
86
|
# File 'lib/rservicebus2/helper_functions.rb', line 83
def self.tick(string)
puts "[TICK] #{Time.new.strftime('%Y-%m-%d %H:%M:%S.%6N')} ::
#{caller[0]}. #{string}"
end
|