Add Debug.Cache method
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: micro/go-micro/util/file/proto/file.proto
|
||||
// source: util/file/proto/file.proto
|
||||
|
||||
package go_micro_server
|
||||
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/debug/service/handler"
|
||||
"github.com/micro/go-micro/v2/proxy"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
@@ -42,7 +43,7 @@ func New(name string, p proxy.Proxy) *Server {
|
||||
server.DefaultRouter.Handle(
|
||||
// inject the debug handler
|
||||
server.DefaultRouter.NewHandler(
|
||||
handler.NewHandler(),
|
||||
handler.NewHandler(client.DefaultClient),
|
||||
server.InternalHandler(true),
|
||||
),
|
||||
)
|
||||
|
@@ -229,6 +229,7 @@ func AuthHandler(fn func() auth.Auth) server.HandlerWrapper {
|
||||
}
|
||||
|
||||
type cacheWrapper struct {
|
||||
cache func() *client.Cache
|
||||
client.Client
|
||||
}
|
||||
|
||||
@@ -242,7 +243,7 @@ func (c *cacheWrapper) Call(ctx context.Context, req client.Request, rsp interfa
|
||||
}
|
||||
|
||||
// if the client doesn't have a cacbe setup don't continue
|
||||
cache := c.Options().Cache
|
||||
cache := c.cache()
|
||||
if cache == nil {
|
||||
return c.Client.Call(ctx, req, rsp, opts...)
|
||||
}
|
||||
@@ -269,6 +270,6 @@ func (c *cacheWrapper) Call(ctx context.Context, req client.Request, rsp interfa
|
||||
}
|
||||
|
||||
// CacheClient wraps requests with the cache wrapper
|
||||
func CacheClient(c client.Client) client.Client {
|
||||
return &cacheWrapper{c}
|
||||
func CacheClient(cacheFn func() *client.Cache, c client.Client) client.Client {
|
||||
return &cacheWrapper{cacheFn, c}
|
||||
}
|
||||
|
Reference in New Issue
Block a user