Class: Droonga::Serf::RemoteCommand::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/serf/remote_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(serf_name, params) ⇒ Base

Returns a new instance of Base.



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/droonga/serf/remote_command.rb', line 34

def initialize(serf_name, params)
  @serf_name = serf_name
  @params    = params
  @response  = {
    "log" => []
  }
  @serf = Serf.new(@serf_name)

  @service_installation = ServiceInstallation.new
  @service_installation.ensure_using_service_base_directory

  log("params = #{params}")
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



32
33
34
# File 'lib/droonga/serf/remote_command.rb', line 32

def response
  @response
end

Instance Method Details

#log(message) ⇒ Object



75
76
77
# File 'lib/droonga/serf/remote_command.rb', line 75

def log(message)
  @response["log"] << message
end

#processObject



48
49
50
# File 'lib/droonga/serf/remote_command.rb', line 48

def process
  # override me!
end

#should_process?Boolean

Returns:

  • (Boolean)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/droonga/serf/remote_command.rb', line 52

def should_process?
  if @params.nil?
    log("anonymous query (to be processed)")
    return true
  end
  unless for_this_cluster?
    log("query for different cluster (mine: #{cluster_id}, to be ignroed)")
    return false
  end

  unless @params.include?("node")
    log("anonymous node query (to be processed)")
    return true
  end
  unless for_me?
    log("query for different node (me: #{@serf_name}, to be ignored)")
    return false
  end

  log("query for this node (to be processed)")
  true
end