expose codec options

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-11-25 10:43:13 +03:00
parent 458388359a
commit 3f6852030f

View File

@ -22,6 +22,10 @@ var (
ErrUnknownContentType = errors.New("unknown content-type")
)
var (
DefaultMaxMessageSize = 1024 * 1024 * 4 // 4Mb
)
// MessageType
type MessageType int
@ -55,6 +59,18 @@ type Message struct {
Body []byte
}
type Option func(*Options)
type Options struct {
MaxMessageSize int64
}
func MaxMessageSize(n int64) Option {
return func(o *Options) {
o.MaxMessageSize = n
}
}
func NewMessage(t MessageType) *Message {
return &Message{Type: t, Header: metadata.New(0)}
}