From 7d7f4046e8202bd5213daa1b3d26019208cba096 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Fri, 22 May 2020 16:52:24 +0100 Subject: [PATCH 1/6] Client Cache --- auth/service/service.go | 2 +- client/cache.go | 64 +++++++++++++++++++++++++++++++++++++++++ client/options.go | 14 +++++++++ config/cmd/cmd.go | 7 +++-- service.go | 1 + util/wrapper/wrapper.go | 45 +++++++++++++++++++++++++++++ 6 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 client/cache.go diff --git a/auth/service/service.go b/auth/service/service.go index 733244a6..fb5cb755 100644 --- a/auth/service/service.go +++ b/auth/service/service.go @@ -261,7 +261,7 @@ func (s *svc) listRules(filters ...string) []*pb.Rule { // loadRules retrieves the rules from the auth service func (s *svc) loadRules() { - rsp, err := s.rule.List(context.TODO(), &pb.ListRequest{}) + rsp, err := s.rule.List(context.TODO(), &pb.ListRequest{}, client.WithCache(time.Minute)) s.Lock() defer s.Unlock() diff --git a/client/cache.go b/client/cache.go new file mode 100644 index 00000000..7a6b8347 --- /dev/null +++ b/client/cache.go @@ -0,0 +1,64 @@ +package client + +import ( + "context" + "crypto/sha1" + "encoding/json" + "fmt" + "sync" + "time" + + "github.com/micro/go-micro/v2/metadata" +) + +// NewCache returns an initialised cache. +// TODO: Setup a go routine to expire records in the cache. +func NewCache() *Cache { + return &Cache{ + values: make(map[string]interface{}), + } +} + +// Cache for responses +type Cache struct { + values map[string]interface{} + mutex sync.Mutex +} + +// Get a response from the cache +func (c *Cache) Get(ctx context.Context, req *Request) interface{} { + md, _ := metadata.FromContext(ctx) + ck := cacheKey{req, md} + + c.mutex.Lock() + defer c.mutex.Unlock() + + if val, ok := c.values[ck.Hash()]; ok { + return val + } + + return nil +} + +// Set a response in the cache +func (c *Cache) Set(ctx context.Context, req *Request, rsp interface{}, expiry time.Duration) { + md, _ := metadata.FromContext(ctx) + ck := cacheKey{req, md} + + c.mutex.Lock() + c.values[ck.Hash()] = rsp + defer c.mutex.Unlock() +} + +type cacheKey struct { + Request *Request + Metadata metadata.Metadata +} + +// Source: https://gobyexample.com/sha1-hashes +func (k *cacheKey) Hash() string { + bytes, _ := json.Marshal(k) + h := sha1.New() + h.Write(bytes) + return fmt.Sprintf("%x", h.Sum(nil)) +} diff --git a/client/options.go b/client/options.go index 5c8f833d..8ba14698 100644 --- a/client/options.go +++ b/client/options.go @@ -29,6 +29,9 @@ type Options struct { PoolSize int PoolTTL time.Duration + // Response cache + Cache *Cache + // Middleware for client Wrappers []Wrapper @@ -59,6 +62,8 @@ type CallOptions struct { StreamTimeout time.Duration // Use the services own auth token ServiceToken bool + // Duration to cache the response for + CacheExpiry time.Duration // Middleware for low level call func CallWrappers []CallWrapper @@ -91,6 +96,7 @@ type RequestOptions struct { func NewOptions(options ...Option) Options { opts := Options{ + Cache: NewCache(), Context: context.Background(), ContentType: DefaultContentType, Codecs: make(map[string]codec.NewCodec), @@ -324,6 +330,14 @@ func WithServiceToken() CallOption { } } +// WithCache is a CallOption which sets the duration the response +// shoull be cached for +func WithCache(c time.Duration) CallOption { + return func(o *CallOptions) { + o.CacheExpiry = c + } +} + func WithMessageContentType(ct string) MessageOption { return func(o *MessageOptions) { o.ContentType = ct diff --git a/config/cmd/cmd.go b/config/cmd/cmd.go index 6ee8bd92..5753cefe 100644 --- a/config/cmd/cmd.go +++ b/config/cmd/cmd.go @@ -471,9 +471,12 @@ func (c *cmd) Before(ctx *cli.Context) error { var serverOpts []server.Option var clientOpts []client.Option - // setup a client to use when calling the runtime + // setup a client to use when calling the runtime. It is important the auth client is wrapped + // after the cache client since the wrappers are applied in reverse order and the cache will use + // some of the headers set by the auth client. authFn := func() auth.Auth { return *c.opts.Auth } - microClient := wrapper.AuthClient(authFn, grpc.NewClient()) + microClient := wrapper.CacheClient(grpc.NewClient()) + microClient = wrapper.AuthClient(authFn, microClient) // Set the store if name := ctx.String("store"); len(name) > 0 { diff --git a/service.go b/service.go index 9c414654..da13c8cd 100644 --- a/service.go +++ b/service.go @@ -42,6 +42,7 @@ func newService(opts ...Option) Service { // wrap client to inject From-Service header on any calls options.Client = wrapper.FromService(serviceName, options.Client) options.Client = wrapper.TraceCall(serviceName, trace.DefaultTracer, options.Client) + options.Client = wrapper.CacheClient(options.Client) options.Client = wrapper.AuthClient(authFn, options.Client) // wrap the server to provide handler stats diff --git a/util/wrapper/wrapper.go b/util/wrapper/wrapper.go index 51672f0a..598df497 100644 --- a/util/wrapper/wrapper.go +++ b/util/wrapper/wrapper.go @@ -227,3 +227,48 @@ func AuthHandler(fn func() auth.Auth) server.HandlerWrapper { } } } + +type cacheWrapper struct { + client.Client +} + +// Call executes the request. If the CacheExpiry option was set, the response will be cached using +// a hash of the metadata and request as the key. +func (c *cacheWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error { + // parse the options + var options client.CallOptions + for _, o := range opts { + o(&options) + } + + // if the client doesn't have a cacbe setup don't continue + cache := c.Options().Cache + if cache == nil { + return c.Client.Call(ctx, req, rsp, opts...) + } + + // if the cache expiry is not set, execute the call without the cache + if options.CacheExpiry == 0 { + return c.Client.Call(ctx, req, rsp, opts...) + } + + // check to see if there is a response + if cRsp := cache.Get(ctx, &req); cRsp != nil { + rsp = cRsp + return nil + } + + // don't cache the result if there was an error + if err := c.Client.Call(ctx, req, rsp, opts...); err != nil { + return err + } + + // set the result in the cache + cache.Set(ctx, &req, rsp, options.CacheExpiry) + return nil +} + +// CacheClient wraps requests with the cache wrapper +func CacheClient(c client.Client) client.Client { + return &cacheWrapper{c} +} From 496293afa1e013a10284f3625d9e5b84dc5db677 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Sat, 23 May 2020 11:34:44 +0100 Subject: [PATCH 2/6] Use hash/fnv, add tests, fix request bug --- client/cache.go | 53 ++++++++++++---------------- client/cache_test.go | 76 +++++++++++++++++++++++++++++++++++++++++ util/wrapper/wrapper.go | 4 +-- 3 files changed, 99 insertions(+), 34 deletions(-) create mode 100644 client/cache_test.go diff --git a/client/cache.go b/client/cache.go index 7a6b8347..e4781dd6 100644 --- a/client/cache.go +++ b/client/cache.go @@ -2,63 +2,52 @@ package client import ( "context" - "crypto/sha1" "encoding/json" "fmt" - "sync" + "hash/fnv" "time" "github.com/micro/go-micro/v2/metadata" + cache "github.com/patrickmn/go-cache" ) // NewCache returns an initialised cache. -// TODO: Setup a go routine to expire records in the cache. func NewCache() *Cache { return &Cache{ - values: make(map[string]interface{}), + cache: cache.New(cache.NoExpiration, 30*time.Second), } } // Cache for responses type Cache struct { - values map[string]interface{} - mutex sync.Mutex + cache *cache.Cache } // Get a response from the cache -func (c *Cache) Get(ctx context.Context, req *Request) interface{} { - md, _ := metadata.FromContext(ctx) - ck := cacheKey{req, md} - - c.mutex.Lock() - defer c.mutex.Unlock() - - if val, ok := c.values[ck.Hash()]; ok { - return val - } - - return nil +func (c *Cache) Get(ctx context.Context, req *Request) (interface{}, bool) { + return c.cache.Get(key(ctx, req)) } // Set a response in the cache func (c *Cache) Set(ctx context.Context, req *Request, rsp interface{}, expiry time.Duration) { + c.cache.Set(key(ctx, req), rsp, expiry) +} + +// key returns a hash for the context and request +func key(ctx context.Context, req *Request) string { md, _ := metadata.FromContext(ctx) - ck := cacheKey{req, md} - c.mutex.Lock() - c.values[ck.Hash()] = rsp - defer c.mutex.Unlock() -} + bytes, _ := json.Marshal(map[string]interface{}{ + "metadata": md, + "request": map[string]interface{}{ + "service": (*req).Service(), + "endpoint": (*req).Endpoint(), + "method": (*req).Method(), + "body": (*req).Body(), + }, + }) -type cacheKey struct { - Request *Request - Metadata metadata.Metadata -} - -// Source: https://gobyexample.com/sha1-hashes -func (k *cacheKey) Hash() string { - bytes, _ := json.Marshal(k) - h := sha1.New() + h := fnv.New64() h.Write(bytes) return fmt.Sprintf("%x", h.Sum(nil)) } diff --git a/client/cache_test.go b/client/cache_test.go new file mode 100644 index 00000000..337312c1 --- /dev/null +++ b/client/cache_test.go @@ -0,0 +1,76 @@ +package client + +import ( + "context" + "testing" + "time" + + "github.com/micro/go-micro/v2/metadata" +) + +func TestCache(t *testing.T) { + ctx := context.TODO() + req := NewRequest("go.micro.service.foo", "Foo.Bar", nil) + + t.Run("CacheMiss", func(t *testing.T) { + if _, ok := NewCache().Get(ctx, &req); ok { + t.Errorf("Expected to get no result from Get") + } + }) + + t.Run("CacheHit", func(t *testing.T) { + c := NewCache() + + rsp := "theresponse" + c.Set(ctx, &req, rsp, time.Minute) + + if res, ok := c.Get(ctx, &req); !ok { + t.Errorf("Expected a result, got nothing") + } else if res != rsp { + t.Errorf("Expected '%v' result, got '%v'", rsp, res) + } + }) +} + +func TestCacheKey(t *testing.T) { + ctx := context.TODO() + req1 := NewRequest("go.micro.service.foo", "Foo.Bar", nil) + req2 := NewRequest("go.micro.service.foo", "Foo.Baz", nil) + req3 := NewRequest("go.micro.service.foo", "Foo.Baz", "customquery") + + t.Run("IdenticalRequests", func(t *testing.T) { + key1 := key(ctx, &req1) + key2 := key(ctx, &req1) + if key1 != key2 { + t.Errorf("Expected the keys to match for identical requests and context") + } + }) + + t.Run("DifferentRequestEndpoints", func(t *testing.T) { + key1 := key(ctx, &req1) + key2 := key(ctx, &req2) + + if key1 == key2 { + t.Errorf("Expected the keys to differ for different request endpoints") + } + }) + + t.Run("DifferentRequestBody", func(t *testing.T) { + key1 := key(ctx, &req2) + key2 := key(ctx, &req3) + + if key1 == key2 { + t.Errorf("Expected the keys to differ for different request bodies") + } + }) + + t.Run("DifferentMetadata", func(t *testing.T) { + mdCtx := metadata.Set(context.TODO(), "foo", "bar") + key1 := key(mdCtx, &req1) + key2 := key(ctx, &req1) + + if key1 == key2 { + t.Errorf("Expected the keys to differ for different metadata") + } + }) +} diff --git a/util/wrapper/wrapper.go b/util/wrapper/wrapper.go index 598df497..d5ff9e83 100644 --- a/util/wrapper/wrapper.go +++ b/util/wrapper/wrapper.go @@ -253,8 +253,8 @@ func (c *cacheWrapper) Call(ctx context.Context, req client.Request, rsp interfa } // check to see if there is a response - if cRsp := cache.Get(ctx, &req); cRsp != nil { - rsp = cRsp + if r, ok := cache.Get(ctx, &req); ok { + rsp = r return nil } From 67146ecdc2c0d9340696348e762781b3ccb6d6ce Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Sun, 24 May 2020 18:05:23 +0100 Subject: [PATCH 3/6] Client Cache tests --- util/wrapper/wrapper_test.go | 71 +++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/util/wrapper/wrapper_test.go b/util/wrapper/wrapper_test.go index fa03af21..c3454779 100644 --- a/util/wrapper/wrapper_test.go +++ b/util/wrapper/wrapper_test.go @@ -3,7 +3,9 @@ package wrapper import ( "context" "testing" + "time" + "github.com/micro/go-micro/v2/client" "github.com/micro/go-micro/v2/metadata" ) @@ -49,5 +51,72 @@ func TestWrapper(t *testing.T) { } } } - +} + +type testClient struct { + callCount int + callRsp interface{} + cache *client.Cache + client.Client +} + +func (c *testClient) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error { + c.callCount++ + rsp = c.callRsp + return nil +} + +func (c *testClient) Options() client.Options { + return client.Options{Cache: c.cache} +} +func TestCacheWrapper(t *testing.T) { + req := client.NewRequest("go.micro.service.foo", "Foo.Bar", nil) + + t.Run("NilCache", func(t *testing.T) { + cli := new(testClient) + w := CacheClient(cli) + + // perfroming two requests should increment the call count by two indicating the cache wasn't + // used even though the WithCache option was passed. + w.Call(context.TODO(), req, nil, client.WithCache(time.Minute)) + w.Call(context.TODO(), req, nil, client.WithCache(time.Minute)) + + if cli.callCount != 2 { + t.Errorf("Expected the client to have been called twice") + } + }) + + t.Run("OptionNotSet", func(t *testing.T) { + cli := new(testClient) + w := CacheClient(cli) + + // perfroming two requests should increment the call count by two since we didn't pass the WithCache + // option to Call. + w.Call(context.TODO(), req, nil) + w.Call(context.TODO(), req, nil) + + if cli.callCount != 2 { + t.Errorf("Expected the client to have been called twice") + } + }) + + t.Run("OptionSet", func(t *testing.T) { + cli := &testClient{callRsp: "foobar", cache: client.NewCache()} + w := CacheClient(cli) + + // perfroming two requests should increment the call count by once since the second request should + // have used the cache + err1 := w.Call(context.TODO(), req, nil, client.WithCache(time.Minute)) + err2 := w.Call(context.TODO(), req, nil, client.WithCache(time.Minute)) + + if err1 != nil { + t.Errorf("Expected nil error, got %v", err1) + } + if err2 != nil { + t.Errorf("Expected nil error, got %v", err2) + } + if cli.callCount != 1 { + t.Errorf("Expected the client to be called 1 time, was actually called %v time(s)", cli.callCount) + } + }) } From 2729569f6625cc24ff28e32ff937b498310e9d96 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Sun, 24 May 2020 18:45:57 +0100 Subject: [PATCH 4/6] Add Debug.Cache method --- client/cache.go | 13 + config/cmd/cmd.go | 3 +- debug/service/handler/debug.go | 12 +- debug/service/proto/debug.pb.go | 190 +++- debug/service/proto/debug.pb.micro.go | 17 + debug/service/proto/debug.proto | 13 +- server/proto/server.pb.go | 552 +++++----- server/proto/server.pb.micro.go | 2 +- service.go | 8 +- util/file/proto/file.pb.go | 1452 ++++++++++++------------- util/file/proto/file.pb.micro.go | 2 +- util/mux/mux.go | 3 +- util/wrapper/wrapper.go | 7 +- 13 files changed, 1148 insertions(+), 1126 deletions(-) diff --git a/client/cache.go b/client/cache.go index e4781dd6..16bd9c70 100644 --- a/client/cache.go +++ b/client/cache.go @@ -33,6 +33,19 @@ func (c *Cache) Set(ctx context.Context, req *Request, rsp interface{}, expiry t c.cache.Set(key(ctx, req), rsp, expiry) } +// List the key value pairs in the cache +func (c *Cache) List() map[string]string { + items := c.cache.Items() + + rsp := make(map[string]string, len(items)) + for k, v := range items { + bytes, _ := json.Marshal(v.Object) + rsp[k] = string(bytes) + } + + return rsp +} + // key returns a hash for the context and request func key(ctx context.Context, req *Request) string { md, _ := metadata.FromContext(ctx) diff --git a/config/cmd/cmd.go b/config/cmd/cmd.go index 5753cefe..2f65b86c 100644 --- a/config/cmd/cmd.go +++ b/config/cmd/cmd.go @@ -475,7 +475,8 @@ func (c *cmd) Before(ctx *cli.Context) error { // after the cache client since the wrappers are applied in reverse order and the cache will use // some of the headers set by the auth client. authFn := func() auth.Auth { return *c.opts.Auth } - microClient := wrapper.CacheClient(grpc.NewClient()) + cacheFn := func() *client.Cache { return (*c.opts.Client).Options().Cache } + microClient := wrapper.CacheClient(cacheFn, grpc.NewClient()) microClient = wrapper.AuthClient(authFn, microClient) // Set the store diff --git a/debug/service/handler/debug.go b/debug/service/handler/debug.go index ffe1a922..cf97cdc0 100644 --- a/debug/service/handler/debug.go +++ b/debug/service/handler/debug.go @@ -5,6 +5,7 @@ import ( "context" "time" + "github.com/micro/go-micro/v2/client" "github.com/micro/go-micro/v2/debug/log" proto "github.com/micro/go-micro/v2/debug/service/proto" "github.com/micro/go-micro/v2/debug/stats" @@ -13,11 +14,12 @@ import ( ) // NewHandler returns an instance of the Debug Handler -func NewHandler() *Debug { +func NewHandler(c client.Client) *Debug { return &Debug{ log: log.DefaultLog, stats: stats.DefaultStats, trace: trace.DefaultTracer, + cache: c.Options().Cache, } } @@ -30,6 +32,8 @@ type Debug struct { stats stats.Stats // the tracer trace trace.Tracer + // the cache + cache *client.Cache } func (d *Debug) Health(ctx context.Context, req *proto.HealthRequest, rsp *proto.HealthResponse) error { @@ -164,3 +168,9 @@ func (d *Debug) Log(ctx context.Context, stream server.Stream) error { return nil } + +// Cache returns all the key value pairs in the client cache +func (d *Debug) Cache(ctx context.Context, req *proto.CacheRequest, rsp *proto.CacheResponse) error { + rsp.Values = d.cache.List() + return nil +} diff --git a/debug/service/proto/debug.pb.go b/debug/service/proto/debug.pb.go index 41e6aebe..859d44cd 100644 --- a/debug/service/proto/debug.pb.go +++ b/debug/service/proto/debug.pb.go @@ -582,6 +582,76 @@ func (m *Span) GetType() SpanType { return SpanType_INBOUND } +type CacheRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CacheRequest) Reset() { *m = CacheRequest{} } +func (m *CacheRequest) String() string { return proto.CompactTextString(m) } +func (*CacheRequest) ProtoMessage() {} +func (*CacheRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_df91f41a5db378e6, []int{9} +} + +func (m *CacheRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CacheRequest.Unmarshal(m, b) +} +func (m *CacheRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CacheRequest.Marshal(b, m, deterministic) +} +func (m *CacheRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CacheRequest.Merge(m, src) +} +func (m *CacheRequest) XXX_Size() int { + return xxx_messageInfo_CacheRequest.Size(m) +} +func (m *CacheRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CacheRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CacheRequest proto.InternalMessageInfo + +type CacheResponse struct { + Values map[string]string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CacheResponse) Reset() { *m = CacheResponse{} } +func (m *CacheResponse) String() string { return proto.CompactTextString(m) } +func (*CacheResponse) ProtoMessage() {} +func (*CacheResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_df91f41a5db378e6, []int{10} +} + +func (m *CacheResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CacheResponse.Unmarshal(m, b) +} +func (m *CacheResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CacheResponse.Marshal(b, m, deterministic) +} +func (m *CacheResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CacheResponse.Merge(m, src) +} +func (m *CacheResponse) XXX_Size() int { + return xxx_messageInfo_CacheResponse.Size(m) +} +func (m *CacheResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CacheResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CacheResponse proto.InternalMessageInfo + +func (m *CacheResponse) GetValues() map[string]string { + if m != nil { + return m.Values + } + return nil +} + func init() { proto.RegisterEnum("SpanType", SpanType_name, SpanType_value) proto.RegisterType((*HealthRequest)(nil), "HealthRequest") @@ -595,50 +665,56 @@ func init() { proto.RegisterType((*TraceResponse)(nil), "TraceResponse") proto.RegisterType((*Span)(nil), "Span") proto.RegisterMapType((map[string]string)(nil), "Span.MetadataEntry") + proto.RegisterType((*CacheRequest)(nil), "CacheRequest") + proto.RegisterType((*CacheResponse)(nil), "CacheResponse") + proto.RegisterMapType((map[string]string)(nil), "CacheResponse.ValuesEntry") } func init() { proto.RegisterFile("debug/service/proto/debug.proto", fileDescriptor_df91f41a5db378e6) } var fileDescriptor_df91f41a5db378e6 = []byte{ - // 594 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xdb, 0x6e, 0xd3, 0x40, - 0x10, 0x8d, 0xed, 0x38, 0xb1, 0xa7, 0x8d, 0xa9, 0x96, 0x8b, 0x2c, 0x73, 0x69, 0x65, 0x09, 0x29, - 0x5c, 0xe4, 0x40, 0x79, 0x41, 0xf0, 0x86, 0x8a, 0x04, 0x52, 0x69, 0xa5, 0x6d, 0xfb, 0x01, 0x5b, - 0x7b, 0xe4, 0x1a, 0xea, 0x0b, 0xbb, 0xeb, 0x4a, 0xf9, 0x16, 0xbe, 0x80, 0x37, 0x7e, 0x86, 0xff, - 0x41, 0x7b, 0x71, 0x1b, 0x0b, 0xa1, 0x3e, 0xf0, 0xb6, 0xe7, 0xec, 0xec, 0xc9, 0xcc, 0xc9, 0xf1, - 0xc0, 0x6e, 0x81, 0xe7, 0x7d, 0xb9, 0x12, 0xc8, 0xaf, 0xaa, 0x1c, 0x57, 0x1d, 0x6f, 0x65, 0xbb, - 0xd2, 0x5c, 0xa6, 0xcf, 0xe9, 0x33, 0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4, 0x1f, 0xea, 0xe2, 0xd3, 0x75, 0x87, 0x54, 0xd3, 0xff, 0xe5, 0xf5, 0xf3, - 0xa7, 0x10, 0x0c, 0x72, 0x64, 0x0b, 0xe6, 0x9f, 0x8f, 0x3e, 0x1c, 0x9f, 0x1d, 0x1d, 0xec, 0x4c, - 0xc8, 0x36, 0x04, 0xc7, 0x67, 0xa7, 0x06, 0x39, 0xfb, 0x3f, 0x1d, 0xf0, 0x0f, 0xd4, 0x62, 0x20, - 0xbb, 0xe0, 0x1d, 0xb6, 0x25, 0xd9, 0xca, 0x6e, 0x12, 0x9c, 0xcc, 0x6d, 0x50, 0xd2, 0xc9, 0x2b, - 0x87, 0xbc, 0x80, 0x99, 0x59, 0x04, 0x24, 0xca, 0x46, 0xcb, 0x23, 0xb9, 0x93, 0x8d, 0x37, 0x44, - 0x3a, 0x21, 0x4b, 0xf0, 0xf5, 0x07, 0x4e, 0x16, 0xd9, 0xe6, 0x4e, 0x48, 0xa2, 0x6c, 0xf4, 0xdd, - 0x9b, 0x4a, 0xfd, 0xa7, 0x93, 0x45, 0xb6, 0x19, 0x8e, 0x24, 0xca, 0x46, 0x59, 0x48, 0x27, 0xe7, - 0x33, 0xbd, 0xbb, 0xde, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x42, 0x7f, 0x05, 0xde, 0x04, - 0x00, 0x00, + // 646 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xdb, 0x6e, 0xd3, 0x4a, + 0x14, 0x8d, 0xed, 0x38, 0xb1, 0x77, 0x62, 0x9f, 0x6a, 0xce, 0x45, 0x96, 0x0f, 0xd0, 0xca, 0x12, + 0x52, 0xb8, 0x68, 0x02, 0xe1, 0x85, 0xcb, 0x1b, 0x14, 0x09, 0xa4, 0xd2, 0x4a, 0xd3, 0x96, 0xf7, + 0xa9, 0x3d, 0x4a, 0x03, 0xf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 0x18, 0x0f, 0xee, 0x90, 0x51, 0xea, 0x10, 0xa2, 0x08, 0xf7, + 0xc3, 0x9a, 0xc6, 0x78, 0x90, 0x4d, 0xa3, 0xd4, 0x96, 0xa1, 0x08, 0xf7, 0xad, 0x4e, 0xe3, 0xa1, + 0x93, 0xd9, 0xe8, 0x6c, 0xa2, 0xaf, 0xee, 0x93, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x22, 0x65, + 0x99, 0x10, 0x98, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -657,6 +733,7 @@ type DebugClient interface { Health(ctx context.Context, in *HealthRequest, opts ...grpc.CallOption) (*HealthResponse, error) Stats(ctx context.Context, in *StatsRequest, opts ...grpc.CallOption) (*StatsResponse, error) Trace(ctx context.Context, in *TraceRequest, opts ...grpc.CallOption) (*TraceResponse, error) + Cache(ctx context.Context, in *CacheRequest, opts ...grpc.CallOption) (*CacheResponse, error) } type debugClient struct { @@ -726,12 +803,22 @@ func (c *debugClient) Trace(ctx context.Context, in *TraceRequest, opts ...grpc. return out, nil } +func (c *debugClient) Cache(ctx context.Context, in *CacheRequest, opts ...grpc.CallOption) (*CacheResponse, error) { + out := new(CacheResponse) + err := c.cc.Invoke(ctx, "/Debug/Cache", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // DebugServer is the server API for Debug service. type DebugServer interface { Log(*LogRequest, Debug_LogServer) error Health(context.Context, *HealthRequest) (*HealthResponse, error) Stats(context.Context, *StatsRequest) (*StatsResponse, error) Trace(context.Context, *TraceRequest) (*TraceResponse, error) + Cache(context.Context, *CacheRequest) (*CacheResponse, error) } // UnimplementedDebugServer can be embedded to have forward compatible implementations. @@ -750,6 +837,9 @@ func (*UnimplementedDebugServer) Stats(ctx context.Context, req *StatsRequest) ( func (*UnimplementedDebugServer) Trace(ctx context.Context, req *TraceRequest) (*TraceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Trace not implemented") } +func (*UnimplementedDebugServer) Cache(ctx context.Context, req *CacheRequest) (*CacheResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Cache not implemented") +} func RegisterDebugServer(s *grpc.Server, srv DebugServer) { s.RegisterService(&_Debug_serviceDesc, srv) @@ -830,6 +920,24 @@ func _Debug_Trace_Handler(srv interface{}, ctx context.Context, dec func(interfa return interceptor(ctx, in, info, handler) } +func _Debug_Cache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CacheRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DebugServer).Cache(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/Debug/Cache", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DebugServer).Cache(ctx, req.(*CacheRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Debug_serviceDesc = grpc.ServiceDesc{ ServiceName: "Debug", HandlerType: (*DebugServer)(nil), @@ -846,6 +954,10 @@ var _Debug_serviceDesc = grpc.ServiceDesc{ MethodName: "Trace", Handler: _Debug_Trace_Handler, }, + { + MethodName: "Cache", + Handler: _Debug_Cache_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/debug/service/proto/debug.pb.micro.go b/debug/service/proto/debug.pb.micro.go index 3d71b722..1e436e22 100644 --- a/debug/service/proto/debug.pb.micro.go +++ b/debug/service/proto/debug.pb.micro.go @@ -46,6 +46,7 @@ type DebugService interface { Health(ctx context.Context, in *HealthRequest, opts ...client.CallOption) (*HealthResponse, error) Stats(ctx context.Context, in *StatsRequest, opts ...client.CallOption) (*StatsResponse, error) Trace(ctx context.Context, in *TraceRequest, opts ...client.CallOption) (*TraceResponse, error) + Cache(ctx context.Context, in *CacheRequest, opts ...client.CallOption) (*CacheResponse, error) } type debugService struct { @@ -139,6 +140,16 @@ func (c *debugService) Trace(ctx context.Context, in *TraceRequest, opts ...clie return out, nil } +func (c *debugService) Cache(ctx context.Context, in *CacheRequest, opts ...client.CallOption) (*CacheResponse, error) { + req := c.c.NewRequest(c.name, "Debug.Cache", in) + out := new(CacheResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // Server API for Debug service type DebugHandler interface { @@ -146,6 +157,7 @@ type DebugHandler interface { Health(context.Context, *HealthRequest, *HealthResponse) error Stats(context.Context, *StatsRequest, *StatsResponse) error Trace(context.Context, *TraceRequest, *TraceResponse) error + Cache(context.Context, *CacheRequest, *CacheResponse) error } func RegisterDebugHandler(s server.Server, hdlr DebugHandler, opts ...server.HandlerOption) error { @@ -154,6 +166,7 @@ func RegisterDebugHandler(s server.Server, hdlr DebugHandler, opts ...server.Han Health(ctx context.Context, in *HealthRequest, out *HealthResponse) error Stats(ctx context.Context, in *StatsRequest, out *StatsResponse) error Trace(ctx context.Context, in *TraceRequest, out *TraceResponse) error + Cache(ctx context.Context, in *CacheRequest, out *CacheResponse) error } type Debug struct { debug @@ -217,3 +230,7 @@ func (h *debugHandler) Stats(ctx context.Context, in *StatsRequest, out *StatsRe func (h *debugHandler) Trace(ctx context.Context, in *TraceRequest, out *TraceResponse) error { return h.DebugHandler.Trace(ctx, in, out) } + +func (h *debugHandler) Cache(ctx context.Context, in *CacheRequest, out *CacheResponse) error { + return h.DebugHandler.Cache(ctx, in, out) +} diff --git a/debug/service/proto/debug.proto b/debug/service/proto/debug.proto index 7516651e..6646cb65 100644 --- a/debug/service/proto/debug.proto +++ b/debug/service/proto/debug.proto @@ -1,10 +1,11 @@ syntax = "proto3"; service Debug { - rpc Log(LogRequest) returns (stream Record) {}; - rpc Health(HealthRequest) returns (HealthResponse) {}; - rpc Stats(StatsRequest) returns (StatsResponse) {}; + rpc Log(LogRequest) returns (stream Record) {}; + rpc Health(HealthRequest) returns (HealthResponse) {}; + rpc Stats(StatsRequest) returns (StatsResponse) {}; rpc Trace(TraceRequest) returns (TraceResponse) {}; + rpc Cache(CacheRequest) returns (CacheResponse) {}; } message HealthRequest { @@ -97,3 +98,9 @@ message Span { map metadata = 7; SpanType type = 8; } + +message CacheRequest {} + +message CacheResponse { + map values = 1; +} \ No newline at end of file diff --git a/server/proto/server.pb.go b/server/proto/server.pb.go index ea21354b..5813ff28 100644 --- a/server/proto/server.pb.go +++ b/server/proto/server.pb.go @@ -1,350 +1,324 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.22.0 -// protoc v3.6.1 -// source: github.com/micro/go-micro/server/proto/server.proto +// source: server/proto/server.proto package go_micro_server import ( + context "context" + fmt "fmt" proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" ) -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type HandleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - Protocol string `protobuf:"bytes,3,opt,name=protocol,proto3" json:"protocol,omitempty"` + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` + Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + Protocol string `protobuf:"bytes,3,opt,name=protocol,proto3" json:"protocol,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *HandleRequest) Reset() { - *x = HandleRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HandleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HandleRequest) ProtoMessage() {} - -func (x *HandleRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HandleRequest.ProtoReflect.Descriptor instead. +func (m *HandleRequest) Reset() { *m = HandleRequest{} } +func (m *HandleRequest) String() string { return proto.CompactTextString(m) } +func (*HandleRequest) ProtoMessage() {} func (*HandleRequest) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_server_proto_server_proto_rawDescGZIP(), []int{0} + return fileDescriptor_1959cecd4d1121a1, []int{0} } -func (x *HandleRequest) GetService() string { - if x != nil { - return x.Service +func (m *HandleRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HandleRequest.Unmarshal(m, b) +} +func (m *HandleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HandleRequest.Marshal(b, m, deterministic) +} +func (m *HandleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HandleRequest.Merge(m, src) +} +func (m *HandleRequest) XXX_Size() int { + return xxx_messageInfo_HandleRequest.Size(m) +} +func (m *HandleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HandleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HandleRequest proto.InternalMessageInfo + +func (m *HandleRequest) GetService() string { + if m != nil { + return m.Service } return "" } -func (x *HandleRequest) GetEndpoint() string { - if x != nil { - return x.Endpoint +func (m *HandleRequest) GetEndpoint() string { + if m != nil { + return m.Endpoint } return "" } -func (x *HandleRequest) GetProtocol() string { - if x != nil { - return x.Protocol +func (m *HandleRequest) GetProtocol() string { + if m != nil { + return m.Protocol } return "" } type HandleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *HandleResponse) Reset() { - *x = HandleResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HandleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HandleResponse) ProtoMessage() {} - -func (x *HandleResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HandleResponse.ProtoReflect.Descriptor instead. +func (m *HandleResponse) Reset() { *m = HandleResponse{} } +func (m *HandleResponse) String() string { return proto.CompactTextString(m) } +func (*HandleResponse) ProtoMessage() {} func (*HandleResponse) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_server_proto_server_proto_rawDescGZIP(), []int{1} + return fileDescriptor_1959cecd4d1121a1, []int{1} } +func (m *HandleResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HandleResponse.Unmarshal(m, b) +} +func (m *HandleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HandleResponse.Marshal(b, m, deterministic) +} +func (m *HandleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HandleResponse.Merge(m, src) +} +func (m *HandleResponse) XXX_Size() int { + return xxx_messageInfo_HandleResponse.Size(m) +} +func (m *HandleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HandleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_HandleResponse proto.InternalMessageInfo + type SubscribeRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` + Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *SubscribeRequest) Reset() { - *x = SubscribeRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SubscribeRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SubscribeRequest) ProtoMessage() {} - -func (x *SubscribeRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead. +func (m *SubscribeRequest) Reset() { *m = SubscribeRequest{} } +func (m *SubscribeRequest) String() string { return proto.CompactTextString(m) } +func (*SubscribeRequest) ProtoMessage() {} func (*SubscribeRequest) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_server_proto_server_proto_rawDescGZIP(), []int{2} + return fileDescriptor_1959cecd4d1121a1, []int{2} } -func (x *SubscribeRequest) GetTopic() string { - if x != nil { - return x.Topic +func (m *SubscribeRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SubscribeRequest.Unmarshal(m, b) +} +func (m *SubscribeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SubscribeRequest.Marshal(b, m, deterministic) +} +func (m *SubscribeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubscribeRequest.Merge(m, src) +} +func (m *SubscribeRequest) XXX_Size() int { + return xxx_messageInfo_SubscribeRequest.Size(m) +} +func (m *SubscribeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SubscribeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SubscribeRequest proto.InternalMessageInfo + +func (m *SubscribeRequest) GetTopic() string { + if m != nil { + return m.Topic } return "" } type SubscribeResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *SubscribeResponse) Reset() { - *x = SubscribeResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SubscribeResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SubscribeResponse) ProtoMessage() {} - -func (x *SubscribeResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SubscribeResponse.ProtoReflect.Descriptor instead. +func (m *SubscribeResponse) Reset() { *m = SubscribeResponse{} } +func (m *SubscribeResponse) String() string { return proto.CompactTextString(m) } +func (*SubscribeResponse) ProtoMessage() {} func (*SubscribeResponse) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_server_proto_server_proto_rawDescGZIP(), []int{3} + return fileDescriptor_1959cecd4d1121a1, []int{3} } -var File_github_com_micro_go_micro_server_proto_server_proto protoreflect.FileDescriptor - -var file_github_com_micro_go_micro_server_proto_server_proto_rawDesc = []byte{ - 0x0a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x69, 0x63, - 0x72, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x61, 0x0a, 0x0d, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1a, 0x0a, - 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x10, 0x0a, 0x0e, 0x48, 0x61, 0x6e, - 0x64, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x0a, 0x10, 0x53, - 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x74, 0x6f, 0x70, 0x69, 0x63, 0x22, 0x13, 0x0a, 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xab, 0x01, 0x0a, 0x06, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x4b, 0x0a, 0x06, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x12, - 0x1e, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x2e, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1f, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x2e, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x54, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, - 0x21, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +func (m *SubscribeResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SubscribeResponse.Unmarshal(m, b) +} +func (m *SubscribeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SubscribeResponse.Marshal(b, m, deterministic) +} +func (m *SubscribeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubscribeResponse.Merge(m, src) +} +func (m *SubscribeResponse) XXX_Size() int { + return xxx_messageInfo_SubscribeResponse.Size(m) +} +func (m *SubscribeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SubscribeResponse.DiscardUnknown(m) } -var ( - file_github_com_micro_go_micro_server_proto_server_proto_rawDescOnce sync.Once - file_github_com_micro_go_micro_server_proto_server_proto_rawDescData = file_github_com_micro_go_micro_server_proto_server_proto_rawDesc -) +var xxx_messageInfo_SubscribeResponse proto.InternalMessageInfo -func file_github_com_micro_go_micro_server_proto_server_proto_rawDescGZIP() []byte { - file_github_com_micro_go_micro_server_proto_server_proto_rawDescOnce.Do(func() { - file_github_com_micro_go_micro_server_proto_server_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_micro_go_micro_server_proto_server_proto_rawDescData) - }) - return file_github_com_micro_go_micro_server_proto_server_proto_rawDescData +func init() { + proto.RegisterType((*HandleRequest)(nil), "go.micro.server.HandleRequest") + proto.RegisterType((*HandleResponse)(nil), "go.micro.server.HandleResponse") + proto.RegisterType((*SubscribeRequest)(nil), "go.micro.server.SubscribeRequest") + proto.RegisterType((*SubscribeResponse)(nil), "go.micro.server.SubscribeResponse") } -var file_github_com_micro_go_micro_server_proto_server_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_github_com_micro_go_micro_server_proto_server_proto_goTypes = []interface{}{ - (*HandleRequest)(nil), // 0: go.micro.server.HandleRequest - (*HandleResponse)(nil), // 1: go.micro.server.HandleResponse - (*SubscribeRequest)(nil), // 2: go.micro.server.SubscribeRequest - (*SubscribeResponse)(nil), // 3: go.micro.server.SubscribeResponse -} -var file_github_com_micro_go_micro_server_proto_server_proto_depIdxs = []int32{ - 0, // 0: go.micro.server.Server.Handle:input_type -> go.micro.server.HandleRequest - 2, // 1: go.micro.server.Server.Subscribe:input_type -> go.micro.server.SubscribeRequest - 1, // 2: go.micro.server.Server.Handle:output_type -> go.micro.server.HandleResponse - 3, // 3: go.micro.server.Server.Subscribe:output_type -> go.micro.server.SubscribeResponse - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name +func init() { proto.RegisterFile("server/proto/server.proto", fileDescriptor_1959cecd4d1121a1) } + +var fileDescriptor_1959cecd4d1121a1 = []byte{ + // 223 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x4e, 0x2d, 0x2a, + 0x4b, 0x2d, 0xd2, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x87, 0x70, 0xf4, 0xc0, 0x1c, 0x21, 0xfe, + 0xf4, 0x7c, 0xbd, 0xdc, 0xcc, 0xe4, 0xa2, 0x7c, 0x3d, 0x88, 0xb0, 0x52, 0x22, 0x17, 0xaf, 0x47, + 0x62, 0x5e, 0x4a, 0x4e, 0x6a, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, 0x04, 0x17, 0x3b, + 0x48, 0x2a, 0x33, 0x39, 0x55, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc6, 0x15, 0x92, 0xe2, + 0xe2, 0x48, 0xcd, 0x4b, 0x29, 0xc8, 0xcf, 0xcc, 0x2b, 0x91, 0x60, 0x02, 0x4b, 0xc1, 0xf9, 0x20, + 0x39, 0xb0, 0x05, 0xc9, 0xf9, 0x39, 0x12, 0xcc, 0x10, 0x39, 0x18, 0x5f, 0x49, 0x80, 0x8b, 0x0f, + 0x66, 0x45, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x92, 0x06, 0x97, 0x40, 0x70, 0x69, 0x52, 0x71, + 0x72, 0x51, 0x66, 0x12, 0xdc, 0x5e, 0x11, 0x2e, 0xd6, 0x92, 0xfc, 0x82, 0xcc, 0x64, 0xa8, 0xad, + 0x10, 0x8e, 0x92, 0x30, 0x97, 0x20, 0x92, 0x4a, 0x88, 0x76, 0xa3, 0xd5, 0x8c, 0x5c, 0x6c, 0xc1, + 0x60, 0xe7, 0x0b, 0x79, 0x73, 0xb1, 0x41, 0xcc, 0x16, 0x92, 0xd3, 0x43, 0xf3, 0x9a, 0x1e, 0x8a, + 0xbf, 0xa4, 0xe4, 0x71, 0xca, 0x43, 0x1d, 0xc5, 0x20, 0x14, 0xc2, 0xc5, 0x09, 0xb7, 0x4c, 0x48, + 0x11, 0x43, 0x3d, 0xba, 0x93, 0xa5, 0x94, 0xf0, 0x29, 0x81, 0x99, 0x9a, 0xc4, 0x06, 0x0e, 0x08, + 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa4, 0x3f, 0x79, 0x80, 0x96, 0x01, 0x00, 0x00, } -func init() { file_github_com_micro_go_micro_server_proto_server_proto_init() } -func file_github_com_micro_go_micro_server_proto_server_proto_init() { - if File_github_com_micro_go_micro_server_proto_server_proto != nil { - return +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// ServerClient is the client API for Server service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServerClient interface { + Handle(ctx context.Context, in *HandleRequest, opts ...grpc.CallOption) (*HandleResponse, error) + Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (*SubscribeResponse, error) +} + +type serverClient struct { + cc *grpc.ClientConn +} + +func NewServerClient(cc *grpc.ClientConn) ServerClient { + return &serverClient{cc} +} + +func (c *serverClient) Handle(ctx context.Context, in *HandleRequest, opts ...grpc.CallOption) (*HandleResponse, error) { + out := new(HandleResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.Server/Handle", in, out, opts...) + if err != nil { + return nil, err } - if !protoimpl.UnsafeEnabled { - file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HandleRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HandleResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SubscribeRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_server_proto_server_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SubscribeResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } + return out, nil +} + +func (c *serverClient) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (*SubscribeResponse, error) { + out := new(SubscribeResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.Server/Subscribe", in, out, opts...) + if err != nil { + return nil, err } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_github_com_micro_go_micro_server_proto_server_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 1, + return out, nil +} + +// ServerServer is the server API for Server service. +type ServerServer interface { + Handle(context.Context, *HandleRequest) (*HandleResponse, error) + Subscribe(context.Context, *SubscribeRequest) (*SubscribeResponse, error) +} + +// UnimplementedServerServer can be embedded to have forward compatible implementations. +type UnimplementedServerServer struct { +} + +func (*UnimplementedServerServer) Handle(ctx context.Context, req *HandleRequest) (*HandleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") +} +func (*UnimplementedServerServer) Subscribe(ctx context.Context, req *SubscribeRequest) (*SubscribeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Subscribe not implemented") +} + +func RegisterServerServer(s *grpc.Server, srv ServerServer) { + s.RegisterService(&_Server_serviceDesc, srv) +} + +func _Server_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HandleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServerServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.Server/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServerServer).Handle(ctx, req.(*HandleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Server_Subscribe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SubscribeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServerServer).Subscribe(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.Server/Subscribe", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServerServer).Subscribe(ctx, req.(*SubscribeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Server_serviceDesc = grpc.ServiceDesc{ + ServiceName: "go.micro.server.Server", + HandlerType: (*ServerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Server_Handle_Handler, }, - GoTypes: file_github_com_micro_go_micro_server_proto_server_proto_goTypes, - DependencyIndexes: file_github_com_micro_go_micro_server_proto_server_proto_depIdxs, - MessageInfos: file_github_com_micro_go_micro_server_proto_server_proto_msgTypes, - }.Build() - File_github_com_micro_go_micro_server_proto_server_proto = out.File - file_github_com_micro_go_micro_server_proto_server_proto_rawDesc = nil - file_github_com_micro_go_micro_server_proto_server_proto_goTypes = nil - file_github_com_micro_go_micro_server_proto_server_proto_depIdxs = nil + { + MethodName: "Subscribe", + Handler: _Server_Subscribe_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "server/proto/server.proto", } diff --git a/server/proto/server.pb.micro.go b/server/proto/server.pb.micro.go index 61ba016f..5d84eda9 100644 --- a/server/proto/server.pb.micro.go +++ b/server/proto/server.pb.micro.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-micro. DO NOT EDIT. -// source: github.com/micro/go-micro/server/proto/server.proto +// source: server/proto/server.proto package go_micro_server diff --git a/service.go b/service.go index da13c8cd..4d793920 100644 --- a/service.go +++ b/service.go @@ -35,14 +35,14 @@ func newService(opts ...Option) Service { // service name serviceName := options.Server.Options().Name - // authFn returns the auth, we pass as a function since auth - // has not yet been set at this point. + // we pass functions to the wrappers since the values can change during initialisation authFn := func() auth.Auth { return options.Server.Options().Auth } + cacheFn := func() *client.Cache { return options.Client.Options().Cache } // wrap client to inject From-Service header on any calls options.Client = wrapper.FromService(serviceName, options.Client) options.Client = wrapper.TraceCall(serviceName, trace.DefaultTracer, options.Client) - options.Client = wrapper.CacheClient(options.Client) + options.Client = wrapper.CacheClient(cacheFn, options.Client) options.Client = wrapper.AuthClient(authFn, options.Client) // wrap the server to provide handler stats @@ -184,7 +184,7 @@ func (s *service) Run() error { // register the debug handler s.opts.Server.Handle( s.opts.Server.NewHandler( - handler.NewHandler(), + handler.NewHandler(s.opts.Client), server.InternalHandler(true), ), ) diff --git a/util/file/proto/file.pb.go b/util/file/proto/file.pb.go index 3e2e7799..826ca43b 100644 --- a/util/file/proto/file.pb.go +++ b/util/file/proto/file.pb.go @@ -1,968 +1,854 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.22.0 -// protoc v3.6.1 -// source: micro/go-micro/util/file/proto/file.proto +// source: util/file/proto/file.proto package go_micro_server import ( + context "context" + fmt "fmt" proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" ) -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type OpenRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` - Truncate bool `protobuf:"varint,2,opt,name=truncate,proto3" json:"truncate,omitempty"` + Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` + Truncate bool `protobuf:"varint,2,opt,name=truncate,proto3" json:"truncate,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *OpenRequest) Reset() { - *x = OpenRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *OpenRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*OpenRequest) ProtoMessage() {} - -func (x *OpenRequest) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use OpenRequest.ProtoReflect.Descriptor instead. +func (m *OpenRequest) Reset() { *m = OpenRequest{} } +func (m *OpenRequest) String() string { return proto.CompactTextString(m) } +func (*OpenRequest) ProtoMessage() {} func (*OpenRequest) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{0} + return fileDescriptor_c90a6c4a93f92bf4, []int{0} } -func (x *OpenRequest) GetFilename() string { - if x != nil { - return x.Filename +func (m *OpenRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_OpenRequest.Unmarshal(m, b) +} +func (m *OpenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_OpenRequest.Marshal(b, m, deterministic) +} +func (m *OpenRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_OpenRequest.Merge(m, src) +} +func (m *OpenRequest) XXX_Size() int { + return xxx_messageInfo_OpenRequest.Size(m) +} +func (m *OpenRequest) XXX_DiscardUnknown() { + xxx_messageInfo_OpenRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_OpenRequest proto.InternalMessageInfo + +func (m *OpenRequest) GetFilename() string { + if m != nil { + return m.Filename } return "" } -func (x *OpenRequest) GetTruncate() bool { - if x != nil { - return x.Truncate +func (m *OpenRequest) GetTruncate() bool { + if m != nil { + return m.Truncate } return false } type OpenResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Result bool `protobuf:"varint,2,opt,name=result,proto3" json:"result,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Result bool `protobuf:"varint,2,opt,name=result,proto3" json:"result,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *OpenResponse) Reset() { - *x = OpenResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *OpenResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*OpenResponse) ProtoMessage() {} - -func (x *OpenResponse) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use OpenResponse.ProtoReflect.Descriptor instead. +func (m *OpenResponse) Reset() { *m = OpenResponse{} } +func (m *OpenResponse) String() string { return proto.CompactTextString(m) } +func (*OpenResponse) ProtoMessage() {} func (*OpenResponse) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{1} + return fileDescriptor_c90a6c4a93f92bf4, []int{1} } -func (x *OpenResponse) GetId() int64 { - if x != nil { - return x.Id +func (m *OpenResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_OpenResponse.Unmarshal(m, b) +} +func (m *OpenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_OpenResponse.Marshal(b, m, deterministic) +} +func (m *OpenResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_OpenResponse.Merge(m, src) +} +func (m *OpenResponse) XXX_Size() int { + return xxx_messageInfo_OpenResponse.Size(m) +} +func (m *OpenResponse) XXX_DiscardUnknown() { + xxx_messageInfo_OpenResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_OpenResponse proto.InternalMessageInfo + +func (m *OpenResponse) GetId() int64 { + if m != nil { + return m.Id } return 0 } -func (x *OpenResponse) GetResult() bool { - if x != nil { - return x.Result +func (m *OpenResponse) GetResult() bool { + if m != nil { + return m.Result } return false } type CloseRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *CloseRequest) Reset() { - *x = CloseRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CloseRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CloseRequest) ProtoMessage() {} - -func (x *CloseRequest) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CloseRequest.ProtoReflect.Descriptor instead. +func (m *CloseRequest) Reset() { *m = CloseRequest{} } +func (m *CloseRequest) String() string { return proto.CompactTextString(m) } +func (*CloseRequest) ProtoMessage() {} func (*CloseRequest) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{2} + return fileDescriptor_c90a6c4a93f92bf4, []int{2} } -func (x *CloseRequest) GetId() int64 { - if x != nil { - return x.Id +func (m *CloseRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CloseRequest.Unmarshal(m, b) +} +func (m *CloseRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CloseRequest.Marshal(b, m, deterministic) +} +func (m *CloseRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CloseRequest.Merge(m, src) +} +func (m *CloseRequest) XXX_Size() int { + return xxx_messageInfo_CloseRequest.Size(m) +} +func (m *CloseRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CloseRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CloseRequest proto.InternalMessageInfo + +func (m *CloseRequest) GetId() int64 { + if m != nil { + return m.Id } return 0 } type CloseResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *CloseResponse) Reset() { - *x = CloseResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CloseResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CloseResponse) ProtoMessage() {} - -func (x *CloseResponse) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CloseResponse.ProtoReflect.Descriptor instead. +func (m *CloseResponse) Reset() { *m = CloseResponse{} } +func (m *CloseResponse) String() string { return proto.CompactTextString(m) } +func (*CloseResponse) ProtoMessage() {} func (*CloseResponse) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{3} + return fileDescriptor_c90a6c4a93f92bf4, []int{3} } +func (m *CloseResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CloseResponse.Unmarshal(m, b) +} +func (m *CloseResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CloseResponse.Marshal(b, m, deterministic) +} +func (m *CloseResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CloseResponse.Merge(m, src) +} +func (m *CloseResponse) XXX_Size() int { + return xxx_messageInfo_CloseResponse.Size(m) +} +func (m *CloseResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CloseResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CloseResponse proto.InternalMessageInfo + type StatRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` + Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *StatRequest) Reset() { - *x = StatRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StatRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StatRequest) ProtoMessage() {} - -func (x *StatRequest) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StatRequest.ProtoReflect.Descriptor instead. +func (m *StatRequest) Reset() { *m = StatRequest{} } +func (m *StatRequest) String() string { return proto.CompactTextString(m) } +func (*StatRequest) ProtoMessage() {} func (*StatRequest) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{4} + return fileDescriptor_c90a6c4a93f92bf4, []int{4} } -func (x *StatRequest) GetFilename() string { - if x != nil { - return x.Filename +func (m *StatRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StatRequest.Unmarshal(m, b) +} +func (m *StatRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StatRequest.Marshal(b, m, deterministic) +} +func (m *StatRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StatRequest.Merge(m, src) +} +func (m *StatRequest) XXX_Size() int { + return xxx_messageInfo_StatRequest.Size(m) +} +func (m *StatRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StatRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StatRequest proto.InternalMessageInfo + +func (m *StatRequest) GetFilename() string { + if m != nil { + return m.Filename } return "" } type StatResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` - LastModified int64 `protobuf:"varint,3,opt,name=last_modified,json=lastModified,proto3" json:"last_modified,omitempty"` + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` + LastModified int64 `protobuf:"varint,3,opt,name=last_modified,json=lastModified,proto3" json:"last_modified,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *StatResponse) Reset() { - *x = StatResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StatResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StatResponse) ProtoMessage() {} - -func (x *StatResponse) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StatResponse.ProtoReflect.Descriptor instead. +func (m *StatResponse) Reset() { *m = StatResponse{} } +func (m *StatResponse) String() string { return proto.CompactTextString(m) } +func (*StatResponse) ProtoMessage() {} func (*StatResponse) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{5} + return fileDescriptor_c90a6c4a93f92bf4, []int{5} } -func (x *StatResponse) GetType() string { - if x != nil { - return x.Type +func (m *StatResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StatResponse.Unmarshal(m, b) +} +func (m *StatResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StatResponse.Marshal(b, m, deterministic) +} +func (m *StatResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StatResponse.Merge(m, src) +} +func (m *StatResponse) XXX_Size() int { + return xxx_messageInfo_StatResponse.Size(m) +} +func (m *StatResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StatResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StatResponse proto.InternalMessageInfo + +func (m *StatResponse) GetType() string { + if m != nil { + return m.Type } return "" } -func (x *StatResponse) GetSize() int64 { - if x != nil { - return x.Size +func (m *StatResponse) GetSize() int64 { + if m != nil { + return m.Size } return 0 } -func (x *StatResponse) GetLastModified() int64 { - if x != nil { - return x.LastModified +func (m *StatResponse) GetLastModified() int64 { + if m != nil { + return m.LastModified } return 0 } type ReadRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - Size int64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + Size int64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *ReadRequest) Reset() { - *x = ReadRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadRequest) ProtoMessage() {} - -func (x *ReadRequest) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadRequest.ProtoReflect.Descriptor instead. +func (m *ReadRequest) Reset() { *m = ReadRequest{} } +func (m *ReadRequest) String() string { return proto.CompactTextString(m) } +func (*ReadRequest) ProtoMessage() {} func (*ReadRequest) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{6} + return fileDescriptor_c90a6c4a93f92bf4, []int{6} } -func (x *ReadRequest) GetId() int64 { - if x != nil { - return x.Id +func (m *ReadRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ReadRequest.Unmarshal(m, b) +} +func (m *ReadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ReadRequest.Marshal(b, m, deterministic) +} +func (m *ReadRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ReadRequest.Merge(m, src) +} +func (m *ReadRequest) XXX_Size() int { + return xxx_messageInfo_ReadRequest.Size(m) +} +func (m *ReadRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ReadRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ReadRequest proto.InternalMessageInfo + +func (m *ReadRequest) GetId() int64 { + if m != nil { + return m.Id } return 0 } -func (x *ReadRequest) GetOffset() int64 { - if x != nil { - return x.Offset +func (m *ReadRequest) GetOffset() int64 { + if m != nil { + return m.Offset } return 0 } -func (x *ReadRequest) GetSize() int64 { - if x != nil { - return x.Size +func (m *ReadRequest) GetSize() int64 { + if m != nil { + return m.Size } return 0 } type ReadResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Size int64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - Eof bool `protobuf:"varint,3,opt,name=eof,proto3" json:"eof,omitempty"` + Size int64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + Eof bool `protobuf:"varint,3,opt,name=eof,proto3" json:"eof,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *ReadResponse) Reset() { - *x = ReadResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadResponse) ProtoMessage() {} - -func (x *ReadResponse) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead. +func (m *ReadResponse) Reset() { *m = ReadResponse{} } +func (m *ReadResponse) String() string { return proto.CompactTextString(m) } +func (*ReadResponse) ProtoMessage() {} func (*ReadResponse) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{7} + return fileDescriptor_c90a6c4a93f92bf4, []int{7} } -func (x *ReadResponse) GetSize() int64 { - if x != nil { - return x.Size +func (m *ReadResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ReadResponse.Unmarshal(m, b) +} +func (m *ReadResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ReadResponse.Marshal(b, m, deterministic) +} +func (m *ReadResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ReadResponse.Merge(m, src) +} +func (m *ReadResponse) XXX_Size() int { + return xxx_messageInfo_ReadResponse.Size(m) +} +func (m *ReadResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ReadResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ReadResponse proto.InternalMessageInfo + +func (m *ReadResponse) GetSize() int64 { + if m != nil { + return m.Size } return 0 } -func (x *ReadResponse) GetData() []byte { - if x != nil { - return x.Data +func (m *ReadResponse) GetData() []byte { + if m != nil { + return m.Data } return nil } -func (x *ReadResponse) GetEof() bool { - if x != nil { - return x.Eof +func (m *ReadResponse) GetEof() bool { + if m != nil { + return m.Eof } return false } type GetRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - BlockId int64 `protobuf:"varint,2,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + BlockId int64 `protobuf:"varint,2,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *GetRequest) Reset() { - *x = GetRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetRequest) ProtoMessage() {} - -func (x *GetRequest) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetRequest.ProtoReflect.Descriptor instead. +func (m *GetRequest) Reset() { *m = GetRequest{} } +func (m *GetRequest) String() string { return proto.CompactTextString(m) } +func (*GetRequest) ProtoMessage() {} func (*GetRequest) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{8} + return fileDescriptor_c90a6c4a93f92bf4, []int{8} } -func (x *GetRequest) GetId() int64 { - if x != nil { - return x.Id +func (m *GetRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetRequest.Unmarshal(m, b) +} +func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetRequest.Marshal(b, m, deterministic) +} +func (m *GetRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetRequest.Merge(m, src) +} +func (m *GetRequest) XXX_Size() int { + return xxx_messageInfo_GetRequest.Size(m) +} +func (m *GetRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetRequest proto.InternalMessageInfo + +func (m *GetRequest) GetId() int64 { + if m != nil { + return m.Id } return 0 } -func (x *GetRequest) GetBlockId() int64 { - if x != nil { - return x.BlockId +func (m *GetRequest) GetBlockId() int64 { + if m != nil { + return m.BlockId } return 0 } type GetResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - BlockId int64 `protobuf:"varint,1,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` - Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + BlockId int64 `protobuf:"varint,1,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *GetResponse) Reset() { - *x = GetResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetResponse) ProtoMessage() {} - -func (x *GetResponse) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetResponse.ProtoReflect.Descriptor instead. +func (m *GetResponse) Reset() { *m = GetResponse{} } +func (m *GetResponse) String() string { return proto.CompactTextString(m) } +func (*GetResponse) ProtoMessage() {} func (*GetResponse) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{9} + return fileDescriptor_c90a6c4a93f92bf4, []int{9} } -func (x *GetResponse) GetBlockId() int64 { - if x != nil { - return x.BlockId +func (m *GetResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetResponse.Unmarshal(m, b) +} +func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetResponse.Marshal(b, m, deterministic) +} +func (m *GetResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetResponse.Merge(m, src) +} +func (m *GetResponse) XXX_Size() int { + return xxx_messageInfo_GetResponse.Size(m) +} +func (m *GetResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetResponse proto.InternalMessageInfo + +func (m *GetResponse) GetBlockId() int64 { + if m != nil { + return m.BlockId } return 0 } -func (x *GetResponse) GetSize() int64 { - if x != nil { - return x.Size +func (m *GetResponse) GetSize() int64 { + if m != nil { + return m.Size } return 0 } -func (x *GetResponse) GetData() []byte { - if x != nil { - return x.Data +func (m *GetResponse) GetData() []byte { + if m != nil { + return m.Data } return nil } type WriteRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *WriteRequest) Reset() { - *x = WriteRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WriteRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WriteRequest) ProtoMessage() {} - -func (x *WriteRequest) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WriteRequest.ProtoReflect.Descriptor instead. +func (m *WriteRequest) Reset() { *m = WriteRequest{} } +func (m *WriteRequest) String() string { return proto.CompactTextString(m) } +func (*WriteRequest) ProtoMessage() {} func (*WriteRequest) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{10} + return fileDescriptor_c90a6c4a93f92bf4, []int{10} } -func (x *WriteRequest) GetId() int64 { - if x != nil { - return x.Id +func (m *WriteRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WriteRequest.Unmarshal(m, b) +} +func (m *WriteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WriteRequest.Marshal(b, m, deterministic) +} +func (m *WriteRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_WriteRequest.Merge(m, src) +} +func (m *WriteRequest) XXX_Size() int { + return xxx_messageInfo_WriteRequest.Size(m) +} +func (m *WriteRequest) XXX_DiscardUnknown() { + xxx_messageInfo_WriteRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_WriteRequest proto.InternalMessageInfo + +func (m *WriteRequest) GetId() int64 { + if m != nil { + return m.Id } return 0 } -func (x *WriteRequest) GetOffset() int64 { - if x != nil { - return x.Offset +func (m *WriteRequest) GetOffset() int64 { + if m != nil { + return m.Offset } return 0 } -func (x *WriteRequest) GetData() []byte { - if x != nil { - return x.Data +func (m *WriteRequest) GetData() []byte { + if m != nil { + return m.Data } return nil } type WriteResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *WriteResponse) Reset() { - *x = WriteResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WriteResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WriteResponse) ProtoMessage() {} - -func (x *WriteResponse) ProtoReflect() protoreflect.Message { - mi := &file_micro_go_micro_util_file_proto_file_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WriteResponse.ProtoReflect.Descriptor instead. +func (m *WriteResponse) Reset() { *m = WriteResponse{} } +func (m *WriteResponse) String() string { return proto.CompactTextString(m) } +func (*WriteResponse) ProtoMessage() {} func (*WriteResponse) Descriptor() ([]byte, []int) { - return file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{11} + return fileDescriptor_c90a6c4a93f92bf4, []int{11} } -var File_micro_go_micro_util_file_proto_file_proto protoreflect.FileDescriptor - -var file_micro_go_micro_util_file_proto_file_proto_rawDesc = []byte{ - 0x0a, 0x29, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x6d, 0x69, 0x63, 0x72, 0x6f, - 0x2f, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x2e, - 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x45, 0x0a, 0x0b, - 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, - 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, - 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x72, 0x75, 0x6e, 0x63, - 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x72, 0x75, 0x6e, 0x63, - 0x61, 0x74, 0x65, 0x22, 0x36, 0x0a, 0x0c, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x1e, 0x0a, 0x0c, 0x43, - 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x0f, 0x0a, 0x0d, 0x43, - 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, - 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, - 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, - 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x5b, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, - 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, - 0x23, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x4d, 0x6f, 0x64, 0x69, - 0x66, 0x69, 0x65, 0x64, 0x22, 0x49, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, - 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, - 0x48, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, - 0x69, 0x7a, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x65, 0x6f, 0x66, 0x22, 0x37, 0x0a, 0x0a, 0x47, 0x65, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x49, 0x64, 0x22, 0x50, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x22, 0x4a, 0x0a, 0x0c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x22, 0x0f, 0x0a, 0x0d, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x32, 0xef, 0x02, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x04, 0x4f, 0x70, - 0x65, 0x6e, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x45, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, - 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, - 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, - 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, - 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x48, 0x0a, 0x05, 0x57, 0x72, 0x69, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, - 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, - 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x05, 0x43, 0x6c, 0x6f, - 0x73, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1e, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +func (m *WriteResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WriteResponse.Unmarshal(m, b) +} +func (m *WriteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WriteResponse.Marshal(b, m, deterministic) +} +func (m *WriteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_WriteResponse.Merge(m, src) +} +func (m *WriteResponse) XXX_Size() int { + return xxx_messageInfo_WriteResponse.Size(m) +} +func (m *WriteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_WriteResponse.DiscardUnknown(m) } -var ( - file_micro_go_micro_util_file_proto_file_proto_rawDescOnce sync.Once - file_micro_go_micro_util_file_proto_file_proto_rawDescData = file_micro_go_micro_util_file_proto_file_proto_rawDesc -) +var xxx_messageInfo_WriteResponse proto.InternalMessageInfo -func file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP() []byte { - file_micro_go_micro_util_file_proto_file_proto_rawDescOnce.Do(func() { - file_micro_go_micro_util_file_proto_file_proto_rawDescData = protoimpl.X.CompressGZIP(file_micro_go_micro_util_file_proto_file_proto_rawDescData) - }) - return file_micro_go_micro_util_file_proto_file_proto_rawDescData +func init() { + proto.RegisterType((*OpenRequest)(nil), "go.micro.server.OpenRequest") + proto.RegisterType((*OpenResponse)(nil), "go.micro.server.OpenResponse") + proto.RegisterType((*CloseRequest)(nil), "go.micro.server.CloseRequest") + proto.RegisterType((*CloseResponse)(nil), "go.micro.server.CloseResponse") + proto.RegisterType((*StatRequest)(nil), "go.micro.server.StatRequest") + proto.RegisterType((*StatResponse)(nil), "go.micro.server.StatResponse") + proto.RegisterType((*ReadRequest)(nil), "go.micro.server.ReadRequest") + proto.RegisterType((*ReadResponse)(nil), "go.micro.server.ReadResponse") + proto.RegisterType((*GetRequest)(nil), "go.micro.server.GetRequest") + proto.RegisterType((*GetResponse)(nil), "go.micro.server.GetResponse") + proto.RegisterType((*WriteRequest)(nil), "go.micro.server.WriteRequest") + proto.RegisterType((*WriteResponse)(nil), "go.micro.server.WriteResponse") } -var file_micro_go_micro_util_file_proto_file_proto_msgTypes = make([]protoimpl.MessageInfo, 12) -var file_micro_go_micro_util_file_proto_file_proto_goTypes = []interface{}{ - (*OpenRequest)(nil), // 0: go.micro.server.OpenRequest - (*OpenResponse)(nil), // 1: go.micro.server.OpenResponse - (*CloseRequest)(nil), // 2: go.micro.server.CloseRequest - (*CloseResponse)(nil), // 3: go.micro.server.CloseResponse - (*StatRequest)(nil), // 4: go.micro.server.StatRequest - (*StatResponse)(nil), // 5: go.micro.server.StatResponse - (*ReadRequest)(nil), // 6: go.micro.server.ReadRequest - (*ReadResponse)(nil), // 7: go.micro.server.ReadResponse - (*GetRequest)(nil), // 8: go.micro.server.GetRequest - (*GetResponse)(nil), // 9: go.micro.server.GetResponse - (*WriteRequest)(nil), // 10: go.micro.server.WriteRequest - (*WriteResponse)(nil), // 11: go.micro.server.WriteResponse -} -var file_micro_go_micro_util_file_proto_file_proto_depIdxs = []int32{ - 0, // 0: go.micro.server.File.Open:input_type -> go.micro.server.OpenRequest - 4, // 1: go.micro.server.File.Stat:input_type -> go.micro.server.StatRequest - 6, // 2: go.micro.server.File.Read:input_type -> go.micro.server.ReadRequest - 10, // 3: go.micro.server.File.Write:input_type -> go.micro.server.WriteRequest - 2, // 4: go.micro.server.File.Close:input_type -> go.micro.server.CloseRequest - 1, // 5: go.micro.server.File.Open:output_type -> go.micro.server.OpenResponse - 5, // 6: go.micro.server.File.Stat:output_type -> go.micro.server.StatResponse - 7, // 7: go.micro.server.File.Read:output_type -> go.micro.server.ReadResponse - 11, // 8: go.micro.server.File.Write:output_type -> go.micro.server.WriteResponse - 3, // 9: go.micro.server.File.Close:output_type -> go.micro.server.CloseResponse - 5, // [5:10] is the sub-list for method output_type - 0, // [0:5] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name +func init() { proto.RegisterFile("util/file/proto/file.proto", fileDescriptor_c90a6c4a93f92bf4) } + +var fileDescriptor_c90a6c4a93f92bf4 = []byte{ + // 447 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x8e, 0xd3, 0x30, + 0x10, 0xc6, 0x9b, 0x3f, 0x2c, 0x61, 0x92, 0x52, 0xe4, 0x03, 0x2a, 0x11, 0xac, 0x56, 0xe6, 0xb2, + 0x5c, 0xb2, 0x12, 0x48, 0xf0, 0x00, 0x68, 0x61, 0x17, 0x09, 0x81, 0xcc, 0x81, 0x03, 0x87, 0x55, + 0xb6, 0x9e, 0x20, 0x8b, 0x34, 0x0e, 0xb1, 0x83, 0x04, 0x2f, 0xcd, 0x2b, 0x20, 0x3b, 0x6e, 0xeb, + 0xb6, 0x89, 0x84, 0xf6, 0x36, 0xe3, 0x19, 0xff, 0xfc, 0xd9, 0xf9, 0x26, 0x90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 0x08, 0x7e, 0x74, 0x5c, 0x04, 0x00, 0x00, } -func init() { file_micro_go_micro_util_file_proto_file_proto_init() } -func file_micro_go_micro_util_file_proto_file_proto_init() { - if File_micro_go_micro_util_file_proto_file_proto != nil { - return +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// FileClient is the client API for File service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type FileClient interface { + Open(ctx context.Context, in *OpenRequest, opts ...grpc.CallOption) (*OpenResponse, error) + Stat(ctx context.Context, in *StatRequest, opts ...grpc.CallOption) (*StatResponse, error) + Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error) + Write(ctx context.Context, in *WriteRequest, opts ...grpc.CallOption) (*WriteResponse, error) + Close(ctx context.Context, in *CloseRequest, opts ...grpc.CallOption) (*CloseResponse, error) +} + +type fileClient struct { + cc *grpc.ClientConn +} + +func NewFileClient(cc *grpc.ClientConn) FileClient { + return &fileClient{cc} +} + +func (c *fileClient) Open(ctx context.Context, in *OpenRequest, opts ...grpc.CallOption) (*OpenResponse, error) { + out := new(OpenResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.File/Open", in, out, opts...) + if err != nil { + return nil, err } - if !protoimpl.UnsafeEnabled { - file_micro_go_micro_util_file_proto_file_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*OpenRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*OpenResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CloseRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CloseResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WriteRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_micro_go_micro_util_file_proto_file_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WriteResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } + return out, nil +} + +func (c *fileClient) Stat(ctx context.Context, in *StatRequest, opts ...grpc.CallOption) (*StatResponse, error) { + out := new(StatResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.File/Stat", in, out, opts...) + if err != nil { + return nil, err } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_micro_go_micro_util_file_proto_file_proto_rawDesc, - NumEnums: 0, - NumMessages: 12, - NumExtensions: 0, - NumServices: 1, + return out, nil +} + +func (c *fileClient) Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error) { + out := new(ReadResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.File/Read", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileClient) Write(ctx context.Context, in *WriteRequest, opts ...grpc.CallOption) (*WriteResponse, error) { + out := new(WriteResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.File/Write", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileClient) Close(ctx context.Context, in *CloseRequest, opts ...grpc.CallOption) (*CloseResponse, error) { + out := new(CloseResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.File/Close", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// FileServer is the server API for File service. +type FileServer interface { + Open(context.Context, *OpenRequest) (*OpenResponse, error) + Stat(context.Context, *StatRequest) (*StatResponse, error) + Read(context.Context, *ReadRequest) (*ReadResponse, error) + Write(context.Context, *WriteRequest) (*WriteResponse, error) + Close(context.Context, *CloseRequest) (*CloseResponse, error) +} + +// UnimplementedFileServer can be embedded to have forward compatible implementations. +type UnimplementedFileServer struct { +} + +func (*UnimplementedFileServer) Open(ctx context.Context, req *OpenRequest) (*OpenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Open not implemented") +} +func (*UnimplementedFileServer) Stat(ctx context.Context, req *StatRequest) (*StatResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Stat not implemented") +} +func (*UnimplementedFileServer) Read(ctx context.Context, req *ReadRequest) (*ReadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Read not implemented") +} +func (*UnimplementedFileServer) Write(ctx context.Context, req *WriteRequest) (*WriteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Write not implemented") +} +func (*UnimplementedFileServer) Close(ctx context.Context, req *CloseRequest) (*CloseResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Close not implemented") +} + +func RegisterFileServer(s *grpc.Server, srv FileServer) { + s.RegisterService(&_File_serviceDesc, srv) +} + +func _File_Open_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OpenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServer).Open(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.File/Open", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServer).Open(ctx, req.(*OpenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _File_Stat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServer).Stat(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.File/Stat", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServer).Stat(ctx, req.(*StatRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _File_Read_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServer).Read(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.File/Read", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServer).Read(ctx, req.(*ReadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _File_Write_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WriteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServer).Write(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.File/Write", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServer).Write(ctx, req.(*WriteRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _File_Close_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CloseRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServer).Close(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.File/Close", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServer).Close(ctx, req.(*CloseRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _File_serviceDesc = grpc.ServiceDesc{ + ServiceName: "go.micro.server.File", + HandlerType: (*FileServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Open", + Handler: _File_Open_Handler, }, - GoTypes: file_micro_go_micro_util_file_proto_file_proto_goTypes, - DependencyIndexes: file_micro_go_micro_util_file_proto_file_proto_depIdxs, - MessageInfos: file_micro_go_micro_util_file_proto_file_proto_msgTypes, - }.Build() - File_micro_go_micro_util_file_proto_file_proto = out.File - file_micro_go_micro_util_file_proto_file_proto_rawDesc = nil - file_micro_go_micro_util_file_proto_file_proto_goTypes = nil - file_micro_go_micro_util_file_proto_file_proto_depIdxs = nil + { + MethodName: "Stat", + Handler: _File_Stat_Handler, + }, + { + MethodName: "Read", + Handler: _File_Read_Handler, + }, + { + MethodName: "Write", + Handler: _File_Write_Handler, + }, + { + MethodName: "Close", + Handler: _File_Close_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "util/file/proto/file.proto", } diff --git a/util/file/proto/file.pb.micro.go b/util/file/proto/file.pb.micro.go index fc4e6928..ac135745 100644 --- a/util/file/proto/file.pb.micro.go +++ b/util/file/proto/file.pb.micro.go @@ -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 diff --git a/util/mux/mux.go b/util/mux/mux.go index 0f03298f..7ad7731f 100644 --- a/util/mux/mux.go +++ b/util/mux/mux.go @@ -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), ), ) diff --git a/util/wrapper/wrapper.go b/util/wrapper/wrapper.go index d5ff9e83..d261940d 100644 --- a/util/wrapper/wrapper.go +++ b/util/wrapper/wrapper.go @@ -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} } From 95703e456527c43e5f997d360194c64e3b91fad3 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Sun, 24 May 2020 20:26:37 +0100 Subject: [PATCH 5/6] Fixes and improved test coverage --- auth/service/service.go | 38 +++++++-------------------- util/wrapper/wrapper.go | 15 ++++++++--- util/wrapper/wrapper_test.go | 51 ++++++++++++++++++++++++++++-------- 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/auth/service/service.go b/auth/service/service.go index fb5cb755..eacc2596 100644 --- a/auth/service/service.go +++ b/auth/service/service.go @@ -5,7 +5,6 @@ import ( "fmt" "sort" "strings" - "sync" "time" "github.com/micro/go-micro/v2/auth" @@ -23,9 +22,6 @@ type svc struct { auth pb.AuthService rule pb.RulesService jwt token.Provider - - rules []*pb.Rule - sync.Mutex } func (s *svc) String() string { @@ -53,8 +49,6 @@ func (s *svc) Init(opts ...auth.Option) { } func (s *svc) Options() auth.Options { - s.Lock() - defer s.Unlock() return s.options } @@ -110,9 +104,6 @@ func (s *svc) Revoke(role string, res *auth.Resource) error { // Verify an account has access to a resource func (s *svc) Verify(acc *auth.Account, res *auth.Resource) error { - // load the rules if none are loaded - s.loadRulesIfEmpty() - // set the namespace on the resource if len(res.Namespace) == 0 { res.Namespace = s.Options().Namespace @@ -230,11 +221,14 @@ func accessForRule(rule *pb.Rule, acc *auth.Account, res *auth.Resource) pb.Acce // listRules gets all the rules from the store which match the filters. // filters are namespace, type, name and then endpoint. func (s *svc) listRules(filters ...string) []*pb.Rule { - s.Lock() - defer s.Unlock() + // load rules using the client cache + allRules, err := s.loadRules() + if err != nil { + return []*pb.Rule{} + } var rules []*pb.Rule - for _, r := range s.rules { + for _, r := range allRules { if len(filters) > 0 && r.Resource.Namespace != filters[0] { continue } @@ -260,27 +254,15 @@ func (s *svc) listRules(filters ...string) []*pb.Rule { } // loadRules retrieves the rules from the auth service -func (s *svc) loadRules() { +func (s *svc) loadRules() ([]*pb.Rule, error) { rsp, err := s.rule.List(context.TODO(), &pb.ListRequest{}, client.WithCache(time.Minute)) - s.Lock() - defer s.Unlock() if err != nil { - log.Errorf("Error listing rules: %v", err) - return + log.Debugf("Error listing rules: %v", err) + return nil, err } - s.rules = rsp.Rules -} - -func (s *svc) loadRulesIfEmpty() { - s.Lock() - rules := s.rules - s.Unlock() - - if len(rules) == 0 { - s.loadRules() - } + return rsp.Rules, nil } func serializeToken(t *pb.Token) *auth.Token { diff --git a/util/wrapper/wrapper.go b/util/wrapper/wrapper.go index d261940d..ba40d7fd 100644 --- a/util/wrapper/wrapper.go +++ b/util/wrapper/wrapper.go @@ -2,6 +2,7 @@ package wrapper import ( "context" + "reflect" "strings" "time" @@ -229,7 +230,7 @@ func AuthHandler(fn func() auth.Auth) server.HandlerWrapper { } type cacheWrapper struct { - cache func() *client.Cache + cacheFn func() *client.Cache client.Client } @@ -243,7 +244,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.cache() + cache := c.cacheFn() if cache == nil { return c.Client.Call(ctx, req, rsp, opts...) } @@ -253,9 +254,15 @@ func (c *cacheWrapper) Call(ctx context.Context, req client.Request, rsp interfa return c.Client.Call(ctx, req, rsp, opts...) } - // check to see if there is a response + // if the response is nil don't call the cache since we can't assign the response + if rsp == nil { + return c.Client.Call(ctx, req, rsp, opts...) + } + + // check to see if there is a response cached, if there is assign it if r, ok := cache.Get(ctx, &req); ok { - rsp = r + val := reflect.ValueOf(rsp).Elem() + val.Set(reflect.ValueOf(r).Elem()) return nil } diff --git a/util/wrapper/wrapper_test.go b/util/wrapper/wrapper_test.go index c3454779..d9760fba 100644 --- a/util/wrapper/wrapper_test.go +++ b/util/wrapper/wrapper_test.go @@ -2,6 +2,7 @@ package wrapper import ( "context" + "reflect" "testing" "time" @@ -56,25 +57,33 @@ func TestWrapper(t *testing.T) { type testClient struct { callCount int callRsp interface{} - cache *client.Cache client.Client } func (c *testClient) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error { c.callCount++ - rsp = c.callRsp + + if c.callRsp != nil { + val := reflect.ValueOf(rsp).Elem() + val.Set(reflect.ValueOf(c.callRsp).Elem()) + } + return nil } -func (c *testClient) Options() client.Options { - return client.Options{Cache: c.cache} +type testRsp struct { + value string } + func TestCacheWrapper(t *testing.T) { req := client.NewRequest("go.micro.service.foo", "Foo.Bar", nil) t.Run("NilCache", func(t *testing.T) { cli := new(testClient) - w := CacheClient(cli) + + w := CacheClient(func() *client.Cache { + return nil + }, cli) // perfroming two requests should increment the call count by two indicating the cache wasn't // used even though the WithCache option was passed. @@ -88,7 +97,11 @@ func TestCacheWrapper(t *testing.T) { t.Run("OptionNotSet", func(t *testing.T) { cli := new(testClient) - w := CacheClient(cli) + cache := client.NewCache() + + w := CacheClient(func() *client.Cache { + return cache + }, cli) // perfroming two requests should increment the call count by two since we didn't pass the WithCache // option to Call. @@ -101,13 +114,21 @@ func TestCacheWrapper(t *testing.T) { }) t.Run("OptionSet", func(t *testing.T) { - cli := &testClient{callRsp: "foobar", cache: client.NewCache()} - w := CacheClient(cli) + val := "foo" + cli := &testClient{callRsp: &testRsp{value: val}} + cache := client.NewCache() + + w := CacheClient(func() *client.Cache { + return cache + }, cli) // perfroming two requests should increment the call count by once since the second request should - // have used the cache - err1 := w.Call(context.TODO(), req, nil, client.WithCache(time.Minute)) - err2 := w.Call(context.TODO(), req, nil, client.WithCache(time.Minute)) + // have used the cache. The correct value should be set on both responses and no errors should + // be returned. + rsp1 := &testRsp{} + rsp2 := &testRsp{} + err1 := w.Call(context.TODO(), req, rsp1, client.WithCache(time.Minute)) + err2 := w.Call(context.TODO(), req, rsp2, client.WithCache(time.Minute)) if err1 != nil { t.Errorf("Expected nil error, got %v", err1) @@ -115,6 +136,14 @@ func TestCacheWrapper(t *testing.T) { if err2 != nil { t.Errorf("Expected nil error, got %v", err2) } + + if rsp1.value != val { + t.Errorf("Expected %v to be assigned to the value, got %v", val, rsp1.value) + } + if rsp2.value != val { + t.Errorf("Expected %v to be assigned to the value, got %v", val, rsp2.value) + } + if cli.callCount != 1 { t.Errorf("Expected the client to be called 1 time, was actually called %v time(s)", cli.callCount) } From 198e9428892352324b4ab4be3d85629bcae64a61 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Sun, 24 May 2020 20:32:22 +0100 Subject: [PATCH 6/6] Remove redundant test --- auth/service/sevice_test.go | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 auth/service/sevice_test.go diff --git a/auth/service/sevice_test.go b/auth/service/sevice_test.go deleted file mode 100644 index 1c206ee3..00000000 --- a/auth/service/sevice_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package service - -import ( - "testing" - - pb "github.com/micro/go-micro/v2/auth/service/proto" -) - -func TestListRulesSorting(t *testing.T) { - s := &svc{ - rules: []*pb.Rule{ - &pb.Rule{Priority: 1}, - &pb.Rule{Priority: 3}, - &pb.Rule{Priority: 2}, - }, - } - - var priorities []int32 - for _, r := range s.listRules() { - priorities = append(priorities, r.Priority) - } - - if priorities[0] != 1 || priorities[1] != 2 || priorities[2] != 3 { - t.Errorf("Incorrect Rule Sequence") - } -}