Class: RServiceBus2::AppResource
- Inherits:
-
Object
- Object
- RServiceBus2::AppResource
- Defined in:
- lib/rservicebus2/appresource.rb
Overview
Wrapper base class for resources used by applications, allowing rservicebus to configure the resource - dependency injection.
Direct Known Subclasses
AppResourceDir, AppResourceFile, AppResourceFluidDb, AppResourceFluidDb2
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #_connect ⇒ Object
-
#begin ⇒ Object
Transaction Semantics.
-
#commit ⇒ Object
Transaction Semantics.
-
#connect(_uri) ⇒ Object
The method which actually connects to the resource.
-
#finished ⇒ Object
A notification that ocurs after getResource, to allow cleanup.
- #get_resource ⇒ Object
-
#initialize(host, uri) ⇒ AppResource
constructor
Resources are attached, and can be specified using the URI syntax.
-
#reconnect ⇒ Object
At least called in the Host rescue block, to ensure all network links are healthy.
-
#rollback ⇒ Object
Transaction Semantics.
Constructor Details
#initialize(host, uri) ⇒ AppResource
Resources are attached, and can be specified using the URI syntax.
26 27 28 29 30 31 32 |
# File 'lib/rservicebus2/appresource.rb', line 26 def initialize(host, uri) @host = host @uri = uri # Do a connect / disconnect loop on startup to validate the connection _connect finished end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/rservicebus2/appresource.rb', line 7 def connection @connection end |
Instance Method Details
#_connect ⇒ Object
14 15 16 17 |
# File 'lib/rservicebus2/appresource.rb', line 14 def _connect @connection = connect(@uri) RServiceBus2.rlog "#{self.class.name}. Connected to, #{@uri}" end |
#begin ⇒ Object
Transaction Semantics
54 55 |
# File 'lib/rservicebus2/appresource.rb', line 54 def begin end |
#commit ⇒ Object
Transaction Semantics
58 59 |
# File 'lib/rservicebus2/appresource.rb', line 58 def commit end |
#connect(_uri) ⇒ Object
The method which actually connects to the resource.
10 11 12 |
# File 'lib/rservicebus2/appresource.rb', line 10 def connect(_uri) fail 'Method, connect, needs to be implemented for resource' end |
#finished ⇒ Object
A notification that ocurs after getResource, to allow cleanup
35 36 37 |
# File 'lib/rservicebus2/appresource.rb', line 35 def finished @connection.close end |
#get_resource ⇒ Object
19 20 21 |
# File 'lib/rservicebus2/appresource.rb', line 19 def get_resource @connection end |
#reconnect ⇒ Object
At least called in the Host rescue block, to ensure all network links are
healthy
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rservicebus2/appresource.rb', line 41 def reconnect begin finished rescue StandardError => e puts '** AppResource. An error was raised while closing connection to, ' + @uri puts 'Message: ' + e. puts e.backtrace end _connect end |
#rollback ⇒ Object
Transaction Semantics
62 63 |
# File 'lib/rservicebus2/appresource.rb', line 62 def rollback end |