mirror of
https://github.com/status-im/consul.git
synced 2025-02-18 08:36:46 +00:00
agent: use persist/load/purge convention for function names
This commit is contained in:
parent
2d1b873e4b
commit
69921808ee
@ -761,7 +761,7 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *CheckType, persist
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore persisted state, if any
|
// Restore persisted state, if any
|
||||||
if err := a.recallCheckState(check); err != nil {
|
if err := a.loadCheckState(check); err != nil {
|
||||||
a.logger.Printf("[WARN] agent: failed restoring state for check %q: %s",
|
a.logger.Printf("[WARN] agent: failed restoring state for check %q: %s",
|
||||||
check.CheckID, err)
|
check.CheckID, err)
|
||||||
}
|
}
|
||||||
@ -917,8 +917,8 @@ func (a *Agent) persistCheckState(check *CheckTTL, status, output string) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// recallCheckState is used to restore the persisted state of a check.
|
// loadCheckState is used to restore the persisted state of a check.
|
||||||
func (a *Agent) recallCheckState(check *structs.HealthCheck) error {
|
func (a *Agent) loadCheckState(check *structs.HealthCheck) error {
|
||||||
// Try to read the persisted state for this check
|
// Try to read the persisted state for this check
|
||||||
file := filepath.Join(a.config.DataDir, checkStateDir, stringHash(check.CheckID))
|
file := filepath.Join(a.config.DataDir, checkStateDir, stringHash(check.CheckID))
|
||||||
buf, err := ioutil.ReadFile(file)
|
buf, err := ioutil.ReadFile(file)
|
||||||
|
@ -1441,7 +1441,7 @@ func TestAgent_persistCheckState(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAgent_recallCheckState(t *testing.T) {
|
func TestAgent_loadCheckState(t *testing.T) {
|
||||||
config := nextConfig()
|
config := nextConfig()
|
||||||
dir, agent := makeAgent(t, config)
|
dir, agent := makeAgent(t, config)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
@ -1459,12 +1459,12 @@ func TestAgent_recallCheckState(t *testing.T) {
|
|||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to recall the state
|
// Try to load the state
|
||||||
health := &structs.HealthCheck{
|
health := &structs.HealthCheck{
|
||||||
CheckID: "check1",
|
CheckID: "check1",
|
||||||
Status: structs.HealthCritical,
|
Status: structs.HealthCritical,
|
||||||
}
|
}
|
||||||
if err := agent.recallCheckState(health); err != nil {
|
if err := agent.loadCheckState(health); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1489,8 +1489,8 @@ func TestAgent_recallCheckState(t *testing.T) {
|
|||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to recall
|
// Try to load
|
||||||
if err := agent.recallCheckState(health); err != nil {
|
if err := agent.loadCheckState(health); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user