Class: Profiler::Api::ClusterController

Inherits:
Profiler::ApplicationController show all
Defined in:
app/controllers/profiler/api/cluster_controller.rb

Instance Method Summary collapse

Instance Method Details

#heartbeatObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/profiler/api/cluster_controller.rb', line 20

def heartbeat
  name = params[:name].to_s
  entry = Profiler.slave_registry.heartbeat(name)
  if entry.nil?
    render json: { error: "Unknown slave — please re-register" }, status: :not_found
  else
    render json: { ok: true }
  end
end

#registerObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/profiler/api/cluster_controller.rb', line 8

def register
  name = params[:name].to_s
  url  = params[:url].to_s

  if name.empty? || url.empty?
    return render json: { error: "name and url are required" }, status: :unprocessable_entity
  end

  Profiler.slave_registry.register(name: name, url: url)
  render json: { ok: true, name: name }
end

#slavesObject



30
31
32
# File 'app/controllers/profiler/api/cluster_controller.rb', line 30

def slaves
  render json: { slaves: Profiler.slave_registry.all }
end