* rename flush to update

This commit is contained in:
Daniel Thomas 2021-10-04 14:08:47 +02:00
parent 75eaa4f19b
commit 23e1432203
3 changed files with 7 additions and 7 deletions

View File

@ -54,7 +54,7 @@ func (c *cache) get(id cacheID) (*cachedResponse, bool) {
return response, ok
}
func (c *cache) flush() {
func (c *cache) update() {
c.RLock()
defer c.RUnlock()
c.cacheMap = cacheMap{}

View File

@ -111,8 +111,8 @@ func getLoop(
for {
select {
case command := <-chanFlush:
l.Info("cache flush command coming in", zap.String("flushCommand", string(command)))
c.flush()
l.Info("cache update command coming in", zap.String("flushCommand", string(command)))
c.update()
c.callWebHooks()
case nextJob := <-chanRequestJob:
id := getCacheIDForRequest(nextJob.request)

View File

@ -15,7 +15,7 @@ const (
responseFoo = `i am a foo response`
responseBar = `i am bar response`
responseUpdate = `update`
responseFlush = `flush`
responseFlush = `update`
)
type getStats func(path string) int
@ -72,7 +72,7 @@ func GetWebHook(t *testing.T) (getStats, http.HandlerFunc) {
case "/update":
w.Write([]byte(responseUpdate))
return
case "/flush":
case "/update":
w.Write([]byte(responseFlush))
return
}
@ -96,7 +96,7 @@ func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string)
"",
[]WebHookURL{
WebHookURL(webHookServer.URL + "/update"),
WebHookURL(webHookServer.URL + "/flush"),
WebHookURL(webHookServer.URL + "/update"),
},
)
s = httptest.NewServer(p)
@ -135,6 +135,6 @@ func TestProxy(t *testing.T) {
//
assert.Equal(t, 1, ws("/update"))
assert.Equal(t, 1, ws("/flush"))
assert.Equal(t, 1, ws("/update"))
}