* 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 return response, ok
} }
func (c *cache) flush() { func (c *cache) update() {
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()
c.cacheMap = cacheMap{} c.cacheMap = cacheMap{}

View File

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

View File

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