From 3f6852030fef6cd8f2fb24797d703d5847b7d577 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 25 Nov 2020 10:43:13 +0300 Subject: [PATCH] expose codec options Signed-off-by: Vasiliy Tolstov --- codec/codec.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/codec/codec.go b/codec/codec.go index ac1cec89..74b07e6c 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -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)} }