From d8ac493395f4154b60f927e83976c5c6909d247c Mon Sep 17 00:00:00 2001 From: Shaker Islam Date: Wed, 1 Apr 2020 16:52:23 -0400 Subject: [PATCH] docs: document exported functions in agent.go (closes #7101) (#7366) and fix one linter error --- agent/agent.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agent/agent.go b/agent/agent.go index 6940064e1..1939d0f26 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -3240,6 +3240,8 @@ func (a *Agent) removeCheckLocked(checkID structs.CheckID, persist bool) error { return nil } +// ServiceHTTPBasedChecks returns HTTP and GRPC based Checks +// for the given serviceID func (a *Agent) ServiceHTTPBasedChecks(serviceID structs.ServiceID) []structs.CheckType { a.stateLock.Lock() defer a.stateLock.Unlock() @@ -3258,6 +3260,7 @@ func (a *Agent) ServiceHTTPBasedChecks(serviceID structs.ServiceID) []structs.Ch return chkTypes } +// AdvertiseAddrLAN returns the AdvertiseAddrLAN config value func (a *Agent) AdvertiseAddrLAN() string { return a.config.AdvertiseAddrLAN.String() } @@ -3668,7 +3671,7 @@ func (a *Agent) loadServices(conf *config.RuntimeConfig, snap map[structs.CheckI } } - for serviceID, _ := range persistedServiceConfigs { + for serviceID := range persistedServiceConfigs { if a.State.Service(serviceID) == nil { // This can be cleaned up now. if err := a.purgeServiceConfig(serviceID); err != nil { @@ -4015,6 +4018,9 @@ func (a *Agent) loadLimits(conf *config.RuntimeConfig) { a.config.RPCMaxBurst = conf.RPCMaxBurst } +// ReloadConfig will atomically reload all configs from the given newCfg, +// including all services, checks, tokens, metadata, dnsServer configs, etc. +// It will also reload all ongoing watches. func (a *Agent) ReloadConfig(newCfg *config.RuntimeConfig) error { // Bulk update the services and checks a.PauseSync() @@ -4305,6 +4311,7 @@ func (a *Agent) registerCache() { }) } +// LocalState returns the agent's local state func (a *Agent) LocalState() *local.State { return a.State }