Navigation Menu

Skip to content

Commit

Permalink
Raise error for unexpected forwardings
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 1, 2015
1 parent 7ab0d36 commit 1f8f33c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/droonga/cluster.rb
Expand Up @@ -28,6 +28,12 @@ class Cluster
class NoCatalogLoaded < StandardError
end

class NotStartedYet < StandardError
end

class UnknownTarget < StandardError
end

class << self
def load_state_file
path = Path.cluster_state
Expand Down Expand Up @@ -134,13 +140,14 @@ def engine_nodes_status
def forward(message, destination)
receiver = destination["to"]
receiver_node_name = receiver.match(/\A[^:]+:\d+\/[^.]+/).to_s
raise NotStartedYet unless @engine_nodes
@engine_nodes.each do |node|
if node.name == receiver_node_name
node.forward(message, destination)
return true
return
end
end
false
raise UnknownTarget.new(receiver)
end

def readable_nodes
Expand Down

0 comments on commit 1f8f33c

Please sign in to comment.