Class: RServiceBus::AppResource
- Inherits:
-
Object
- Object
- RServiceBus::AppResource
- Defined in:
- lib/rservicebus/AppResource.rb
Overview
Wrapper base class for resources used by applications, allowing rservicebus to configure the resource
-
dependency injection.
Direct Known Subclasses
AppResource_Dir, AppResource_File, AppResource_FluidDb, AppResource_FluidDbFirebird, AppResource_FluidDbMysql, AppResource_FluidDbMysql2, AppResource_FluidDbPgsql, AppResource_FluidDbTinyTds, AppResource_Redis, AppResource_ScpDownload, AppResource_ScpUpload, AppResource_Smb
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.
-
#getResource ⇒ Object
The method which actually configures the resource.
-
#initialize(host, uri) ⇒ AppResource
constructor
Resources are attached resources, 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 resources, and can be specified using the URI syntax.
26 27 28 29 30 31 32 |
# File 'lib/rservicebus/AppResource.rb', line 26 def initialize( host, uri ) @host = host @uri = uri #Do a connect / disconnect loop on startup to validate the connection self._connect self.finished end |
Instance Method Details
#_connect ⇒ Object
18 19 20 21 |
# File 'lib/rservicebus/AppResource.rb', line 18 def _connect @connection = self.connect(@uri) RServiceBus.rlog "#{self.class.name}. Connected to, #{@uri.to_s}" end |
#Begin ⇒ Object
Transaction Semantics
60 61 62 |
# File 'lib/rservicebus/AppResource.rb', line 60 def Begin end |
#Commit ⇒ Object
Transaction Semantics
65 66 67 |
# File 'lib/rservicebus/AppResource.rb', line 65 def Commit end |
#connect(uri) ⇒ Object
The method which actually connects to the resource.
14 15 16 |
# File 'lib/rservicebus/AppResource.rb', line 14 def connect(uri) raise 'Method, connect, needs to be implemented for resource' end |
#finished ⇒ Object
A notification that ocurs after getResource, to allow cleanup
42 43 44 |
# File 'lib/rservicebus/AppResource.rb', line 42 def finished @connection.close end |
#getResource ⇒ Object
The method which actually configures the resource.
37 38 39 |
# File 'lib/rservicebus/AppResource.rb', line 37 def getResource return @connection end |
#reconnect ⇒ Object
At least called in the Host rescue block, to ensure all network links are healthy
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rservicebus/AppResource.rb', line 47 def reconnect begin self.finished rescue Exception => e puts '** AppResource. An error was raised while closing connection to, ' + @uri.to_s puts 'Message: ' + e. puts e.backtrace end self._connect end |
#Rollback ⇒ Object
Transaction Semantics
70 71 72 |
# File 'lib/rservicebus/AppResource.rb', line 70 def Rollback end |