Skip to content

Commit

Permalink
Minor changes to message bus for redis message bus strategy gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanstout committed Oct 28, 2015
1 parent 515daec commit 467ac6c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
6 changes: 6 additions & 0 deletions docs/UPGRADE_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.9.5 to 0.9.7

- 0.9.7 adds the awesome VoltTime class.
To make this work, some stuff had to change in volt-mongo, upgrade volt-mongo to at least 0.2.0. Also, switch any instances of Time to VoltTime.
-

# 0.9.4 to 0.9.5

CSS url's now should be referenced either 1) as relative paths from the css file, or 2) using the full path from inside of app (eg: main/assets/images/background.jpg)
Expand Down
12 changes: 9 additions & 3 deletions lib/volt/server/message_bus/base_message_bus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#
# MessageBus instances inherit from MessageBus::BaseMessageBus and provide
# two methods 'publish' and 'subscribe'. They should be inside of
# Volt::MessageBus.
# Volt::MessageBus. Be sure to
# ```require 'volt/server/message_bus/base_message_bus'```
#
# publish should take a channel name and a message and deliver the message to
# any subscried listeners.
#
# subscribe should take a channel name and a block. It should yield a message
# to the block if a message is published to the channel.
# to the block if a message is published to the channel. It should return an
# object with a ```remove``` method that will remove the subscription.
#
# The implementation details of the pub/sub connection are left to the
# implemntation. If the user needs to configure server addresses, Volt.config
Expand All @@ -29,9 +31,13 @@
# NOTE: in the future, we plan to add support for round robbin message receiving
# and other patterns.

require 'volt/reactive/eventable'

module Volt
module MessageBus
class BaseMessageBus
include Eventable

# MessagesBus's should take an instance of a Volt::App
def initialize(volt_app)
raise "Not implemented"
Expand All @@ -54,4 +60,4 @@ def disconnect!
end
end
end
end
end
3 changes: 1 addition & 2 deletions lib/volt/server/message_bus/peer_to_peer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module MessageBus
class PeerToPeer < BaseMessageBus
# How long without an update before we mark an instance as dead (in seconds)
DEAD_TIME = 20
include Eventable

# Use subscribe instead of on provided in Eventable
alias_method :subscribe, :on
Expand Down Expand Up @@ -200,4 +199,4 @@ def still_alive?(peer_server_id)

end
end
end
end
13 changes: 9 additions & 4 deletions lib/volt/volt/server_setup/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module ServerSetup
module App
# Include Eventable to allow for lifecycle callbacks
include Eventable

# The root url is where the volt app is mounted
attr_reader :root_url
# The app url is where the app folder (and sprockets) is mounted
Expand Down Expand Up @@ -125,12 +125,17 @@ def start_message_bus
# updating each other.
unless Volt.env.test?
# Start the message bus
bus_name = Volt.config.message_bus.try(:bus_name) || 'peer_to_peer'
bus_name = if ((bus = Volt.config.message_bus) && name = bus.bus_name)
name
else
'peer_to_peer'
end

begin
message_bus_class = MessageBus.const_get(bus_name.camelize)
rescue NameError => e
raise "message bus name #{bus_name} was not found, be sure its "
+ "gem is included in the gemfile."
+ "gem is included in the gemfile."
end

@message_bus = message_bus_class.new(self)
Expand All @@ -148,4 +153,4 @@ def start_message_bus
end
end
end
end
end

0 comments on commit 467ac6c

Please sign in to comment.