update to latest micro
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
d7ffcd19f8
commit
89b41364c3
8
file.go
8
file.go
@ -8,13 +8,15 @@ import (
|
||||
"regexp"
|
||||
|
||||
"dario.cat/mergo"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/config"
|
||||
rutil "go.unistack.org/micro/v3/util/reflect"
|
||||
"golang.org/x/text/transform"
|
||||
)
|
||||
|
||||
var DefaultStructTag = "file"
|
||||
var (
|
||||
DefaultStructTag = "file"
|
||||
MaxFileSize int64 = 1 * 1024 * 1024
|
||||
)
|
||||
|
||||
type fileConfig struct {
|
||||
opts config.Options
|
||||
@ -129,7 +131,7 @@ func (c *fileConfig) Load(ctx context.Context, opts ...config.LoadOption) error
|
||||
r = fp
|
||||
}
|
||||
|
||||
buf, err := io.ReadAll(io.LimitReader(r, int64(codec.DefaultMaxMsgSize)))
|
||||
buf, err := io.ReadAll(io.LimitReader(r, MaxFileSize))
|
||||
if err != nil {
|
||||
if !c.opts.AllowFail {
|
||||
return err
|
||||
|
13
file_test.go
13
file_test.go
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@ -22,22 +21,10 @@ func (*jsoncodec) Unmarshal(buf []byte, v interface{}, opts ...codec.Option) err
|
||||
return json.Unmarshal(buf, v)
|
||||
}
|
||||
|
||||
func (*jsoncodec) ReadBody(r io.Reader, v interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*jsoncodec) ReadHeader(r io.Reader, m *codec.Message, t codec.MessageType) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*jsoncodec) String() string {
|
||||
return "json"
|
||||
}
|
||||
|
||||
func (*jsoncodec) Write(w io.Writer, m *codec.Message, v interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestLoadReplace(t *testing.T) {
|
||||
type Config struct {
|
||||
Key string
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"os"
|
||||
"reflect"
|
||||
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/config"
|
||||
"go.unistack.org/micro/v3/util/jitter"
|
||||
rutil "go.unistack.org/micro/v3/util/reflect"
|
||||
@ -44,7 +43,7 @@ func (w *fileWatcher) run() {
|
||||
return
|
||||
}
|
||||
var buf []byte
|
||||
buf, err = ioutil.ReadAll(io.LimitReader(fp, int64(codec.DefaultMaxMsgSize)))
|
||||
buf, err = ioutil.ReadAll(io.LimitReader(fp, MaxFileSize))
|
||||
if err == nil {
|
||||
err = w.opts.Codec.Unmarshal(buf, dst)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user