many lint fixes and optimizations (#17)
* util/kubernetes: drop stale files * debug/log/kubernetes: drop stale files * util/scope: remove stale files * util/mdns: drop stale files * lint fixes Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/unistack-org/micro/v3/metadata"
|
||||
)
|
||||
|
||||
// Message types
|
||||
const (
|
||||
// Message types
|
||||
Error MessageType = iota
|
||||
Request
|
||||
Response
|
||||
@@ -25,8 +25,9 @@ var (
|
||||
|
||||
var (
|
||||
// DefaultMaxMsgSize specifies how much data codec can handle
|
||||
DefaultMaxMsgSize int = 1024 * 1024 * 4 // 4Mb
|
||||
DefaultCodec Codec = NewCodec()
|
||||
DefaultMaxMsgSize int = 1024 * 1024 * 4 // 4Mb
|
||||
// DefaultCodec is the global default codec
|
||||
DefaultCodec Codec = NewCodec()
|
||||
)
|
||||
|
||||
// MessageType
|
||||
|
@@ -30,12 +30,8 @@ func (c *noopCodec) ReadBody(conn io.Reader, b interface{}) error {
|
||||
}
|
||||
|
||||
switch v := b.(type) {
|
||||
case string:
|
||||
v = string(buf)
|
||||
case *string:
|
||||
*v = string(buf)
|
||||
case []byte:
|
||||
v = buf
|
||||
case *[]byte:
|
||||
*v = buf
|
||||
case *Frame:
|
||||
@@ -112,15 +108,9 @@ func (c *noopCodec) Unmarshal(d []byte, v interface{}) error {
|
||||
return nil
|
||||
}
|
||||
switch ve := v.(type) {
|
||||
case string:
|
||||
ve = string(d)
|
||||
return nil
|
||||
case *string:
|
||||
*ve = string(d)
|
||||
return nil
|
||||
case []byte:
|
||||
ve = d
|
||||
return nil
|
||||
case *[]byte:
|
||||
*ve = d
|
||||
return nil
|
||||
|
34
codec/noop_test.go
Normal file
34
codec/noop_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package codec
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNoopBytes(t *testing.T) {
|
||||
req := []byte("test req")
|
||||
rsp := make([]byte, len(req))
|
||||
|
||||
nc := NewCodec()
|
||||
if err := nc.Unmarshal(req, &rsp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(req, rsp) {
|
||||
t.Fatalf("req not eq rsp: %s != %s", req, rsp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoopString(t *testing.T) {
|
||||
req := []byte("test req")
|
||||
var rsp string
|
||||
|
||||
nc := NewCodec()
|
||||
if err := nc.Unmarshal(req, &rsp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(req, []byte(rsp)) {
|
||||
t.Fatalf("req not eq rsp: %s != %s", req, rsp)
|
||||
}
|
||||
}
|
@@ -45,6 +45,7 @@ func Meter(m meter.Meter) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// NewOptions returns new options
|
||||
func NewOptions(opts ...Option) Options {
|
||||
options := Options{
|
||||
Logger: logger.DefaultLogger,
|
||||
|
Reference in New Issue
Block a user