console: implement an HTTP cache for Clickhouse-backed requests

Fix #328
This commit is contained in:
Vincent Bernat
2022-12-22 15:40:22 +01:00
parent fe4295614e
commit 775dc08db2
18 changed files with 550 additions and 86 deletions

View File

@@ -81,15 +81,15 @@ func (c *Component) Start() error {
endpoint := c.d.HTTP.GinRouter.Group("/api/v0/console", c.d.Auth.UserAuthentication())
endpoint.GET("/configuration", c.configHandlerFunc)
endpoint.GET("/docs/:name", c.docsHandlerFunc)
endpoint.GET("/widget/flow-last", c.widgetFlowLastHandlerFunc)
endpoint.GET("/widget/flow-rate", c.widgetFlowRateHandlerFunc)
endpoint.GET("/widget/exporters", c.widgetExportersHandlerFunc)
endpoint.GET("/widget/top/:name", c.widgetTopHandlerFunc)
endpoint.GET("/widget/graph", c.widgetGraphHandlerFunc)
endpoint.POST("/graph", c.graphHandlerFunc)
endpoint.POST("/sankey", c.sankeyHandlerFunc)
endpoint.GET("/widget/flow-last", c.d.HTTP.CacheByRequestPath(5*time.Second), c.widgetFlowLastHandlerFunc)
endpoint.GET("/widget/flow-rate", c.d.HTTP.CacheByRequestPath(5*time.Second), c.widgetFlowRateHandlerFunc)
endpoint.GET("/widget/exporters", c.d.HTTP.CacheByRequestPath(30*time.Second), c.widgetExportersHandlerFunc)
endpoint.GET("/widget/top/:name", c.d.HTTP.CacheByRequestPath(30*time.Second), c.widgetTopHandlerFunc)
endpoint.GET("/widget/graph", c.d.HTTP.CacheByRequestPath(5*time.Minute), c.widgetGraphHandlerFunc)
endpoint.POST("/graph", c.d.HTTP.CacheByRequestBody(30*time.Minute), c.graphHandlerFunc)
endpoint.POST("/sankey", c.d.HTTP.CacheByRequestBody(30*time.Minute), c.sankeyHandlerFunc)
endpoint.POST("/filter/validate", c.filterValidateHandlerFunc)
endpoint.POST("/filter/complete", c.filterCompleteHandlerFunc)
endpoint.POST("/filter/complete", c.d.HTTP.CacheByRequestBody(time.Minute), c.filterCompleteHandlerFunc)
endpoint.GET("/filter/saved", c.filterSavedListHandlerFunc)
endpoint.DELETE("/filter/saved/:id", c.filterSavedDeleteHandlerFunc)
endpoint.POST("/filter/saved", c.filterSavedAddHandlerFunc)