mirror of https://github.com/status-im/consul.git
agent/proxy: improve comments on snapshotting
This commit is contained in:
parent
e0bbe66427
commit
1a32435a4d
|
@ -96,8 +96,14 @@ type Manager struct {
|
|||
// for changes to this value.
|
||||
runState managerRunState
|
||||
|
||||
proxies map[string]Proxy
|
||||
// lastSnapshot stores a pointer to the last snapshot that successfully
|
||||
// wrote to disk. This is used for dup detection to prevent rewriting
|
||||
// the same snapshot multiple times. snapshots should never be that
|
||||
// large so keeping it in-memory should be cheap even for thousands of
|
||||
// proxies (unlikely scenario).
|
||||
lastSnapshot *snapshot
|
||||
|
||||
proxies map[string]Proxy
|
||||
}
|
||||
|
||||
// NewManager initializes a Manager. After initialization, the exported
|
||||
|
|
|
@ -101,7 +101,10 @@ func (m *Manager) snapshot(path string, checkDup bool) error {
|
|||
|
||||
// Write the file
|
||||
err = file.WriteAtomic(path, encoded)
|
||||
if err == nil && checkDup {
|
||||
|
||||
// If we are checking for dups and we had a successful write, store
|
||||
// it so we don't rewrite the same value.
|
||||
if checkDup && err == nil {
|
||||
m.lastSnapshot = &s
|
||||
}
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue