mirror of
https://github.com/foomo/contentfulproxy.git
synced 2025-10-16 12:25:37 +00:00
* rename flush to update
This commit is contained in:
parent
75eaa4f19b
commit
23e1432203
@ -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{}
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
@ -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"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user