rservicebus 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rservicebus/AppResource.rb +25 -10
- data/lib/rservicebus/AppResource/Dir.rb +2 -15
- data/lib/rservicebus/AppResource/File.rb +2 -15
- data/lib/rservicebus/AppResource/FluidDbMysql.rb +2 -14
- data/lib/rservicebus/AppResource/FluidDbMysql2.rb +2 -14
- data/lib/rservicebus/AppResource/FluidDbPgsql.rb +2 -16
- data/lib/rservicebus/AppResource/Mysql.rb +2 -19
- data/lib/rservicebus/AppResource/Redis.rb +15 -17
- data/lib/rservicebus/HandlerLoader.rb +3 -2
- metadata +2 -2
@@ -7,35 +7,50 @@ module RServiceBus
|
|
7
7
|
#
|
8
8
|
class AppResource
|
9
9
|
@uri
|
10
|
-
|
10
|
+
@connection
|
11
|
+
|
12
|
+
# The method which actually connects to the resource.
|
13
|
+
#
|
14
|
+
def connect(uri)
|
15
|
+
raise "Method, connect, needs to be implemented for resource"
|
16
|
+
end
|
17
|
+
|
18
|
+
def _connect
|
19
|
+
@connection = self.connect(@uri)
|
20
|
+
puts "#{self.class.name}. Connected to, #{@uri.to_s}" unless !ENV["QUIET"].nil?
|
21
|
+
end
|
22
|
+
|
11
23
|
# Resources are attached resources, and can be specified using the URI syntax.
|
12
24
|
#
|
13
25
|
# @param [String] uri a location for the resource to which we will attach, eg redis://127.0.0.1/foo
|
14
26
|
def initialize( uri )
|
15
27
|
@uri = uri
|
28
|
+
self._connect
|
16
29
|
end
|
17
30
|
|
18
31
|
# The method which actually configures the resource.
|
19
32
|
#
|
20
33
|
# @return [Object] the configured object.
|
21
34
|
def getResource
|
22
|
-
|
35
|
+
return @connection
|
23
36
|
end
|
24
|
-
|
37
|
+
|
25
38
|
# A notification that ocurs after getResource, to allow cleanup
|
26
39
|
def finished
|
27
|
-
|
40
|
+
@connection.close
|
28
41
|
end
|
29
|
-
|
42
|
+
|
30
43
|
# At least called in the Host rescue block, to ensure all network links are healthy
|
31
44
|
def reconnect
|
32
45
|
begin
|
33
|
-
|
34
|
-
rescue
|
35
|
-
puts "AppResource. An error was raised while closing connection to, " + @uri.to_s
|
46
|
+
self.finished
|
47
|
+
rescue Exception => e
|
48
|
+
puts "** AppResource. An error was raised while closing connection to, " + @uri.to_s
|
49
|
+
puts "Message: " + e.message
|
50
|
+
puts e.backtrace
|
36
51
|
end
|
37
|
-
|
38
|
-
self.
|
52
|
+
|
53
|
+
self._connect
|
39
54
|
end
|
40
55
|
|
41
56
|
end
|
@@ -2,21 +2,8 @@ module RServiceBus
|
|
2
2
|
|
3
3
|
class AppResource_Dir<AppResource
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
def connect()
|
8
|
-
@dir = Dir.new( @uri.path )
|
9
|
-
|
10
|
-
puts "AppResource_Dir. Connected to, " + @uri.to_s
|
11
|
-
end
|
12
|
-
|
13
|
-
def initialize( uri )
|
14
|
-
super(uri)
|
15
|
-
self.connect
|
16
|
-
end
|
17
|
-
|
18
|
-
def getResource
|
19
|
-
return @dir
|
5
|
+
def connect(uri)
|
6
|
+
return Dir.new( uri.path )
|
20
7
|
end
|
21
8
|
|
22
9
|
end
|
@@ -2,21 +2,8 @@ module RServiceBus
|
|
2
2
|
|
3
3
|
class AppResource_File<AppResource
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
def connect()
|
8
|
-
@file = File.new( @uri.path )
|
9
|
-
|
10
|
-
puts "AppResource_File. Connected to, " + @uri.to_s
|
11
|
-
end
|
12
|
-
|
13
|
-
def initialize( uri )
|
14
|
-
super(uri)
|
15
|
-
self.connect
|
16
|
-
end
|
17
|
-
|
18
|
-
def getResource
|
19
|
-
return @file
|
5
|
+
def connect(uri)
|
6
|
+
return File.new( uri.path )
|
20
7
|
end
|
21
8
|
|
22
9
|
end
|
@@ -5,20 +5,8 @@ module RServiceBus
|
|
5
5
|
#Implementation of an AppResource - Redis
|
6
6
|
class AppResource_FluidDbMysql<AppResource
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
def initialize( uri )
|
11
|
-
super(uri)
|
12
|
-
host = uri.host
|
13
|
-
database = uri.path.sub( "/", "" )
|
14
|
-
|
15
|
-
|
16
|
-
@connection = FluidDb::Mysql.new( uri )
|
17
|
-
puts "AppResource_Mysql. Connected to, " + uri.to_s
|
18
|
-
end
|
19
|
-
|
20
|
-
def getResource
|
21
|
-
return @connection
|
8
|
+
def connect(uri)
|
9
|
+
return FluidDb::Mysql.new( uri )
|
22
10
|
end
|
23
11
|
|
24
12
|
end
|
@@ -5,22 +5,10 @@ module RServiceBus
|
|
5
5
|
#Implementation ofF an AppResource - Redis
|
6
6
|
class AppResource_FluidDbMysql2<AppResource
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
def initialize( uri )
|
11
|
-
super(uri)
|
12
|
-
host = uri.host
|
13
|
-
database = uri.path.sub( "/", "" )
|
14
|
-
|
15
|
-
|
16
|
-
@connection = FluidDb::Mysql2.new( uri )
|
17
|
-
puts "AppResource_Mysql. Connected to, " + uri.to_s
|
8
|
+
def connect(uri)
|
9
|
+
return FluidDb::Mysql2.new( uri )
|
18
10
|
end
|
19
11
|
|
20
|
-
def getResource
|
21
|
-
return @connection
|
22
|
-
end
|
23
|
-
|
24
12
|
end
|
25
13
|
|
26
14
|
end
|
@@ -5,22 +5,8 @@ module RServiceBus
|
|
5
5
|
#Implementation of an AppResource - Redis
|
6
6
|
class AppResource_FluidDbPgsql<AppResource
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
def initialize( uri )
|
11
|
-
super(uri)
|
12
|
-
host = uri.host
|
13
|
-
database = uri.path.sub( "/", "" )
|
14
|
-
|
15
|
-
|
16
|
-
@connection = FluidDb::Pgsql.new( uri )
|
17
|
-
puts "AppResource_Mysql. Connected to, " + uri.to_s
|
8
|
+
def connect(uri)
|
9
|
+
return FluidDb::Pgsql.new( uri )
|
18
10
|
end
|
19
|
-
|
20
|
-
def getResource
|
21
|
-
return @connection
|
22
|
-
end
|
23
|
-
|
24
11
|
end
|
25
|
-
|
26
12
|
end
|
@@ -5,27 +5,10 @@ module RServiceBus
|
|
5
5
|
#Implementation of an AppResource - Redis
|
6
6
|
class AppResource_Mysql<AppResource
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
def connect()
|
11
|
-
uri = self.uri
|
12
|
-
host = uri.host
|
13
|
-
database = uri.path.sub( "/", "" )
|
14
|
-
|
15
|
-
|
16
|
-
@connection = Mysql2::Client.new(:host => uri.host,
|
8
|
+
def connect(uri)
|
9
|
+
return Mysql2::Client.new(:host => uri.host,
|
17
10
|
:database => uri.path.sub( "/", "" ),
|
18
11
|
:username => uri.user )
|
19
|
-
puts "AppResource_Mysql. Connected to, " + uri.to_s
|
20
|
-
end
|
21
|
-
|
22
|
-
def initialize( uri )
|
23
|
-
super(uri)
|
24
|
-
self.connect
|
25
|
-
end
|
26
|
-
|
27
|
-
def getResource
|
28
|
-
return @connection
|
29
12
|
end
|
30
13
|
|
31
14
|
end
|
@@ -1,21 +1,19 @@
|
|
1
1
|
module RServiceBus
|
2
|
+
|
3
|
+
require "redis"
|
4
|
+
|
5
|
+
#Implementation of an AppResource - Redis
|
6
|
+
class AppResource_Redis<AppResource
|
7
|
+
|
8
|
+
def connect(uri)
|
9
|
+
port = uri.port || 6379
|
2
10
|
|
3
|
-
|
4
|
-
|
5
|
-
#Implementation of an AppResource - Redis
|
6
|
-
class AppResource_Redis<AppResource
|
7
|
-
|
8
|
-
@connection
|
9
|
-
|
10
|
-
def initialize( uri )
|
11
|
-
super(uri)
|
12
|
-
@connection = Redis.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def getResource
|
16
|
-
return @connection
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
11
|
+
return Redis.new( :host=>uri.host, :port=>port )
|
12
|
+
end
|
20
13
|
|
14
|
+
def finished
|
15
|
+
@connection.quit
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
21
19
|
end
|
@@ -92,11 +92,12 @@ class HandlerLoader
|
|
92
92
|
# @param [Hash] appResources As hash[k,v] where k is the name of a resource, and v is the resource
|
93
93
|
def setAppResources( handler, appResources )
|
94
94
|
@host.log "Checking app resources for: #{handler.class.name}", true
|
95
|
+
@host.log "If your attribute is not getting set, check that it is in the 'attr_accessor' list", true
|
95
96
|
appResources.each do |k,v|
|
96
|
-
if handler.class.method_defined?( k ) then
|
97
|
+
if handler.class.method_defined?( k ) then
|
97
98
|
handler.instance_variable_set( "@#{k}", v.getResource() )
|
98
99
|
@resourceList[handler.class.name] = Array.new if @resourceList[handler.class.name].nil?
|
99
|
-
@resourceList[handler.class.name] << v
|
100
|
+
@resourceList[handler.class.name] << v
|
100
101
|
@host.log "App resource attribute, #{k}, set for: " + handler.class.name
|
101
102
|
end
|
102
103
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rservicebus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.29
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby interpretation of NServiceBus
|
15
15
|
email: guy@guyirvine.com
|