Documentation ¶
Index ¶
- Constants
- type CacheQueryResponseFn
- type CacheResourceResponseFn
- type CachedQueryDataResponse
- type CachedResourceDataResponse
- type CachingService
- type FakeOSSCachingService
- func (f *FakeOSSCachingService) AssertCalls(t *testing.T, fn string, times int)
- func (f *FakeOSSCachingService) HandleQueryRequest(ctx context.Context, req *backend.QueryDataRequest) (bool, CachedQueryDataResponse)
- func (f *FakeOSSCachingService) HandleResourceRequest(ctx context.Context, req *backend.CallResourceRequest) (bool, CachedResourceDataResponse)
- func (f *FakeOSSCachingService) Reset()
- type OSSCachingService
Constants ¶
View Source
const ( XCacheHeader = "X-Cache" StatusHit = "HIT" StatusMiss = "MISS" StatusBypass = "BYPASS" StatusError = "ERROR" StatusDisabled = "DISABLED" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheQueryResponseFn ¶
type CacheQueryResponseFn func(context.Context, *backend.QueryDataResponse)
type CacheResourceResponseFn ¶
type CacheResourceResponseFn func(context.Context, *backend.CallResourceResponse)
type CachedQueryDataResponse ¶
type CachedQueryDataResponse struct { // The cached data response associated with a query, or nil if no cached data is found Response *backend.QueryDataResponse // A function that should be used to cache a QueryDataResponse for a given query. // It can be set to nil by the method implementation (if there is an error, for example), so it should be checked before being called. UpdateCacheFn CacheQueryResponseFn }
type CachedResourceDataResponse ¶
type CachedResourceDataResponse struct { // The cached response associated with a resource request, or nil if no cached data is found Response *backend.CallResourceResponse // A function that should be used to cache a CallResourceResponse for a given resource request. // It can be set to nil by the method implementation (if there is an error, for example), so it should be checked before being called. // Because plugins can send multiple responses asynchronously, the implementation should be able to handle multiple calls to this function for one request. UpdateCacheFn CacheResourceResponseFn }
type CachingService ¶
type CachingService interface { // HandleQueryRequest uses a QueryDataRequest to check the cache for any existing results for that query. // If none are found, it should return false and a CachedQueryDataResponse with an UpdateCacheFn which can be used to update the results cache after the fact. // This function may populate any response headers (accessible through the context) with the cache status using the X-Cache header. HandleQueryRequest(context.Context, *backend.QueryDataRequest) (bool, CachedQueryDataResponse) // HandleResourceRequest uses a CallResourceRequest to check the cache for any existing results for that request. If none are found, it should return false. // This function may populate any response headers (accessible through the context) with the cache status using the X-Cache header. HandleResourceRequest(context.Context, *backend.CallResourceRequest) (bool, CachedResourceDataResponse) }
type FakeOSSCachingService ¶
type FakeOSSCachingService struct { ReturnHit bool ReturnResourceResponse CachedResourceDataResponse ReturnQueryResponse CachedQueryDataResponse // contains filtered or unexported fields }
func NewFakeOSSCachingService ¶
func NewFakeOSSCachingService() *FakeOSSCachingService
func (*FakeOSSCachingService) AssertCalls ¶
func (f *FakeOSSCachingService) AssertCalls(t *testing.T, fn string, times int)
func (*FakeOSSCachingService) HandleQueryRequest ¶
func (f *FakeOSSCachingService) HandleQueryRequest(ctx context.Context, req *backend.QueryDataRequest) (bool, CachedQueryDataResponse)
func (*FakeOSSCachingService) HandleResourceRequest ¶
func (f *FakeOSSCachingService) HandleResourceRequest(ctx context.Context, req *backend.CallResourceRequest) (bool, CachedResourceDataResponse)
func (*FakeOSSCachingService) Reset ¶
func (f *FakeOSSCachingService) Reset()
type OSSCachingService ¶
type OSSCachingService struct { }
Implementation of interface - does nothing
func ProvideCachingService ¶
func ProvideCachingService() *OSSCachingService
func (*OSSCachingService) HandleQueryRequest ¶
func (s *OSSCachingService) HandleQueryRequest(ctx context.Context, req *backend.QueryDataRequest) (bool, CachedQueryDataResponse)
func (*OSSCachingService) HandleResourceRequest ¶
func (s *OSSCachingService) HandleResourceRequest(ctx context.Context, req *backend.CallResourceRequest) (bool, CachedResourceDataResponse)
Click to show internal directories.
Click to hide internal directories.