README.md in redis-stream-0.1.0 vs README.md in redis-stream-0.2.0
- old
+ new
@@ -61,23 +61,37 @@
configure do
set :redis_stream, Redis::Stream::Client.new("greetings", "HTTP", "http_client", "sync_start" => true)
get '/:name' do
halt 500, 'name parameter not found' unless params.include?(:name)
- result = settings.redis_stream.sync_add(params[:name], "time_out" => 60)
+ result = settings.redis_stream.sync_add(params[:name], "group" => "GREETER", "time_out" => 60)
@name = params[:name]
@reversed_name = result[payload]
erb :index
end
__END__
@@index
<p>Hello, <%= @name %>!</p>
<p><%= @reversed_name</p>
-
```
+# reverse_greeter.rb
+```ruby
+require 'redis-stream'
+
+reverse_greeter = Redis::Stream::Client.new("greetings", "GREETER", "reverse_greeter")
+reverse_greeter.on_message do |message|
+ begin
+ greeting = message['payload']
+ reverse_greeter.add(greeting.reverse, "to" => message['from'])
+ rescue Exception => e
+ end
+end
+
+reverse_greeter.start(true, false)
+```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.