MCPcopy
hub / github.com/sourcegraph/checkup / CheckAndStore

Method CheckAndStore

checkup.go:101–120  ·  view source on GitHub ↗

CheckAndStore performs health checks and immediately stores the results to the configured storage if there were no errors. Checks are not performed if c.Storage is nil. If c.Storage is also a Maintainer, Maintain() will be called if Store() is successful.

()

Source from the content-addressed store, hash-verified

99// is nil. If c.Storage is also a Maintainer, Maintain()
100// will be called if Store() is successful.
101func (c Checkup) CheckAndStore() error {
102 if c.Storage == nil {
103 return fmt.Errorf("no storage mechanism defined")
104 }
105 results, err := c.Check()
106 if err != nil {
107 return err
108 }
109
110 err = c.Storage.Store(results)
111 if err != nil {
112 return err
113 }
114
115 if m, ok := c.Storage.(Maintainer); ok {
116 return m.Maintain()
117 }
118
119 return nil
120}
121
122// CheckAndStoreEvery calls CheckAndStore every interval. It returns
123// the ticker that it's using so you can stop it when you don't want

Callers 2

CheckAndStoreEveryMethod · 0.95
TestCheckAndStoreFunction · 0.95

Calls 3

CheckMethod · 0.95
StoreMethod · 0.65
MaintainMethod · 0.65

Tested by 1

TestCheckAndStoreFunction · 0.76