mirror of https://github.com/status-im/consul.git
Revert "local state: rename Add{Check,Service}State to Set{Check,Service}State"
This reverts commit 9280841a80
.
This commit is contained in:
parent
e95d22b9a8
commit
fa45a6a547
|
@ -206,13 +206,21 @@ func (l *State) AddService(service *structs.NodeService, token string) error {
|
|||
service.ID = service.Service
|
||||
}
|
||||
|
||||
l.SetServiceState(&ServiceState{
|
||||
l.AddServiceState(&ServiceState{
|
||||
Service: service,
|
||||
Token: token,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *State) AddServiceState(s *ServiceState) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
|
||||
l.services[s.Service.ID] = s
|
||||
l.TriggerSyncChanges()
|
||||
}
|
||||
|
||||
// RemoveService is used to remove a service entry from the local state.
|
||||
// The agent will make a best effort to ensure it is deregistered.
|
||||
func (l *State) RemoveService(id string) error {
|
||||
|
@ -277,17 +285,6 @@ func (l *State) ServiceState(id string) *ServiceState {
|
|||
return s.Clone()
|
||||
}
|
||||
|
||||
// SetServiceState is used to overwrite a raw service state with the given
|
||||
// state. This method is safe to be called concurrently but should only be used
|
||||
// during testing. You should most likely call AddService instead.
|
||||
func (l *State) SetServiceState(s *ServiceState) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
|
||||
l.services[s.Service.ID] = s
|
||||
l.TriggerSyncChanges()
|
||||
}
|
||||
|
||||
// ServiceStates returns a shallow copy of all service state records.
|
||||
// The service record still points to the original service record and
|
||||
// must not be modified.
|
||||
|
@ -348,13 +345,21 @@ func (l *State) AddCheck(check *structs.HealthCheck, token string) error {
|
|||
// hard-set the node name
|
||||
check.Node = l.config.NodeName
|
||||
|
||||
l.SetCheckState(&CheckState{
|
||||
l.AddCheckState(&CheckState{
|
||||
Check: check,
|
||||
Token: token,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *State) AddCheckState(c *CheckState) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
|
||||
l.checks[c.Check.CheckID] = c
|
||||
l.TriggerSyncChanges()
|
||||
}
|
||||
|
||||
// RemoveCheck is used to remove a health check from the local state.
|
||||
// The agent will make a best effort to ensure it is deregistered
|
||||
// todo(fs): RemoveService returns an error for a non-existant service. RemoveCheck should as well.
|
||||
|
@ -479,17 +484,6 @@ func (l *State) CheckState(id types.CheckID) *CheckState {
|
|||
return c.Clone()
|
||||
}
|
||||
|
||||
// SetCheckState is used to overwrite a raw check state with the given
|
||||
// state. This method is safe to be called concurrently but should only be used
|
||||
// during testing. You should most likely call AddCheck instead.
|
||||
func (l *State) SetCheckState(c *CheckState) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
|
||||
l.checks[c.Check.CheckID] = c
|
||||
l.TriggerSyncChanges()
|
||||
}
|
||||
|
||||
// CheckStates returns a shallow copy of all health check state records.
|
||||
// The health check records and the deferred checks still point to
|
||||
// the original values and must not be modified.
|
||||
|
|
|
@ -108,7 +108,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
|||
Tags: []string{},
|
||||
Port: 11211,
|
||||
}
|
||||
a.State.SetServiceState(&local.ServiceState{
|
||||
a.State.AddServiceState(&local.ServiceState{
|
||||
Service: srv6,
|
||||
InSync: true,
|
||||
})
|
||||
|
@ -679,7 +679,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
|||
Name: "cache",
|
||||
Status: api.HealthPassing,
|
||||
}
|
||||
a.State.SetCheckState(&local.CheckState{
|
||||
a.State.AddCheckState(&local.CheckState{
|
||||
Check: chk5,
|
||||
InSync: true,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue