add some defaults

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-11-26 01:13:05 +03:00
parent 3f6852030f
commit 0d93b2c31c
3 changed files with 20 additions and 17 deletions

View File

@ -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
}
}

View File

@ -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

View File

@ -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"
)