diff --git a/codec/codec.go b/codec/codec.go index 74b07e6c..fa5c98e9 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -23,7 +23,7 @@ var ( ) var ( - DefaultMaxMessageSize = 1024 * 1024 * 4 // 4Mb + DefaultMaxMsgSize = 1024 * 1024 * 4 // 4Mb ) // MessageType @@ -62,12 +62,12 @@ type Message struct { type Option func(*Options) type Options struct { - MaxMessageSize int64 + MaxMsgSize int64 } -func MaxMessageSize(n int64) Option { +func MaxMsgSize(n int64) Option { return func(o *Options) { - o.MaxMessageSize = n + o.MaxMsgSize = n } } diff --git a/server/options.go b/server/options.go index aa91f956..fb4a31e1 100644 --- a/server/options.go +++ b/server/options.go @@ -16,6 +16,8 @@ import ( "github.com/unistack-org/micro/v3/tracer" ) +type Option func(*Options) + // Options server struct type Options struct { Codecs map[string]codec.Codec diff --git a/server/server.go b/server/server.go index 5fb1a3b3..9badf18e 100644 --- a/server/server.go +++ b/server/server.go @@ -15,6 +15,20 @@ var ( DefaultServer Server = NewServer() ) +var ( + DefaultAddress = ":0" + DefaultName = "server" + DefaultVersion = "latest" + DefaultId = uuid.New().String() + DefaultRegisterCheck = func(context.Context) error { return nil } + DefaultRegisterInterval = time.Second * 30 + DefaultRegisterTTL = time.Second * 90 + DefaultNamespace = "micro" + DefaultMaxMsgSize = 1024 * 1024 * 4 // 4Mb + DefaultMaxMsgRecvSize = 1024 * 1024 * 4 // 4Mb + DefaultMaxMsgSendSize = 1024 * 1024 * 4 // 4Mb +) + // Server is a simple micro server abstraction type Server interface { // Initialise options @@ -134,16 +148,3 @@ type Subscriber interface { Endpoints() []*registry.Endpoint Options() SubscriberOptions } - -type Option func(*Options) - -var ( - DefaultAddress = ":0" - DefaultName = "server" - DefaultVersion = "latest" - DefaultId = uuid.New().String() - DefaultRegisterCheck = func(context.Context) error { return nil } - DefaultRegisterInterval = time.Second * 30 - DefaultRegisterTTL = time.Second * 90 - DefaultNamespace = "micro" -)