grafana/pkg/middleware
Michael Mandrus 5626461b3c
Caching: Refactor enterprise query caching middleware to a wire service (#65616)
* define initial service and add to wire

* update caching service interface

* add skipQueryCache header handler and update metrics query function to use it

* add caching service as a dependency to query service

* working caching impl

* propagate cache status to frontend in response

* beginning of improvements suggested by Lean - separate caching logic from query logic.

* more changes to simplify query function

* Decided to revert renaming of function

* Remove error status from cache request

* add extra documentation

* Move query caching duration metric to query package

* add a little bit of documentation

* wip: convert resource caching

* Change return type of query service QueryData to a QueryDataResponse with Headers

* update codeowners

* change X-Cache value to const

* use resource caching in endpoint handlers

* write resource headers to response even if it's not a cache hit

* fix panic caused by lack of nil check

* update unit test

* remove NONE header - shouldn't show up in OSS

* Convert everything to use the plugin middleware

* revert a few more things

* clean up unused vars

* start reverting resource caching, start to implement in plugin middleware

* revert more, fix typo

* Update caching interfaces - resource caching now has a separate cache method

* continue wiring up new resource caching conventions - still in progress

* add more safety to implementation

* remove some unused objects

* remove some code that I left in by accident

* add some comments, fix codeowners, fix duplicate registration

* fix source of panic in resource middleware

* Update client decorator test to provide an empty response object

* create tests for caching middleware

* fix unit test

* Update pkg/services/caching/service.go

Co-authored-by: Arati R. <33031346+suntala@users.noreply.github.com>

* improve error message in error log

* quick docs update

* Remove use of mockery. Update return signature to return an explicit hit/miss bool

* create unit test for empty request context

* rename caching metrics to make it clear they pertain to caching

* Update pkg/services/pluginsintegration/clientmiddleware/caching_middleware.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* Add clarifying comments to cache skip middleware func

* Add comment pointing to the resource cache update call

* fix unit tests (missing dependency)

* try to fix mystery syntax error

* fix a panic

* Caching: Introduce feature toggle to caching service refactor (#66323)

* introduce new feature toggle

* hide calls to new service behind a feature flag

* remove licensing flag from toggle (misunderstood what it was for)

* fix unit tests

* rerun toggle gen

---------

Co-authored-by: Arati R. <33031346+suntala@users.noreply.github.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2023-04-12 12:30:33 -04:00
..
cookies Auth: Add feature flag to move token rotation to client (#65060) 2023-03-23 14:39:04 +01:00
csrf CSRF: Fix additional headers option (#50629) 2022-07-13 19:28:59 +01:00
loggermw Logger: Add feature toggle for errors in HTTP request logs (#64425) 2023-03-31 15:38:09 +02:00
auth_test.go Chore: Move ReqContext to contexthandler service (#62102) 2023-01-27 08:50:36 +01:00
auth.go Plugins: Migrate licensing and access control to pkg/services/pluginsintegration package (#65258) 2023-03-27 11:15:37 +02:00
csp.go Middleware: Add CSP Report Only support (#58074) 2022-11-16 17:11:26 +00:00
dashboard_redirect_test.go Chore: Remove endpoints that contain the slug field (#35104) 2021-06-03 16:20:13 +03:00
dashboard_redirect.go Chore: Move ReqContext to contexthandler service (#62102) 2023-01-27 08:50:36 +01:00
gziper.go Chore: replace macaron with web package (#40136) 2021-10-11 14:30:59 +02:00
middleware_basic_auth_test.go LDAP: Move LDAP globals to Config (#63255) 2023-02-10 19:01:55 +01:00
middleware_jwt_auth_test.go ContextHandler: add all configured auth header to context (#62775) 2023-02-02 16:25:46 +01:00
middleware_test.go Auth: Fix orgrole picker disabled if isSynced user (#64033) 2023-03-22 17:41:59 +00:00
middleware.go Caching: Refactor enterprise query caching middleware to a wire service (#65616) 2023-04-12 12:30:33 -04:00
org_redirect_test.go Auth: Refactor auth package (#58920) 2022-11-18 09:56:06 +01:00
org_redirect.go UserService: use the UserService instead of calling sqlstore directly (#55745) 2022-09-27 07:58:49 -04:00
quota_test.go Auth: Refactor auth package (#58920) 2022-11-18 09:56:06 +01:00
quota.go Chore: Move ReqContext to contexthandler service (#62102) 2023-01-27 08:50:36 +01:00
recovery_test.go Chore: Move ReqContext to contexthandler service (#62102) 2023-01-27 08:50:36 +01:00
recovery.go Handle ioutil deprecations (#53526) 2022-08-10 15:37:51 +02:00
request_metrics.go Logger: Add feature toggle for errors in HTTP request logs (#64425) 2023-03-31 15:38:09 +02:00
request_test.go Logger: Add feature toggle for errors in HTTP request logs (#64425) 2023-03-31 15:38:09 +02:00
request_tracing.go Logger: Add feature toggle for errors in HTTP request logs (#64425) 2023-03-31 15:38:09 +02:00
testing.go API: Permit Cache-Control (browser caching) for datasource resources (#62033) 2023-02-02 20:34:55 +00:00
validate_host.go Chore: Move ReqContext to contexthandler service (#62102) 2023-01-27 08:50:36 +01:00