barrister-redis 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6feaeedde87a54aa056308f4990a5bc3ee3e0505
4
- data.tar.gz: a3bed90a34e91a277343a813213852ca13097953
3
+ metadata.gz: f59ab5cd82cdc88e70c2488e04edeab0fc037e89
4
+ data.tar.gz: 4a16014fbafa16204f26de40d68d461598b16f99
5
5
  SHA512:
6
- metadata.gz: 31e86af94dce36cca7dbd1488c3156ea6961c9d71c8cda1d4ace3d1b0c54a0ffc50e8fb5bda4fe1daaf27df3c84e47a5a66d18df4d9d733aabf91292c650aa05
7
- data.tar.gz: 136c4100f86e29a2296a6826492850fd8c6197579a010ec6baf29195d811342c10f5995e25eb9b0c07dd66658a4eb861b665207d3bdc9ce8ed0cfeb096147117
6
+ metadata.gz: 02c8c12117b5cef6dc701980e7521173828dee31f9de72ba5d47cf016b42c081e2c295a8735284429d736124baf8c29b5c013152afbe6bf854e6a79984e74ebf
7
+ data.tar.gz: 00b25208a7d48922d01ac5e6ee4b1aee372424b0a0c16f6e1d158624c1d1fda7f9d4784d97c4eb689e4aac00452064595945b454df1d7c02c93b89109f0241da
data/README.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  A Redis server-container and transport for Barrister RPC.
4
4
 
5
+ ## Usage
6
+
7
+ To instantiate a Redis transport, you need only the URL of the Redis database
8
+ and the name of the list that client and server will be using as a message bus:
9
+
10
+ ```ruby
11
+
12
+ list_name = 'foo_bar'
13
+ transport = Barrister::RedisTransport.new('redis://localhost:6379', list_name)
14
+
15
+ ```
16
+
17
+ Instantiating a Redis container is easy as well, and follows a similar pattern:
18
+
19
+ ```ruby
20
+
21
+ json_path = './user_service.json'
22
+ database_url = 'redis://localhost:6379'
23
+ list_name = 'foo_bar'
24
+ handlers = [UserService]
25
+
26
+ container = Barrister::RedisContainer.new json_path, database_url, list_name, handlers
27
+ container.start
28
+
29
+ ```
30
+
31
+ Calling the 'start' method of an instantiated RedisContainer will connect to
32
+ the Redis database and begin polling for inbound messages.
33
+
5
34
  ## Installation
6
35
 
7
36
  Add this line to your application's Gemfile:
@@ -16,10 +45,6 @@ Or install it yourself as:
16
45
 
17
46
  $ gem install barrister-redis
18
47
 
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
48
  ## Contributing
24
49
 
25
50
  1. Fork it ( http://github.com/<my-github-username>/barrister-redis/fork )
@@ -31,19 +31,28 @@ module Barrister
31
31
 
32
32
  class RedisContainer
33
33
 
34
- def initialize(json_path, database_url, list_name, handlers)
35
- @list_name = list_name
34
+ def initialize(json_path, handlers, options={})
35
+ options = {
36
+ database_url: 'redis://localhost:6379',
37
+ list_name: json_path.split('/')[-1].split('.')[0]
38
+ }.merge(options)
39
+
40
+ @list_name = options[:list_name]
36
41
 
37
42
  # establish connection to Redis
38
- @client = ::Redis.connect url: database_url
43
+ @client = ::Redis.connect url: options[:database_url]
39
44
 
40
45
  # initialize service
41
46
  contract = Barrister::contract_from_file(json_path)
42
47
  @server = Barrister::Server.new(contract)
43
48
 
49
+ # in case we are passed a single handler
50
+ handlers = handlers.kind_of?(Array) ? handlers : [handlers]
51
+
44
52
  # register each provided handler
45
- handlers.each do |handler_klass|
46
- @server.add_handler handler_klass.to_s, handler_klass.new
53
+ handlers.each do |handler|
54
+ iface_name = handler.class.to_s.split('::').last
55
+ @server.add_handler iface_name, handler
47
56
  end
48
57
  end
49
58
 
@@ -1,5 +1,5 @@
1
1
  module Barrister
2
2
  module Redis
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barrister-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erin Swenson-Healey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-26 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis