Class: Jubatus::Common::ClientBase

Inherits:
Object
  • Object
show all
Defined in:
lib/jubatus/common/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, name, timeout_sec) ⇒ ClientBase

Returns a new instance of ClientBase.


47
48
49
50
51
# File 'lib/jubatus/common/client.rb', line 47

def initialize(host, port, name, timeout_sec)
  @cli = MessagePack::RPC::Client.new(host, port)
  @cli.timeout = timeout_sec
  @jubatus_client = Jubatus::Common::Client.new(@cli, name)
end

Class Method Details

.connect(host, port, name, timeout_sec, &block) ⇒ Object


53
54
55
56
57
58
59
60
# File 'lib/jubatus/common/client.rb', line 53

def self.connect(host, port, name, timeout_sec, &block)
  begin
    client = self.new(host, port, name, timeout_sec)
    block.call(client)
  ensure
    client.get_client.close
  end
end

Instance Method Details

#do_mixObject


92
93
94
# File 'lib/jubatus/common/client.rb', line 92

def do_mix
  @jubatus_client.call("do_mix", [], TBool.new, [])
end

#get_clientObject


62
63
64
# File 'lib/jubatus/common/client.rb', line 62

def get_client
  @cli
end

#get_configObject


74
75
76
# File 'lib/jubatus/common/client.rb', line 74

def get_config
  @jubatus_client.call("get_config", [], TString.new, [])
end

#get_nameObject


66
67
68
# File 'lib/jubatus/common/client.rb', line 66

def get_name
  @jubatus_client.name
end

#get_proxy_statusObject


96
97
98
99
# File 'lib/jubatus/common/client.rb', line 96

def get_proxy_status
  @jubatus_client.call("get_proxy_status", [], TMap.new(TString.new, TMap.new(
      TString.new, TString.new)), [])
end

#get_statusObject


87
88
89
90
# File 'lib/jubatus/common/client.rb', line 87

def get_status
  @jubatus_client.call("get_status", [], TMap.new(TString.new, TMap.new(
      TString.new, TString.new)), [])
end

#load(id) ⇒ Object


83
84
85
# File 'lib/jubatus/common/client.rb', line 83

def load(id)
  @jubatus_client.call("load", [id], TBool.new, [TString.new])
end

#save(id) ⇒ Object


78
79
80
81
# File 'lib/jubatus/common/client.rb', line 78

def save(id)
  @jubatus_client.call("save", [id], TMap.new(TString.new, TString.new),
      [TString.new])
end

#set_name(name) ⇒ Object


70
71
72
# File 'lib/jubatus/common/client.rb', line 70

def set_name(name)
  @jubatus_client.name = name
end