From 87b19504d73175117e295fb5b7bfd2c5d2df2c18 Mon Sep 17 00:00:00 2001 From: Damian Debkowski Date: Thu, 7 Dec 2023 10:29:18 -0800 Subject: [PATCH] feat(storage): remove withMinimumBuffer --- internal/storage/options.go | 18 ++++++------------ internal/storage/options_test.go | 10 ---------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/internal/storage/options.go b/internal/storage/options.go index ce40a009da..28b7d82ef1 100644 --- a/internal/storage/options.go +++ b/internal/storage/options.go @@ -53,7 +53,6 @@ func getDefaultOptions() Options { WithFileAccessMode: ReadOnly, WithCreateFile: false, WithBuffer: 0, - WithMinimumBuffer: 0, } } @@ -63,7 +62,6 @@ type Options struct { WithFileAccessMode AccessMode WithCreateFile bool WithBuffer uint64 - WithMinimumBuffer uint64 } // Option is a storage option. @@ -90,18 +88,14 @@ func WithFileAccessMode(m AccessMode) Option { } } -// WithBuffer sets the buffer size. -// The value must be a factorial of 4KiB. +// WithBuffer sets the buffer size. If the buffer size is not +// a factorial of 4KiB, the input will be used as a minimum +// buffer threshold used to determine the minimum number of +// emtpy bytes allowed in the buffer before having the buffer +// expand. In this case, the buffer size will be rounded up +// to the nearest 4KiB factorial. func WithBuffer(b uint64) Option { return func(o *Options) { o.WithBuffer = b } } - -// WithMinimumBuffer sets the threshold to enforce when the -// buffer expands back to its original size. -func WithMinimumBuffer(m uint64) Option { - return func(o *Options) { - o.WithMinimumBuffer = m - } -} diff --git a/internal/storage/options_test.go b/internal/storage/options_test.go index c5c12a6b5e..a2f8dad414 100644 --- a/internal/storage/options_test.go +++ b/internal/storage/options_test.go @@ -69,14 +69,4 @@ func Test_getOpts(t *testing.T) { testOpts.WithBuffer = 4096 assert.Equal(opts, testOpts) }) - t.Run("WithMinimumBuffer", func(t *testing.T) { - testOpts := getDefaultOptions() - opts := GetOpts(WithMinimumBuffer(0)) - assert.Equal(testOpts, opts) - - testOpts = getDefaultOptions() - opts = GetOpts(WithMinimumBuffer(88)) - testOpts.WithMinimumBuffer = 88 - assert.Equal(opts, testOpts) - }) }