add some defaults
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		| @@ -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 | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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" | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user