mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Use ProcessGet instead of ProcessList for fetch a single process
This commit is contained in:
@@ -423,6 +423,18 @@ func (n *Core) ProcessValidateConfig(config *app.Config) error {
|
|||||||
return client.ProcessValidateConfig(config)
|
return client.ProcessValidateConfig(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Core) ProcessGet(id app.ProcessID, filter []string) (api.Process, error) {
|
||||||
|
n.lock.RLock()
|
||||||
|
client := n.client
|
||||||
|
n.lock.RUnlock()
|
||||||
|
|
||||||
|
if client == nil {
|
||||||
|
return api.Process{}, ErrNoPeer
|
||||||
|
}
|
||||||
|
|
||||||
|
return client.Process(id, filter)
|
||||||
|
}
|
||||||
|
|
||||||
func (n *Core) ProcessList(options client.ProcessListOptions) ([]api.Process, error) {
|
func (n *Core) ProcessList(options client.ProcessListOptions) ([]api.Process, error) {
|
||||||
n.lock.RLock()
|
n.lock.RLock()
|
||||||
client := n.client
|
client := n.client
|
||||||
|
@@ -555,20 +555,12 @@ func (p *Manager) ProcessGet(nodeid string, id app.ProcessID, filter []string) (
|
|||||||
return api.Process{}, err
|
return api.Process{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list, err := node.Core().ProcessList(client.ProcessListOptions{
|
process, err := node.Core().ProcessGet(id, filter)
|
||||||
ID: []string{id.ID},
|
|
||||||
Filter: filter,
|
|
||||||
Domain: id.Domain,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Process{}, err
|
return api.Process{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(list) == 0 {
|
return process, nil
|
||||||
return api.Process{}, fmt.Errorf("process not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
return list[0], nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Manager) ProcessAdd(nodeid string, config *app.Config, metadata map[string]interface{}) error {
|
func (p *Manager) ProcessAdd(nodeid string, config *app.Config, metadata map[string]interface{}) error {
|
||||||
|
Reference in New Issue
Block a user