From cfc770c3fe8903968eecd7ff6dc2983e13f4ef58 Mon Sep 17 00:00:00 2001
From: Leonard Lyubich <leonard@nspcc.ru>
Date: Thu, 26 Nov 2020 10:40:50 +0300
Subject: [PATCH] [#211] blobstor: Add SmallSizeLimit parameter

Add numeric parameter of maximum size of the "small" objects.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
---
 pkg/local_object_storage/blobstor/blobstor.go | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/pkg/local_object_storage/blobstor/blobstor.go b/pkg/local_object_storage/blobstor/blobstor.go
index 1275037d7..e4b9d5c47 100644
--- a/pkg/local_object_storage/blobstor/blobstor.go
+++ b/pkg/local_object_storage/blobstor/blobstor.go
@@ -22,6 +22,8 @@ type cfg struct {
 	compressor func([]byte) []byte
 
 	decompressor func([]byte) ([]byte, error)
+
+	smallSizeLimit uint64
 }
 
 const (
@@ -39,8 +41,9 @@ func defaultCfg() *cfg {
 				RootPath:    "./",
 			},
 		},
-		compressor:   noOpCompressor,
-		decompressor: noOpDecompressor,
+		compressor:     noOpCompressor,
+		decompressor:   noOpDecompressor,
+		smallSizeLimit: 1 << 20,
 	}
 }
 
@@ -117,3 +120,11 @@ func WithTreeRootPerm(perm os.FileMode) Option {
 		c.fsTree.Permissions = perm
 	}
 }
+
+// WithSmallSizeLimit returns option to set maximum size of
+// "small" object.
+func WithSmallSizeLimit(lim uint64) Option {
+	return func(c *cfg) {
+		c.smallSizeLimit = lim
+	}
+}