mirror of
https://github.com/datarhei/core.git
synced 2025-10-11 19:00:13 +08:00
Add /api/v3/cluster/process/:id/probe endpoint
This commit is contained in:
@@ -40,6 +40,7 @@ type Node interface {
|
||||
ReloadProcess(id app.ProcessID) error
|
||||
DeleteProcess(id app.ProcessID) error
|
||||
UpdateProcess(id app.ProcessID, config *app.Config, metadata map[string]interface{}) error
|
||||
ProbeProcess(id app.ProcessID) (clientapi.Probe, error)
|
||||
|
||||
NodeReader
|
||||
}
|
||||
@@ -1106,3 +1107,21 @@ func (n *node) UpdateProcess(id app.ProcessID, config *app.Config, metadata map[
|
||||
|
||||
return n.peer.ProcessUpdate(client.NewProcessID(id.ID, id.Domain), cfg)
|
||||
}
|
||||
|
||||
func (n *node) ProbeProcess(id app.ProcessID) (clientapi.Probe, error) {
|
||||
n.peerLock.RLock()
|
||||
defer n.peerLock.RUnlock()
|
||||
|
||||
if n.peer == nil {
|
||||
probe := clientapi.Probe{
|
||||
Log: []string{fmt.Sprintf("the node %s where the process %s resides, is not connected", n.id, id.String())},
|
||||
}
|
||||
return probe, fmt.Errorf("not connected")
|
||||
}
|
||||
|
||||
probe, err := n.peer.ProcessProbe(client.NewProcessID(id.ID, id.Domain))
|
||||
|
||||
probe.Log = append([]string{fmt.Sprintf("probed on node: %s", n.id)}, probe.Log...)
|
||||
|
||||
return probe, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user