merge changes from master #65

Merged
vtolstov merged 3 commits from master into v3 2021-11-24 00:59:00 +03:00
4 changed files with 20 additions and 8 deletions

View File

@ -5,29 +5,40 @@ type Frame struct {
Data []byte Data []byte
} }
// NewFrame returns new frame with data
func NewFrame(data []byte) *Frame {
return &Frame{Data: data}
}
// MarshalJSON returns frame data
func (m *Frame) MarshalJSON() ([]byte, error) { func (m *Frame) MarshalJSON() ([]byte, error) {
return m.Data, nil return m.Marshal()
} }
// UnmarshalJSON set frame data
func (m *Frame) UnmarshalJSON(data []byte) error { func (m *Frame) UnmarshalJSON(data []byte) error {
m.Data = data return m.Unmarshal(data)
return nil
} }
// ProtoMessage noop func
func (m *Frame) ProtoMessage() {} func (m *Frame) ProtoMessage() {}
// Reset resets frame
func (m *Frame) Reset() { func (m *Frame) Reset() {
*m = Frame{} *m = Frame{}
} }
// String returns frame as string
func (m *Frame) String() string { func (m *Frame) String() string {
return string(m.Data) return string(m.Data)
} }
// Marshal returns frame data
func (m *Frame) Marshal() ([]byte, error) { func (m *Frame) Marshal() ([]byte, error) {
return m.Data, nil return m.Data, nil
} }
// Unmarshal set frame data
func (m *Frame) Unmarshal(data []byte) error { func (m *Frame) Unmarshal(data []byte) error {
m.Data = data m.Data = data
return nil return nil

View File

@ -16,6 +16,7 @@ import (
"go.unistack.org/micro/v3/network/transport" "go.unistack.org/micro/v3/network/transport"
"go.unistack.org/micro/v3/register" "go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/tracer" "go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v3/util/id"
) )
// Option func // Option func
@ -106,7 +107,7 @@ func NewOptions(opts ...Option) Options {
Address: DefaultAddress, Address: DefaultAddress,
Name: DefaultName, Name: DefaultName,
Version: DefaultVersion, Version: DefaultVersion,
ID: DefaultID, ID: id.Must(),
Namespace: DefaultNamespace, Namespace: DefaultNamespace,
} }

View File

@ -8,7 +8,6 @@ import (
"go.unistack.org/micro/v3/codec" "go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata" "go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/register" "go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/util/id"
) )
// DefaultServer default server // DefaultServer default server
@ -21,8 +20,6 @@ var (
DefaultName = "server" DefaultName = "server"
// DefaultVersion will be used if no version passed // DefaultVersion will be used if no version passed
DefaultVersion = "latest" DefaultVersion = "latest"
// DefaultID will be used if no id passed
DefaultID = id.Must()
// DefaultRegisterCheck holds func that run before register server // DefaultRegisterCheck holds func that run before register server
DefaultRegisterCheck = func(context.Context) error { return nil } DefaultRegisterCheck = func(context.Context) error { return nil }
// DefaultRegisterInterval holds interval for register // DefaultRegisterInterval holds interval for register

View File

@ -91,7 +91,10 @@ func Merge(dst interface{}, mp map[string]interface{}, opts ...Option) error {
val, ok := mp[fname] val, ok := mp[fname]
if !ok { if !ok {
continue val, ok = mp[dfld.Name]
if !ok {
continue
}
} }
sval = reflect.ValueOf(val) sval = reflect.ValueOf(val)