mirror of https://github.com/status-im/consul.git
parent
c6e441dd60
commit
abd83f2d28
|
@ -18,7 +18,9 @@ import (
|
|||
"github.com/hashicorp/consul/types"
|
||||
)
|
||||
|
||||
// Config is the configuration for the State.
|
||||
// Config is the configuration for the State. It is
|
||||
// populated during NewLocalAgent from the agent configuration to avoid
|
||||
// race conditions with the agent configuration.
|
||||
type Config struct {
|
||||
AdvertiseAddr string
|
||||
CheckUpdateInterval time.Duration
|
||||
|
@ -108,7 +110,7 @@ type rpc interface {
|
|||
}
|
||||
|
||||
// State is used to represent the node's services,
|
||||
// and checks. We use it to perform anti-entropy with the
|
||||
// and checks. We used it to perform anti-entropy with the
|
||||
// catalog representation
|
||||
type State struct {
|
||||
sync.RWMutex
|
||||
|
@ -152,7 +154,7 @@ type State struct {
|
|||
tokens *token.Store
|
||||
}
|
||||
|
||||
// NewLocalState creates a new local state for the agent.
|
||||
// NewLocalState creates a is used to initialize the local state
|
||||
func NewState(c Config, lg *log.Logger, tokens *token.Store) *State {
|
||||
l := &State{
|
||||
config: c,
|
||||
|
@ -166,8 +168,6 @@ func NewState(c Config, lg *log.Logger, tokens *token.Store) *State {
|
|||
return l
|
||||
}
|
||||
|
||||
// SetDiscardCheckOutput configures whether the check output
|
||||
// is discarded. This can be changed at runtime.
|
||||
func (l *State) SetDiscardCheckOutput(b bool) {
|
||||
l.discardCheckOutput.Store(b)
|
||||
}
|
||||
|
@ -181,7 +181,6 @@ func (l *State) ServiceToken(id string) string {
|
|||
}
|
||||
|
||||
// serviceToken returns an ACL token associated with a service.
|
||||
// This method is not synchronized and the lock must already be held.
|
||||
func (l *State) serviceToken(id string) string {
|
||||
var token string
|
||||
if s := l.services[id]; s != nil {
|
||||
|
@ -311,7 +310,6 @@ func (l *State) CheckToken(checkID types.CheckID) string {
|
|||
}
|
||||
|
||||
// checkToken returns an ACL token associated with a check.
|
||||
// This method is not synchronized and the lock must already be held.
|
||||
func (l *State) checkToken(id types.CheckID) string {
|
||||
var token string
|
||||
c := l.checks[id]
|
||||
|
@ -502,10 +500,7 @@ func (l *State) CheckStates() map[types.CheckID]*CheckState {
|
|||
}
|
||||
|
||||
// CriticalCheckStates returns the locally registered checks that the
|
||||
// agent is aware of and are being kept in sync with the server.
|
||||
// The map contains a shallow copy of the current check states but
|
||||
// references to the actual check definition which must not be
|
||||
// modified.
|
||||
// agent is aware of and are being kept in sync with the server
|
||||
func (l *State) CriticalCheckStates() map[types.CheckID]*CheckState {
|
||||
l.RLock()
|
||||
defer l.RUnlock()
|
||||
|
|
Loading…
Reference in New Issue