summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/codeberg.org/gruf')
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/atomic.tpl57
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/atomic_test.tpl60
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/bool.go47
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/bytes.go57
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/error.go57
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/flags.go97
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/int.go69
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/interface.go57
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/state.go58
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/string.go57
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/time.go58
-rw-r--r--vendor/codeberg.org/gruf/go-atomics/uint.go69
-rw-r--r--vendor/codeberg.org/gruf/go-bitutil/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-bitutil/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-bitutil/flag.go3084
-rw-r--r--vendor/codeberg.org/gruf/go-bitutil/flag.tpl94
-rw-r--r--vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl98
-rw-r--r--vendor/codeberg.org/gruf/go-bitutil/pack.go85
-rw-r--r--vendor/codeberg.org/gruf/go-bitutil/test.tpl60
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/README.md12
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/buffer.go131
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/bytes.go261
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/bytesconv_table.go11
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/bytesize.go306
-rw-r--r--vendor/codeberg.org/gruf/go-byteutil/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-byteutil/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-byteutil/buffer.go134
-rw-r--r--vendor/codeberg.org/gruf/go-byteutil/bytes.go84
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v2/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v2/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v2/cache.go67
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v2/compare.go23
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v2/hook.go6
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v2/lookup.go210
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v2/scheduler.go17
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v2/ttl.go310
-rw-r--r--vendor/codeberg.org/gruf/go-debug/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-debug/README.md37
-rw-r--r--vendor/codeberg.org/gruf/go-debug/debug.go58
-rw-r--r--vendor/codeberg.org/gruf/go-debug/debug_env.go9
-rw-r--r--vendor/codeberg.org/gruf/go-debug/debug_off.go7
-rw-r--r--vendor/codeberg.org/gruf/go-debug/debug_on.go7
-rw-r--r--vendor/codeberg.org/gruf/go-debug/pprof_off.go16
-rw-r--r--vendor/codeberg.org/gruf/go-debug/pprof_on.go63
-rw-r--r--vendor/codeberg.org/gruf/go-debug/run_tests.sh17
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/README.md5
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/callers.go102
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/error.go35
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/error_notrace.go33
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/errors.go36
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/once.go47
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/standard.go106
-rw-r--r--vendor/codeberg.org/gruf/go-fastcopy/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-fastcopy/copy.go134
-rw-r--r--vendor/codeberg.org/gruf/go-fastpath/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-fastpath/README.md1
-rw-r--r--vendor/codeberg.org/gruf/go-fastpath/benchmarks.pngbin108279 -> 0 bytes
-rw-r--r--vendor/codeberg.org/gruf/go-fastpath/path.go319
-rw-r--r--vendor/codeberg.org/gruf/go-hashenc/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-hashenc/README.md1
-rw-r--r--vendor/codeberg.org/gruf/go-hashenc/enc.go42
-rw-r--r--vendor/codeberg.org/gruf/go-hashenc/hashenc.go58
-rw-r--r--vendor/codeberg.org/gruf/go-kv/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-kv/README.md9
-rw-r--r--vendor/codeberg.org/gruf/go-kv/benchmark.pngbin97592 -> 0 bytes
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field.go105
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field_fmt.go36
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field_format.go35
-rw-r--r--vendor/codeberg.org/gruf/go-kv/format/README.md5
-rw-r--r--vendor/codeberg.org/gruf/go-kv/format/benchmark.pngbin36505 -> 0 bytes
-rw-r--r--vendor/codeberg.org/gruf/go-kv/format/format.go922
-rw-r--r--vendor/codeberg.org/gruf/go-kv/format/formatter.go349
-rw-r--r--vendor/codeberg.org/gruf/go-kv/format/util.go56
-rw-r--r--vendor/codeberg.org/gruf/go-kv/util.go71
-rw-r--r--vendor/codeberg.org/gruf/go-logger/v2/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-logger/v2/level/levels.go49
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/README.md1
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/debug.go39
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/map.go466
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/mutex.go105
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/mutex_safe.go50
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go137
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/pool.go40
-rw-r--r--vendor/codeberg.org/gruf/go-pools/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-pools/README.md2
-rw-r--r--vendor/codeberg.org/gruf/go-pools/bufio.go89
-rw-r--r--vendor/codeberg.org/gruf/go-pools/bytes.go46
-rw-r--r--vendor/codeberg.org/gruf/go-pools/fastpath.go46
-rw-r--r--vendor/codeberg.org/gruf/go-pools/henc.go46
-rw-r--r--vendor/codeberg.org/gruf/go-pools/pool.go387
-rw-r--r--vendor/codeberg.org/gruf/go-runners/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-runners/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-runners/context.go43
-rw-r--r--vendor/codeberg.org/gruf/go-runners/pool.go174
-rw-r--r--vendor/codeberg.org/gruf/go-runners/run.go124
-rw-r--r--vendor/codeberg.org/gruf/go-runners/service.go159
-rw-r--r--vendor/codeberg.org/gruf/go-sched/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-sched/README.md5
-rw-r--r--vendor/codeberg.org/gruf/go-sched/job.go118
-rw-r--r--vendor/codeberg.org/gruf/go-sched/scheduler.go250
-rw-r--r--vendor/codeberg.org/gruf/go-sched/timing.go92
-rw-r--r--vendor/codeberg.org/gruf/go-store/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-store/kv/iterator.go63
-rw-r--r--vendor/codeberg.org/gruf/go-store/kv/state.go130
-rw-r--r--vendor/codeberg.org/gruf/go-store/kv/store.go227
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/block.go895
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/compressor.go104
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/disk.go400
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/errors.go90
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/fs.go65
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/lock.go76
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/memory.go188
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/storage.go54
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/transform.go25
-rw-r--r--vendor/codeberg.org/gruf/go-store/util/fs.go82
-rw-r--r--vendor/codeberg.org/gruf/go-store/util/io.go42
-rw-r--r--vendor/codeberg.org/gruf/go-store/util/pool.go20
-rw-r--r--vendor/codeberg.org/gruf/go-store/util/sys.go14
125 files changed, 0 insertions, 13574 deletions
diff --git a/vendor/codeberg.org/gruf/go-atomics/LICENSE b/vendor/codeberg.org/gruf/go-atomics/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-atomics/README.md b/vendor/codeberg.org/gruf/go-atomics/README.md
deleted file mode 100644
index 38ba53276..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-atomics
-
-This library provides a variety of types for atomic operations on common Go types. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-atomics/atomic.tpl b/vendor/codeberg.org/gruf/go-atomics/atomic.tpl
deleted file mode 100644
index 00134c1e8..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/atomic.tpl
+++ /dev/null
@@ -1,57 +0,0 @@
-package atomics
-
-import (
- "sync/atomic"
- "unsafe"
-)
-
-// {{ .Name }} provides user-friendly means of performing atomic operations on {{ .Type }} types.
-type {{ .Name }} struct{ ptr unsafe.Pointer }
-
-// New{{ .Name }} will return a new {{ .Name }} instance initialized with zero value.
-func New{{ .Name }}() *{{ .Name }} {
- var v {{ .Type }}
- return &{{ .Name }}{
- ptr: unsafe.Pointer(&v),
- }
-}
-
-// Store will atomically store {{ .Type }} value in address contained within v.
-func (v *{{ .Name }}) Store(val {{ .Type }}) {
- atomic.StorePointer(&v.ptr, unsafe.Pointer(&val))
-}
-
-// Load will atomically load {{ .Type }} value at address contained within v.
-func (v *{{ .Name }}) Load() {{ .Type }} {
- return *(*{{ .Type }})(atomic.LoadPointer(&v.ptr))
-}
-
-// CAS performs a compare-and-swap for a(n) {{ .Type }} value at address contained within v.
-func (v *{{ .Name }}) CAS(cmp, swp {{ .Type }}) bool {
- for {
- // Load current value at address
- ptr := atomic.LoadPointer(&v.ptr)
- cur := *(*{{ .Type }})(ptr)
-
- // Perform comparison against current
- if !({{ call .Compare "cur" "cmp" }}) {
- return false
- }
-
- // Attempt to replace pointer
- if atomic.CompareAndSwapPointer(
- &v.ptr,
- ptr,
- unsafe.Pointer(&swp),
- ) {
- return true
- }
- }
-}
-
-// Swap atomically stores new {{ .Type }} value into address contained within v, and returns previous value.
-func (v *{{ .Name }}) Swap(swp {{ .Type }}) {{ .Type }} {
- ptr := unsafe.Pointer(&swp)
- ptr = atomic.SwapPointer(&v.ptr, ptr)
- return *(*{{ .Type }})(ptr)
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/atomic_test.tpl b/vendor/codeberg.org/gruf/go-atomics/atomic_test.tpl
deleted file mode 100644
index 4e659d81f..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/atomic_test.tpl
+++ /dev/null
@@ -1,60 +0,0 @@
-package atomics_test
-
-import (
- "atomic"
- "unsafe"
- "testing"
-
- "codeberg.org/gruf/go-atomics"
-)
-
-func Test{{ .Name }}StoreLoad(t *testing.T) {
- for _, test := range {{ .Name }}Tests {
- val := atomics.New{{ .Name }}()
-
- val.Store(test.V1)
-
- if !({{ call .Compare "val.Load()" "test.V1" }}) {
- t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V1)
- }
-
- val.Store(test.V2)
-
- if !({{ call .Compare "val.Load()" "test.V2" }}) {
- t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V2)
- }
- }
-}
-
-func Test{{ .Name }}CAS(t *testing.T) {
- for _, test := range {{ .Name }}Tests {
- val := atomics.New{{ .Name }}()
-
- val.Store(test.V1)
-
- if val.CAS(test.V2, test.V1) {
- t.Fatalf("failed testing negative .CAS: test=%+v state=%v", test, val.Load())
- }
-
- if !val.CAS(test.V1, test.V2) {
- t.Fatalf("failed testing positive .CAS: test=%+v state=%v", test, val.Load())
- }
- }
-}
-
-func Test{{ .Name }}Swap(t *testing.T) {
- for _, test := range {{ .Name }}Tests {
- val := atomics.New{{ .Name }}()
-
- val.Store(test.V1)
-
- if !({{ call .Compare "val.Swap(test.V2)" "test.V1" }}) {
- t.Fatal("failed testing .Swap")
- }
-
- if !({{ call .Compare "val.Swap(test.V1)" "test.V2" }}) {
- t.Fatal("failed testing .Swap")
- }
- }
-}
-
diff --git a/vendor/codeberg.org/gruf/go-atomics/bool.go b/vendor/codeberg.org/gruf/go-atomics/bool.go
deleted file mode 100644
index 52660d356..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/bool.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package atomics
-
-import "sync/atomic"
-
-// Bool provides user-friendly means of performing atomic operations on bool types.
-type Bool uint32
-
-// NewBool will return a new Bool instance initialized with zero value.
-func NewBool() *Bool {
- return new(Bool)
-}
-
-// Store will atomically store bool value in address contained within i.
-func (b *Bool) Store(val bool) {
- atomic.StoreUint32((*uint32)(b), fromBool(val))
-}
-
-// Load will atomically load bool value at address contained within i.
-func (b *Bool) Load() bool {
- return toBool(atomic.LoadUint32((*uint32)(b)))
-}
-
-// CAS performs a compare-and-swap for a(n) bool value at address contained within i.
-func (b *Bool) CAS(cmp, swp bool) bool {
- return atomic.CompareAndSwapUint32((*uint32)(b), fromBool(cmp), fromBool(swp))
-}
-
-// Swap atomically stores new bool value into address contained within i, and returns previous value.
-func (b *Bool) Swap(swp bool) bool {
- return toBool(atomic.SwapUint32((*uint32)(b), fromBool(swp)))
-}
-
-// toBool converts uint32 value to bool.
-func toBool(u uint32) bool {
- if u == 0 {
- return false
- }
- return true
-}
-
-// fromBool converts from bool to uint32 value.
-func fromBool(b bool) uint32 {
- if b {
- return 1
- }
- return 0
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/bytes.go b/vendor/codeberg.org/gruf/go-atomics/bytes.go
deleted file mode 100644
index 3e40d186c..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/bytes.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package atomics
-
-import (
- "sync/atomic"
- "unsafe"
-)
-
-// Bytes provides user-friendly means of performing atomic operations on []byte types.
-type Bytes struct{ ptr unsafe.Pointer }
-
-// NewBytes will return a new Bytes instance initialized with zero value.
-func NewBytes() *Bytes {
- var v []byte
- return &Bytes{
- ptr: unsafe.Pointer(&v),
- }
-}
-
-// Store will atomically store []byte value in address contained within v.
-func (v *Bytes) Store(val []byte) {
- atomic.StorePointer(&v.ptr, unsafe.Pointer(&val))
-}
-
-// Load will atomically load []byte value at address contained within v.
-func (v *Bytes) Load() []byte {
- return *(*[]byte)(atomic.LoadPointer(&v.ptr))
-}
-
-// CAS performs a compare-and-swap for a(n) []byte value at address contained within v.
-func (v *Bytes) CAS(cmp, swp []byte) bool {
- for {
- // Load current value at address
- ptr := atomic.LoadPointer(&v.ptr)
- cur := *(*[]byte)(ptr)
-
- // Perform comparison against current
- if !(string(cur) == string(cmp)) {
- return false
- }
-
- // Attempt to replace pointer
- if atomic.CompareAndSwapPointer(
- &v.ptr,
- ptr,
- unsafe.Pointer(&swp),
- ) {
- return true
- }
- }
-}
-
-// Swap atomically stores new []byte value into address contained within v, and returns previous value.
-func (v *Bytes) Swap(swp []byte) []byte {
- ptr := unsafe.Pointer(&swp)
- ptr = atomic.SwapPointer(&v.ptr, ptr)
- return *(*[]byte)(ptr)
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/error.go b/vendor/codeberg.org/gruf/go-atomics/error.go
deleted file mode 100644
index 0ecc4e9ad..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/error.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package atomics
-
-import (
- "sync/atomic"
- "unsafe"
-)
-
-// Error provides user-friendly means of performing atomic operations on error types.
-type Error struct{ ptr unsafe.Pointer }
-
-// NewError will return a new Error instance initialized with zero value.
-func NewError() *Error {
- var v error
- return &Error{
- ptr: unsafe.Pointer(&v),
- }
-}
-
-// Store will atomically store error value in address contained within v.
-func (v *Error) Store(val error) {
- atomic.StorePointer(&v.ptr, unsafe.Pointer(&val))
-}
-
-// Load will atomically load error value at address contained within v.
-func (v *Error) Load() error {
- return *(*error)(atomic.LoadPointer(&v.ptr))
-}
-
-// CAS performs a compare-and-swap for a(n) error value at address contained within v.
-func (v *Error) CAS(cmp, swp error) bool {
- for {
- // Load current value at address
- ptr := atomic.LoadPointer(&v.ptr)
- cur := *(*error)(ptr)
-
- // Perform comparison against current
- if !(cur == cmp) {
- return false
- }
-
- // Attempt to replace pointer
- if atomic.CompareAndSwapPointer(
- &v.ptr,
- ptr,
- unsafe.Pointer(&swp),
- ) {
- return true
- }
- }
-}
-
-// Swap atomically stores new error value into address contained within v, and returns previous value.
-func (v *Error) Swap(swp error) error {
- ptr := unsafe.Pointer(&swp)
- ptr = atomic.SwapPointer(&v.ptr, ptr)
- return *(*error)(ptr)
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/flags.go b/vendor/codeberg.org/gruf/go-atomics/flags.go
deleted file mode 100644
index 42176bece..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/flags.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package atomics
-
-import (
- "sync/atomic"
-
- "codeberg.org/gruf/go-bitutil"
-)
-
-// Flags32 provides user-friendly means of performing atomic operations on bitutil.Flags32 types.
-type Flags32 bitutil.Flags32
-
-// NewFlags32 will return a new Flags32 instance initialized with zero value.
-func NewFlags32() *Flags32 {
- return new(Flags32)
-}
-
-// Get will atomically load a(n) bitutil.Flags32 value contained within f, and check if bit value is set.
-func (f *Flags32) Get(bit uint8) bool {
- return f.Load().Get(bit)
-}
-
-// Set performs a compare-and-swap for a(n) bitutil.Flags32 with bit value set, at address contained within f.
-func (f *Flags32) Set(bit uint8) bool {
- cur := f.Load()
- return f.CAS(cur, cur.Set(bit))
-}
-
-// Unset performs a compare-and-swap for a(n) bitutil.Flags32 with bit value unset, at address contained within f.
-func (f *Flags32) Unset(bit uint8) bool {
- cur := f.Load()
- return f.CAS(cur, cur.Unset(bit))
-}
-
-// Store will atomically store bitutil.Flags32 value in address contained within f.
-func (f *Flags32) Store(val bitutil.Flags32) {
- atomic.StoreUint32((*uint32)(f), uint32(val))
-}
-
-// Load will atomically load bitutil.Flags32 value at address contained within f.
-func (f *Flags32) Load() bitutil.Flags32 {
- return bitutil.Flags32(atomic.LoadUint32((*uint32)(f)))
-}
-
-// CAS performs a compare-and-swap for a(n) bitutil.Flags32 value at address contained within f.
-func (f *Flags32) CAS(cmp, swp bitutil.Flags32) bool {
- return atomic.CompareAndSwapUint32((*uint32)(f), uint32(cmp), uint32(swp))
-}
-
-// Swap atomically stores new bitutil.Flags32 value into address contained within f, and returns previous value.
-func (f *Flags32) Swap(swp bitutil.Flags32) bitutil.Flags32 {
- return bitutil.Flags32(atomic.SwapUint32((*uint32)(f), uint32(swp)))
-}
-
-// Flags64 provides user-friendly means of performing atomic operations on bitutil.Flags64 types.
-type Flags64 bitutil.Flags64
-
-// NewFlags64 will return a new Flags64 instance initialized with zero value.
-func NewFlags64() *Flags64 {
- return new(Flags64)
-}
-
-// Get will atomically load a(n) bitutil.Flags64 value contained within f, and check if bit value is set.
-func (f *Flags64) Get(bit uint8) bool {
- return f.Load().Get(bit)
-}
-
-// Set performs a compare-and-swap for a(n) bitutil.Flags64 with bit value set, at address contained within f.
-func (f *Flags64) Set(bit uint8) bool {
- cur := f.Load()
- return f.CAS(cur, cur.Set(bit))
-}
-
-// Unset performs a compare-and-swap for a(n) bitutil.Flags64 with bit value unset, at address contained within f.
-func (f *Flags64) Unset(bit uint8) bool {
- cur := f.Load()
- return f.CAS(cur, cur.Unset(bit))
-}
-
-// Store will atomically store bitutil.Flags64 value in address contained within f.
-func (f *Flags64) Store(val bitutil.Flags64) {
- atomic.StoreUint64((*uint64)(f), uint64(val))
-}
-
-// Load will atomically load bitutil.Flags64 value at address contained within f.
-func (f *Flags64) Load() bitutil.Flags64 {
- return bitutil.Flags64(atomic.LoadUint64((*uint64)(f)))
-}
-
-// CAS performs a compare-and-swap for a(n) bitutil.Flags64 value at address contained within f.
-func (f *Flags64) CAS(cmp, swp bitutil.Flags64) bool {
- return atomic.CompareAndSwapUint64((*uint64)(f), uint64(cmp), uint64(swp))
-}
-
-// Swap atomically stores new bitutil.Flags64 value into address contained within f, and returns previous value.
-func (f *Flags64) Swap(swp bitutil.Flags64) bitutil.Flags64 {
- return bitutil.Flags64(atomic.SwapUint64((*uint64)(f), uint64(swp)))
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/int.go b/vendor/codeberg.org/gruf/go-atomics/int.go
deleted file mode 100644
index 019ca1034..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/int.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package atomics
-
-import "sync/atomic"
-
-// Int32 provides user-friendly means of performing atomic operations on int32 types.
-type Int32 int32
-
-// NewInt32 will return a new Int32 instance initialized with zero value.
-func NewInt32() *Int32 {
- return new(Int32)
-}
-
-// Add will atomically add int32 delta to value in address contained within i, returning new value.
-func (i *Int32) Add(delta int32) int32 {
- return atomic.AddInt32((*int32)(i), delta)
-}
-
-// Store will atomically store int32 value in address contained within i.
-func (i *Int32) Store(val int32) {
- atomic.StoreInt32((*int32)(i), val)
-}
-
-// Load will atomically load int32 value at address contained within i.
-func (i *Int32) Load() int32 {
- return atomic.LoadInt32((*int32)(i))
-}
-
-// CAS performs a compare-and-swap for a(n) int32 value at address contained within i.
-func (i *Int32) CAS(cmp, swp int32) bool {
- return atomic.CompareAndSwapInt32((*int32)(i), cmp, swp)
-}
-
-// Swap atomically stores new int32 value into address contained within i, and returns previous value.
-func (i *Int32) Swap(swp int32) int32 {
- return atomic.SwapInt32((*int32)(i), swp)
-}
-
-// Int64 provides user-friendly means of performing atomic operations on int64 types.
-type Int64 int64
-
-// NewInt64 will return a new Int64 instance initialized with zero value.
-func NewInt64() *Int64 {
- return new(Int64)
-}
-
-// Add will atomically add int64 delta to value in address contained within i, returning new value.
-func (i *Int64) Add(delta int64) int64 {
- return atomic.AddInt64((*int64)(i), delta)
-}
-
-// Store will atomically store int64 value in address contained within i.
-func (i *Int64) Store(val int64) {
- atomic.StoreInt64((*int64)(i), val)
-}
-
-// Load will atomically load int64 value at address contained within i.
-func (i *Int64) Load() int64 {
- return atomic.LoadInt64((*int64)(i))
-}
-
-// CAS performs a compare-and-swap for a(n) int64 value at address contained within i.
-func (i *Int64) CAS(cmp, swp int64) bool {
- return atomic.CompareAndSwapInt64((*int64)(i), cmp, swp)
-}
-
-// Swap atomically stores new int64 value into address contained within i, and returns previous value.
-func (i *Int64) Swap(swp int64) int64 {
- return atomic.SwapInt64((*int64)(i), swp)
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/interface.go b/vendor/codeberg.org/gruf/go-atomics/interface.go
deleted file mode 100644
index f0d1c4355..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/interface.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package atomics
-
-import (
- "sync/atomic"
- "unsafe"
-)
-
-// Interface provides user-friendly means of performing atomic operations on interface{} types.
-type Interface struct{ ptr unsafe.Pointer }
-
-// NewInterface will return a new Interface instance initialized with zero value.
-func NewInterface() *Interface {
- var v interface{}
- return &Interface{
- ptr: unsafe.Pointer(&v),
- }
-}
-
-// Store will atomically store interface{} value in address contained within v.
-func (v *Interface) Store(val interface{}) {
- atomic.StorePointer(&v.ptr, unsafe.Pointer(&val))
-}
-
-// Load will atomically load interface{} value at address contained within v.
-func (v *Interface) Load() interface{} {
- return *(*interface{})(atomic.LoadPointer(&v.ptr))
-}
-
-// CAS performs a compare-and-swap for a(n) interface{} value at address contained within v.
-func (v *Interface) CAS(cmp, swp interface{}) bool {
- for {
- // Load current value at address
- ptr := atomic.LoadPointer(&v.ptr)
- cur := *(*interface{})(ptr)
-
- // Perform comparison against current
- if !(cur == cmp) {
- return false
- }
-
- // Attempt to replace pointer
- if atomic.CompareAndSwapPointer(
- &v.ptr,
- ptr,
- unsafe.Pointer(&swp),
- ) {
- return true
- }
- }
-}
-
-// Swap atomically stores new interface{} value into address contained within v, and returns previous value.
-func (v *Interface) Swap(swp interface{}) interface{} {
- ptr := unsafe.Pointer(&swp)
- ptr = atomic.SwapPointer(&v.ptr, ptr)
- return *(*interface{})(ptr)
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/state.go b/vendor/codeberg.org/gruf/go-atomics/state.go
deleted file mode 100644
index 21892f378..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/state.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package atomics
-
-import "sync"
-
-// State provides user-friendly means of performing atomic-like
-// operations on a uint32 state, and allowing callbacks on successful
-// state change. This is a bit of a misnomer being where it is, as it
-// actually uses a mutex under-the-hood.
-type State struct {
- mutex sync.Mutex
- state uint32
-}
-
-// Store will update State value safely within mutex lock.
-func (st *State) Store(val uint32) {
- st.mutex.Lock()
- st.state = val
- st.mutex.Unlock()
-}
-
-// Load will get value of State safely within mutex lock.
-func (st *State) Load() uint32 {
- st.mutex.Lock()
- state := st.state
- st.mutex.Unlock()
- return state
-}
-
-// WithLock performs fn within State mutex lock, useful if you want
-// to just use State's mutex for locking instead of creating another.
-func (st *State) WithLock(fn func()) {
- st.mutex.Lock()
- defer st.mutex.Unlock()
- fn()
-}
-
-// Update performs fn within State mutex lock, with the current state
-// value provided as an argument, and return value used to update state.
-func (st *State) Update(fn func(state uint32) uint32) {
- st.mutex.Lock()
- defer st.mutex.Unlock()
- st.state = fn(st.state)
-}
-
-// CAS performs a compare-and-swap on State, calling fn on success. Success value is also returned.
-func (st *State) CAS(cmp, swp uint32, fn func()) (ok bool) {
- // Acquire lock
- st.mutex.Lock()
- defer st.mutex.Unlock()
-
- // Perform CAS operation, fn() on success
- if ok = (st.state == cmp); ok {
- st.state = swp
- fn()
- }
-
- return
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/string.go b/vendor/codeberg.org/gruf/go-atomics/string.go
deleted file mode 100644
index a0a6e115f..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/string.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package atomics
-
-import (
- "sync/atomic"
- "unsafe"
-)
-
-// String provides user-friendly means of performing atomic operations on string types.
-type String struct{ ptr unsafe.Pointer }
-
-// NewString will return a new String instance initialized with zero value.
-func NewString() *String {
- var v string
- return &String{
- ptr: unsafe.Pointer(&v),
- }
-}
-
-// Store will atomically store string value in address contained within v.
-func (v *String) Store(val string) {
- atomic.StorePointer(&v.ptr, unsafe.Pointer(&val))
-}
-
-// Load will atomically load string value at address contained within v.
-func (v *String) Load() string {
- return *(*string)(atomic.LoadPointer(&v.ptr))
-}
-
-// CAS performs a compare-and-swap for a(n) string value at address contained within v.
-func (v *String) CAS(cmp, swp string) bool {
- for {
- // Load current value at address
- ptr := atomic.LoadPointer(&v.ptr)
- cur := *(*string)(ptr)
-
- // Perform comparison against current
- if !(cur == cmp) {
- return false
- }
-
- // Attempt to replace pointer
- if atomic.CompareAndSwapPointer(
- &v.ptr,
- ptr,
- unsafe.Pointer(&swp),
- ) {
- return true
- }
- }
-}
-
-// Swap atomically stores new string value into address contained within v, and returns previous value.
-func (v *String) Swap(swp string) string {
- ptr := unsafe.Pointer(&swp)
- ptr = atomic.SwapPointer(&v.ptr, ptr)
- return *(*string)(ptr)
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/time.go b/vendor/codeberg.org/gruf/go-atomics/time.go
deleted file mode 100644
index 4bf20cc74..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/time.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package atomics
-
-import (
- "sync/atomic"
- "time"
- "unsafe"
-)
-
-// Time provides user-friendly means of performing atomic operations on time.Time types.
-type Time struct{ ptr unsafe.Pointer }
-
-// NewTime will return a new Time instance initialized with zero value.
-func NewTime() *Time {
- var v time.Time
- return &Time{
- ptr: unsafe.Pointer(&v),
- }
-}
-
-// Store will atomically store time.Time value in address contained within v.
-func (v *Time) Store(val time.Time) {
- atomic.StorePointer(&v.ptr, unsafe.Pointer(&val))
-}
-
-// Load will atomically load time.Time value at address contained within v.
-func (v *Time) Load() time.Time {
- return *(*time.Time)(atomic.LoadPointer(&v.ptr))
-}
-
-// CAS performs a compare-and-swap for a(n) time.Time value at address contained within v.
-func (v *Time) CAS(cmp, swp time.Time) bool {
- for {
- // Load current value at address
- ptr := atomic.LoadPointer(&v.ptr)
- cur := *(*time.Time)(ptr)
-
- // Perform comparison against current
- if !(cur.Equal(cmp)) {
- return false
- }
-
- // Attempt to replace pointer
- if atomic.CompareAndSwapPointer(
- &v.ptr,
- ptr,
- unsafe.Pointer(&swp),
- ) {
- return true
- }
- }
-}
-
-// Swap atomically stores new time.Time value into address contained within v, and returns previous value.
-func (v *Time) Swap(swp time.Time) time.Time {
- ptr := unsafe.Pointer(&swp)
- ptr = atomic.SwapPointer(&v.ptr, ptr)
- return *(*time.Time)(ptr)
-}
diff --git a/vendor/codeberg.org/gruf/go-atomics/uint.go b/vendor/codeberg.org/gruf/go-atomics/uint.go
deleted file mode 100644
index 087e231d1..000000000
--- a/vendor/codeberg.org/gruf/go-atomics/uint.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package atomics
-
-import "sync/atomic"
-
-// Uint32 provides user-friendly means of performing atomic operations on uint32 types.
-type Uint32 uint32
-
-// NewUint32 will return a new Uint32 instance initialized with zero value.
-func NewUint32() *Uint32 {
- return new(Uint32)
-}
-
-// Add will atomically add uint32 delta to value in address contained within i, returning new value.
-func (u *Uint32) Add(delta uint32) uint32 {
- return atomic.AddUint32((*uint32)(u), delta)
-}
-
-// Store will atomically store uint32 value in address contained within i.
-func (u *Uint32) Store(val uint32) {
- atomic.StoreUint32((*uint32)(u), val)
-}
-
-// Load will atomically load uint32 value at address contained within i.
-func (u *Uint32) Load() uint32 {
- return atomic.LoadUint32((*uint32)(u))
-}
-
-// CAS performs a compare-and-swap for a(n) uint32 value at address contained within i.
-func (u *Uint32) CAS(cmp, swp uint32) bool {
- return atomic.CompareAndSwapUint32((*uint32)(u), cmp, swp)
-}
-
-// Swap atomically stores new uint32 value into address contained within i, and returns previous value.
-func (u *Uint32) Swap(swp uint32) uint32 {
- return atomic.SwapUint32((*uint32)(u), swp)
-}
-
-// Uint64 provides user-friendly means of performing atomic operations on uint64 types.
-type Uint64 uint64
-
-// NewUint64 will return a new Uint64 instance initialized with zero value.
-func NewUint64() *Uint64 {
- return new(Uint64)
-}
-
-// Add will atomically add uint64 delta to value in address contained within i, returning new value.
-func (u *Uint64) Add(delta uint64) uint64 {
- return atomic.AddUint64((*uint64)(u), delta)
-}
-
-// Store will atomically store uint64 value in address contained within i.
-func (u *Uint64) Store(val uint64) {
- atomic.StoreUint64((*uint64)(u), val)
-}
-
-// Load will atomically load uint64 value at address contained within i.
-func (u *Uint64) Load() uint64 {
- return atomic.LoadUint64((*uint64)(u))
-}
-
-// CAS performs a compare-and-swap for a(n) uint64 value at address contained within i.
-func (u *Uint64) CAS(cmp, swp uint64) bool {
- return atomic.CompareAndSwapUint64((*uint64)(u), cmp, swp)
-}
-
-// Swap atomically stores new uint64 value into address contained within i, and returns previous value.
-func (u *Uint64) Swap(swp uint64) uint64 {
- return atomic.SwapUint64((*uint64)(u), swp)
-}
diff --git a/vendor/codeberg.org/gruf/go-bitutil/LICENSE b/vendor/codeberg.org/gruf/go-bitutil/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-bitutil/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-bitutil/README.md b/vendor/codeberg.org/gruf/go-bitutil/README.md
deleted file mode 100644
index a71c1aa0b..000000000
--- a/vendor/codeberg.org/gruf/go-bitutil/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-bitutil
-
-This library provides helpful methods and types for performing typical bitwise operations on integers, e.g. packing/unpacking, bit flags. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag.go b/vendor/codeberg.org/gruf/go-bitutil/flag.go
deleted file mode 100644
index d8b0f8b66..000000000
--- a/vendor/codeberg.org/gruf/go-bitutil/flag.go
+++ /dev/null
@@ -1,3084 +0,0 @@
-package bitutil
-
-import (
- "codeberg.org/gruf/go-byteutil"
-)
-
-// Flags8 is a type-casted unsigned integer with helper
-// methods for easily managing up to 8 bit flags.
-type Flags8 uint8
-
-// Get will fetch the flag bit value at index 'bit'.
-func (f Flags8) Get(bit uint8) bool {
- mask := Flags8(1) << bit
- return (f&mask != 0)
-}
-
-// Set will set the flag bit value at index 'bit'.
-func (f Flags8) Set(bit uint8) Flags8 {
- mask := Flags8(1) << bit
- return f | mask
-}
-
-// Unset will unset the flag bit value at index 'bit'.
-func (f Flags8) Unset(bit uint8) Flags8 {
- mask := Flags8(1) << bit
- return f & ^mask
-}
-
-// Get0 will fetch the flag bit value at index 0.
-func (f Flags8) Get0() bool {
- const mask = Flags8(1) << 0
- return (f&mask != 0)
-}
-
-// Set0 will set the flag bit value at index 0.
-func (f Flags8) Set0() Flags8 {
- const mask = Flags8(1) << 0
- return f | mask
-}
-
-// Unset0 will unset the flag bit value at index 0.
-func (f Flags8) Unset0() Flags8 {
- const mask = Flags8(1) << 0
- return f & ^mask
-}
-
-// Get1 will fetch the flag bit value at index 1.
-func (f Flags8) Get1() bool {
- const mask = Flags8(1) << 1
- return (f&mask != 0)
-}
-
-// Set1 will set the flag bit value at index 1.
-func (f Flags8) Set1() Flags8 {
- const mask = Flags8(1) << 1
- return f | mask
-}
-
-// Unset1 will unset the flag bit value at index 1.
-func (f Flags8) Unset1() Flags8 {
- const mask = Flags8(1) << 1
- return f & ^mask
-}
-
-// Get2 will fetch the flag bit value at index 2.
-func (f Flags8) Get2() bool {
- const mask = Flags8(1) << 2
- return (f&mask != 0)
-}
-
-// Set2 will set the flag bit value at index 2.
-func (f Flags8) Set2() Flags8 {
- const mask = Flags8(1) << 2
- return f | mask
-}
-
-// Unset2 will unset the flag bit value at index 2.
-func (f Flags8) Unset2() Flags8 {
- const mask = Flags8(1) << 2
- return f & ^mask
-}
-
-// Get3 will fetch the flag bit value at index 3.
-func (f Flags8) Get3() bool {
- const mask = Flags8(1) << 3
- return (f&mask != 0)
-}
-
-// Set3 will set the flag bit value at index 3.
-func (f Flags8) Set3() Flags8 {
- const mask = Flags8(1) << 3
- return f | mask
-}
-
-// Unset3 will unset the flag bit value at index 3.
-func (f Flags8) Unset3() Flags8 {
- const mask = Flags8(1) << 3
- return f & ^mask
-}
-
-// Get4 will fetch the flag bit value at index 4.
-func (f Flags8) Get4() bool {
- const mask = Flags8(1) << 4
- return (f&mask != 0)
-}
-
-// Set4 will set the flag bit value at index 4.
-func (f Flags8) Set4() Flags8 {
- const mask = Flags8(1) << 4
- return f | mask
-}
-
-// Unset4 will unset the flag bit value at index 4.
-func (f Flags8) Unset4() Flags8 {
- const mask = Flags8(1) << 4
- return f & ^mask
-}
-
-// Get5 will fetch the flag bit value at index 5.
-func (f Flags8) Get5() bool {
- const mask = Flags8(1) << 5
- return (f&mask != 0)
-}
-
-// Set5 will set the flag bit value at index 5.
-func (f Flags8) Set5() Flags8 {
- const mask = Flags8(1) << 5
- return f | mask
-}
-
-// Unset5 will unset the flag bit value at index 5.
-func (f Flags8) Unset5() Flags8 {
- const mask = Flags8(1) << 5
- return f & ^mask
-}
-
-// Get6 will fetch the flag bit value at index 6.
-func (f Flags8) Get6() bool {
- const mask = Flags8(1) << 6
- return (f&mask != 0)
-}
-
-// Set6 will set the flag bit value at index 6.
-func (f Flags8) Set6() Flags8 {
- const mask = Flags8(1) << 6
- return f | mask
-}
-
-// Unset6 will unset the flag bit value at index 6.
-func (f Flags8) Unset6() Flags8 {
- const mask = Flags8(1) << 6
- return f & ^mask
-}
-
-// Get7 will fetch the flag bit value at index 7.
-func (f Flags8) Get7() bool {
- const mask = Flags8(1) << 7
- return (f&mask != 0)
-}
-
-// Set7 will set the flag bit value at index 7.
-func (f Flags8) Set7() Flags8 {
- const mask = Flags8(1) << 7
- return f | mask
-}
-
-// Unset7 will unset the flag bit value at index 7.
-func (f Flags8) Unset7() Flags8 {
- const mask = Flags8(1) << 7
- return f & ^mask
-}
-
-// String returns a human readable representation of Flags8.
-func (f Flags8) String() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteByte('{')
-
- val = f.Get0()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get1()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get2()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get3()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get4()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get5()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get6()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get7()
- buf.WriteString(bool2str(val) + " ")
-
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-// GoString returns a more verbose human readable representation of Flags8.
-func (f Flags8) GoString() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteString("bitutil.Flags8{")
-
- val = f.Get0()
- buf.WriteString("0=" + bool2str(val) + " ")
-
- val = f.Get1()
- buf.WriteString("1=" + bool2str(val) + " ")
-
- val = f.Get2()
- buf.WriteString("2=" + bool2str(val) + " ")
-
- val = f.Get3()
- buf.WriteString("3=" + bool2str(val) + " ")
-
- val = f.Get4()
- buf.WriteString("4=" + bool2str(val) + " ")
-
- val = f.Get5()
- buf.WriteString("5=" + bool2str(val) + " ")
-
- val = f.Get6()
- buf.WriteString("6=" + bool2str(val) + " ")
-
- val = f.Get7()
- buf.WriteString("7=" + bool2str(val) + " ")
-
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-// Flags16 is a type-casted unsigned integer with helper
-// methods for easily managing up to 16 bit flags.
-type Flags16 uint16
-
-// Get will fetch the flag bit value at index 'bit'.
-func (f Flags16) Get(bit uint8) bool {
- mask := Flags16(1) << bit
- return (f&mask != 0)
-}
-
-// Set will set the flag bit value at index 'bit'.
-func (f Flags16) Set(bit uint8) Flags16 {
- mask := Flags16(1) << bit
- return f | mask
-}
-
-// Unset will unset the flag bit value at index 'bit'.
-func (f Flags16) Unset(bit uint8) Flags16 {
- mask := Flags16(1) << bit
- return f & ^mask
-}
-
-// Get0 will fetch the flag bit value at index 0.
-func (f Flags16) Get0() bool {
- const mask = Flags16(1) << 0
- return (f&mask != 0)
-}
-
-// Set0 will set the flag bit value at index 0.
-func (f Flags16) Set0() Flags16 {
- const mask = Flags16(1) << 0
- return f | mask
-}
-
-// Unset0 will unset the flag bit value at index 0.
-func (f Flags16) Unset0() Flags16 {
- const mask = Flags16(1) << 0
- return f & ^mask
-}
-
-// Get1 will fetch the flag bit value at index 1.
-func (f Flags16) Get1() bool {
- const mask = Flags16(1) << 1
- return (f&mask != 0)
-}
-
-// Set1 will set the flag bit value at index 1.
-func (f Flags16) Set1() Flags16 {
- const mask = Flags16(1) << 1
- return f | mask
-}
-
-// Unset1 will unset the flag bit value at index 1.
-func (f Flags16) Unset1() Flags16 {
- const mask = Flags16(1) << 1
- return f & ^mask
-}
-
-// Get2 will fetch the flag bit value at index 2.
-func (f Flags16) Get2() bool {
- const mask = Flags16(1) << 2
- return (f&mask != 0)
-}
-
-// Set2 will set the flag bit value at index 2.
-func (f Flags16) Set2() Flags16 {
- const mask = Flags16(1) << 2
- return f | mask
-}
-
-// Unset2 will unset the flag bit value at index 2.
-func (f Flags16) Unset2() Flags16 {
- const mask = Flags16(1) << 2
- return f & ^mask
-}
-
-// Get3 will fetch the flag bit value at index 3.
-func (f Flags16) Get3() bool {
- const mask = Flags16(1) << 3
- return (f&mask != 0)
-}
-
-// Set3 will set the flag bit value at index 3.
-func (f Flags16) Set3() Flags16 {
- const mask = Flags16(1) << 3
- return f | mask
-}
-
-// Unset3 will unset the flag bit value at index 3.
-func (f Flags16) Unset3() Flags16 {
- const mask = Flags16(1) << 3
- return f & ^mask
-}
-
-// Get4 will fetch the flag bit value at index 4.
-func (f Flags16) Get4() bool {
- const mask = Flags16(1) << 4
- return (f&mask != 0)
-}
-
-// Set4 will set the flag bit value at index 4.
-func (f Flags16) Set4() Flags16 {
- const mask = Flags16(1) << 4
- return f | mask
-}
-
-// Unset4 will unset the flag bit value at index 4.
-func (f Flags16) Unset4() Flags16 {
- const mask = Flags16(1) << 4
- return f & ^mask
-}
-
-// Get5 will fetch the flag bit value at index 5.
-func (f Flags16) Get5() bool {
- const mask = Flags16(1) << 5
- return (f&mask != 0)
-}
-
-// Set5 will set the flag bit value at index 5.
-func (f Flags16) Set5() Flags16 {
- const mask = Flags16(1) << 5
- return f | mask
-}
-
-// Unset5 will unset the flag bit value at index 5.
-func (f Flags16) Unset5() Flags16 {
- const mask = Flags16(1) << 5
- return f & ^mask
-}
-
-// Get6 will fetch the flag bit value at index 6.
-func (f Flags16) Get6() bool {
- const mask = Flags16(1) << 6
- return (f&mask != 0)
-}
-
-// Set6 will set the flag bit value at index 6.
-func (f Flags16) Set6() Flags16 {
- const mask = Flags16(1) << 6
- return f | mask
-}
-
-// Unset6 will unset the flag bit value at index 6.
-func (f Flags16) Unset6() Flags16 {
- const mask = Flags16(1) << 6
- return f & ^mask
-}
-
-// Get7 will fetch the flag bit value at index 7.
-func (f Flags16) Get7() bool {
- const mask = Flags16(1) << 7
- return (f&mask != 0)
-}
-
-// Set7 will set the flag bit value at index 7.
-func (f Flags16) Set7() Flags16 {
- const mask = Flags16(1) << 7
- return f | mask
-}
-
-// Unset7 will unset the flag bit value at index 7.
-func (f Flags16) Unset7() Flags16 {
- const mask = Flags16(1) << 7
- return f & ^mask
-}
-
-// Get8 will fetch the flag bit value at index 8.
-func (f Flags16) Get8() bool {
- const mask = Flags16(1) << 8
- return (f&mask != 0)
-}
-
-// Set8 will set the flag bit value at index 8.
-func (f Flags16) Set8() Flags16 {
- const mask = Flags16(1) << 8
- return f | mask
-}
-
-// Unset8 will unset the flag bit value at index 8.
-func (f Flags16) Unset8() Flags16 {
- const mask = Flags16(1) << 8
- return f & ^mask
-}
-
-// Get9 will fetch the flag bit value at index 9.
-func (f Flags16) Get9() bool {
- const mask = Flags16(1) << 9
- return (f&mask != 0)
-}
-
-// Set9 will set the flag bit value at index 9.
-func (f Flags16) Set9() Flags16 {
- const mask = Flags16(1) << 9
- return f | mask
-}
-
-// Unset9 will unset the flag bit value at index 9.
-func (f Flags16) Unset9() Flags16 {
- const mask = Flags16(1) << 9
- return f & ^mask
-}
-
-// Get10 will fetch the flag bit value at index 10.
-func (f Flags16) Get10() bool {
- const mask = Flags16(1) << 10
- return (f&mask != 0)
-}
-
-// Set10 will set the flag bit value at index 10.
-func (f Flags16) Set10() Flags16 {
- const mask = Flags16(1) << 10
- return f | mask
-}
-
-// Unset10 will unset the flag bit value at index 10.
-func (f Flags16) Unset10() Flags16 {
- const mask = Flags16(1) << 10
- return f & ^mask
-}
-
-// Get11 will fetch the flag bit value at index 11.
-func (f Flags16) Get11() bool {
- const mask = Flags16(1) << 11
- return (f&mask != 0)
-}
-
-// Set11 will set the flag bit value at index 11.
-func (f Flags16) Set11() Flags16 {
- const mask = Flags16(1) << 11
- return f | mask
-}
-
-// Unset11 will unset the flag bit value at index 11.
-func (f Flags16) Unset11() Flags16 {
- const mask = Flags16(1) << 11
- return f & ^mask
-}
-
-// Get12 will fetch the flag bit value at index 12.
-func (f Flags16) Get12() bool {
- const mask = Flags16(1) << 12
- return (f&mask != 0)
-}
-
-// Set12 will set the flag bit value at index 12.
-func (f Flags16) Set12() Flags16 {
- const mask = Flags16(1) << 12
- return f | mask
-}
-
-// Unset12 will unset the flag bit value at index 12.
-func (f Flags16) Unset12() Flags16 {
- const mask = Flags16(1) << 12
- return f & ^mask
-}
-
-// Get13 will fetch the flag bit value at index 13.
-func (f Flags16) Get13() bool {
- const mask = Flags16(1) << 13
- return (f&mask != 0)
-}
-
-// Set13 will set the flag bit value at index 13.
-func (f Flags16) Set13() Flags16 {
- const mask = Flags16(1) << 13
- return f | mask
-}
-
-// Unset13 will unset the flag bit value at index 13.
-func (f Flags16) Unset13() Flags16 {
- const mask = Flags16(1) << 13
- return f & ^mask
-}
-
-// Get14 will fetch the flag bit value at index 14.
-func (f Flags16) Get14() bool {
- const mask = Flags16(1) << 14
- return (f&mask != 0)
-}
-
-// Set14 will set the flag bit value at index 14.
-func (f Flags16) Set14() Flags16 {
- const mask = Flags16(1) << 14
- return f | mask
-}
-
-// Unset14 will unset the flag bit value at index 14.
-func (f Flags16) Unset14() Flags16 {
- const mask = Flags16(1) << 14
- return f & ^mask
-}
-
-// Get15 will fetch the flag bit value at index 15.
-func (f Flags16) Get15() bool {
- const mask = Flags16(1) << 15
- return (f&mask != 0)
-}
-
-// Set15 will set the flag bit value at index 15.
-func (f Flags16) Set15() Flags16 {
- const mask = Flags16(1) << 15
- return f | mask
-}
-
-// Unset15 will unset the flag bit value at index 15.
-func (f Flags16) Unset15() Flags16 {
- const mask = Flags16(1) << 15
- return f & ^mask
-}
-
-// String returns a human readable representation of Flags16.
-func (f Flags16) String() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteByte('{')
-
- val = f.Get0()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get1()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get2()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get3()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get4()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get5()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get6()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get7()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get8()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get9()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get10()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get11()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get12()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get13()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get14()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get15()
- buf.WriteString(bool2str(val) + " ")
-
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-// GoString returns a more verbose human readable representation of Flags16.
-func (f Flags16) GoString() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteString("bitutil.Flags16{")
-
- val = f.Get0()
- buf.WriteString("0=" + bool2str(val) + " ")
-
- val = f.Get1()
- buf.WriteString("1=" + bool2str(val) + " ")
-
- val = f.Get2()
- buf.WriteString("2=" + bool2str(val) + " ")
-
- val = f.Get3()
- buf.WriteString("3=" + bool2str(val) + " ")
-
- val = f.Get4()
- buf.WriteString("4=" + bool2str(val) + " ")
-
- val = f.Get5()
- buf.WriteString("5=" + bool2str(val) + " ")
-
- val = f.Get6()
- buf.WriteString("6=" + bool2str(val) + " ")
-
- val = f.Get7()
- buf.WriteString("7=" + bool2str(val) + " ")
-
- val = f.Get8()
- buf.WriteString("8=" + bool2str(val) + " ")
-
- val = f.Get9()
- buf.WriteString("9=" + bool2str(val) + " ")
-
- val = f.Get10()
- buf.WriteString("10=" + bool2str(val) + " ")
-
- val = f.Get11()
- buf.WriteString("11=" + bool2str(val) + " ")
-
- val = f.Get12()
- buf.WriteString("12=" + bool2str(val) + " ")
-
- val = f.Get13()
- buf.WriteString("13=" + bool2str(val) + " ")
-
- val = f.Get14()
- buf.WriteString("14=" + bool2str(val) + " ")
-
- val = f.Get15()
- buf.WriteString("15=" + bool2str(val) + " ")
-
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-// Flags32 is a type-casted unsigned integer with helper
-// methods for easily managing up to 32 bit flags.
-type Flags32 uint32
-
-// Get will fetch the flag bit value at index 'bit'.
-func (f Flags32) Get(bit uint8) bool {
- mask := Flags32(1) << bit
- return (f&mask != 0)
-}
-
-// Set will set the flag bit value at index 'bit'.
-func (f Flags32) Set(bit uint8) Flags32 {
- mask := Flags32(1) << bit
- return f | mask
-}
-
-// Unset will unset the flag bit value at index 'bit'.
-func (f Flags32) Unset(bit uint8) Flags32 {
- mask := Flags32(1) << bit
- return f & ^mask
-}
-
-// Get0 will fetch the flag bit value at index 0.
-func (f Flags32) Get0() bool {
- const mask = Flags32(1) << 0
- return (f&mask != 0)
-}
-
-// Set0 will set the flag bit value at index 0.
-func (f Flags32) Set0() Flags32 {
- const mask = Flags32(1) << 0
- return f | mask
-}
-
-// Unset0 will unset the flag bit value at index 0.
-func (f Flags32) Unset0() Flags32 {
- const mask = Flags32(1) << 0
- return f & ^mask
-}
-
-// Get1 will fetch the flag bit value at index 1.
-func (f Flags32) Get1() bool {
- const mask = Flags32(1) << 1
- return (f&mask != 0)
-}
-
-// Set1 will set the flag bit value at index 1.
-func (f Flags32) Set1() Flags32 {
- const mask = Flags32(1) << 1
- return f | mask
-}
-
-// Unset1 will unset the flag bit value at index 1.
-func (f Flags32) Unset1() Flags32 {
- const mask = Flags32(1) << 1
- return f & ^mask
-}
-
-// Get2 will fetch the flag bit value at index 2.
-func (f Flags32) Get2() bool {
- const mask = Flags32(1) << 2
- return (f&mask != 0)
-}
-
-// Set2 will set the flag bit value at index 2.
-func (f Flags32) Set2() Flags32 {
- const mask = Flags32(1) << 2
- return f | mask
-}
-
-// Unset2 will unset the flag bit value at index 2.
-func (f Flags32) Unset2() Flags32 {
- const mask = Flags32(1) << 2
- return f & ^mask
-}
-
-// Get3 will fetch the flag bit value at index 3.
-func (f Flags32) Get3() bool {
- const mask = Flags32(1) << 3
- return (f&mask != 0)
-}
-
-// Set3 will set the flag bit value at index 3.
-func (f Flags32) Set3() Flags32 {
- const mask = Flags32(1) << 3
- return f | mask
-}
-
-// Unset3 will unset the flag bit value at index 3.
-func (f Flags32) Unset3() Flags32 {
- const mask = Flags32(1) << 3
- return f & ^mask
-}
-
-// Get4 will fetch the flag bit value at index 4.
-func (f Flags32) Get4() bool {
- const mask = Flags32(1) << 4
- return (f&mask != 0)
-}
-
-// Set4 will set the flag bit value at index 4.
-func (f Flags32) Set4() Flags32 {
- const mask = Flags32(1) << 4
- return f | mask
-}
-
-// Unset4 will unset the flag bit value at index 4.
-func (f Flags32) Unset4() Flags32 {
- const mask = Flags32(1) << 4
- return f & ^mask
-}
-
-// Get5 will fetch the flag bit value at index 5.
-func (f Flags32) Get5() bool {
- const mask = Flags32(1) << 5
- return (f&mask != 0)
-}
-
-// Set5 will set the flag bit value at index 5.
-func (f Flags32) Set5() Flags32 {
- const mask = Flags32(1) << 5
- return f | mask
-}
-
-// Unset5 will unset the flag bit value at index 5.
-func (f Flags32) Unset5() Flags32 {
- const mask = Flags32(1) << 5
- return f & ^mask
-}
-
-// Get6 will fetch the flag bit value at index 6.
-func (f Flags32) Get6() bool {
- const mask = Flags32(1) << 6
- return (f&mask != 0)
-}
-
-// Set6 will set the flag bit value at index 6.
-func (f Flags32) Set6() Flags32 {
- const mask = Flags32(1) << 6
- return f | mask
-}
-
-// Unset6 will unset the flag bit value at index 6.
-func (f Flags32) Unset6() Flags32 {
- const mask = Flags32(1) << 6
- return f & ^mask
-}
-
-// Get7 will fetch the flag bit value at index 7.
-func (f Flags32) Get7() bool {
- const mask = Flags32(1) << 7
- return (f&mask != 0)
-}
-
-// Set7 will set the flag bit value at index 7.
-func (f Flags32) Set7() Flags32 {
- const mask = Flags32(1) << 7
- return f | mask
-}
-
-// Unset7 will unset the flag bit value at index 7.
-func (f Flags32) Unset7() Flags32 {
- const mask = Flags32(1) << 7
- return f & ^mask
-}
-
-// Get8 will fetch the flag bit value at index 8.
-func (f Flags32) Get8() bool {
- const mask = Flags32(1) << 8
- return (f&mask != 0)
-}
-
-// Set8 will set the flag bit value at index 8.
-func (f Flags32) Set8() Flags32 {
- const mask = Flags32(1) << 8
- return f | mask
-}
-
-// Unset8 will unset the flag bit value at index 8.
-func (f Flags32) Unset8() Flags32 {
- const mask = Flags32(1) << 8
- return f & ^mask
-}
-
-// Get9 will fetch the flag bit value at index 9.
-func (f Flags32) Get9() bool {
- const mask = Flags32(1) << 9
- return (f&mask != 0)
-}
-
-// Set9 will set the flag bit value at index 9.
-func (f Flags32) Set9() Flags32 {
- const mask = Flags32(1) << 9
- return f | mask
-}
-
-// Unset9 will unset the flag bit value at index 9.
-func (f Flags32) Unset9() Flags32 {
- const mask = Flags32(1) << 9
- return f & ^mask
-}
-
-// Get10 will fetch the flag bit value at index 10.
-func (f Flags32) Get10() bool {
- const mask = Flags32(1) << 10
- return (f&mask != 0)
-}
-
-// Set10 will set the flag bit value at index 10.
-func (f Flags32) Set10() Flags32 {
- const mask = Flags32(1) << 10
- return f | mask
-}
-
-// Unset10 will unset the flag bit value at index 10.
-func (f Flags32) Unset10() Flags32 {
- const mask = Flags32(1) << 10
- return f & ^mask
-}
-
-// Get11 will fetch the flag bit value at index 11.
-func (f Flags32) Get11() bool {
- const mask = Flags32(1) << 11
- return (f&mask != 0)
-}
-
-// Set11 will set the flag bit value at index 11.
-func (f Flags32) Set11() Flags32 {
- const mask = Flags32(1) << 11
- return f | mask
-}
-
-// Unset11 will unset the flag bit value at index 11.
-func (f Flags32) Unset11() Flags32 {
- const mask = Flags32(1) << 11
- return f & ^mask
-}
-
-// Get12 will fetch the flag bit value at index 12.
-func (f Flags32) Get12() bool {
- const mask = Flags32(1) << 12
- return (f&mask != 0)
-}
-
-// Set12 will set the flag bit value at index 12.
-func (f Flags32) Set12() Flags32 {
- const mask = Flags32(1) << 12
- return f | mask
-}
-
-// Unset12 will unset the flag bit value at index 12.
-func (f Flags32) Unset12() Flags32 {
- const mask = Flags32(1) << 12
- return f & ^mask
-}
-
-// Get13 will fetch the flag bit value at index 13.
-func (f Flags32) Get13() bool {
- const mask = Flags32(1) << 13
- return (f&mask != 0)
-}
-
-// Set13 will set the flag bit value at index 13.
-func (f Flags32) Set13() Flags32 {
- const mask = Flags32(1) << 13
- return f | mask
-}
-
-// Unset13 will unset the flag bit value at index 13.
-func (f Flags32) Unset13() Flags32 {
- const mask = Flags32(1) << 13
- return f & ^mask
-}
-
-// Get14 will fetch the flag bit value at index 14.
-func (f Flags32) Get14() bool {
- const mask = Flags32(1) << 14
- return (f&mask != 0)
-}
-
-// Set14 will set the flag bit value at index 14.
-func (f Flags32) Set14() Flags32 {
- const mask = Flags32(1) << 14
- return f | mask
-}
-
-// Unset14 will unset the flag bit value at index 14.
-func (f Flags32) Unset14() Flags32 {
- const mask = Flags32(1) << 14
- return f & ^mask
-}
-
-// Get15 will fetch the flag bit value at index 15.
-func (f Flags32) Get15() bool {
- const mask = Flags32(1) << 15
- return (f&mask != 0)
-}
-
-// Set15 will set the flag bit value at index 15.
-func (f Flags32) Set15() Flags32 {
- const mask = Flags32(1) << 15
- return f | mask
-}
-
-// Unset15 will unset the flag bit value at index 15.
-func (f Flags32) Unset15() Flags32 {
- const mask = Flags32(1) << 15
- return f & ^mask
-}
-
-// Get16 will fetch the flag bit value at index 16.
-func (f Flags32) Get16() bool {
- const mask = Flags32(1) << 16
- return (f&mask != 0)
-}
-
-// Set16 will set the flag bit value at index 16.
-func (f Flags32) Set16() Flags32 {
- const mask = Flags32(1) << 16
- return f | mask
-}
-
-// Unset16 will unset the flag bit value at index 16.
-func (f Flags32) Unset16() Flags32 {
- const mask = Flags32(1) << 16
- return f & ^mask
-}
-
-// Get17 will fetch the flag bit value at index 17.
-func (f Flags32) Get17() bool {
- const mask = Flags32(1) << 17
- return (f&mask != 0)
-}
-
-// Set17 will set the flag bit value at index 17.
-func (f Flags32) Set17() Flags32 {
- const mask = Flags32(1) << 17
- return f | mask
-}
-
-// Unset17 will unset the flag bit value at index 17.
-func (f Flags32) Unset17() Flags32 {
- const mask = Flags32(1) << 17
- return f & ^mask
-}
-
-// Get18 will fetch the flag bit value at index 18.
-func (f Flags32) Get18() bool {
- const mask = Flags32(1) << 18
- return (f&mask != 0)
-}
-
-// Set18 will set the flag bit value at index 18.
-func (f Flags32) Set18() Flags32 {
- const mask = Flags32(1) << 18
- return f | mask
-}
-
-// Unset18 will unset the flag bit value at index 18.
-func (f Flags32) Unset18() Flags32 {
- const mask = Flags32(1) << 18
- return f & ^mask
-}
-
-// Get19 will fetch the flag bit value at index 19.
-func (f Flags32) Get19() bool {
- const mask = Flags32(1) << 19
- return (f&mask != 0)
-}
-
-// Set19 will set the flag bit value at index 19.
-func (f Flags32) Set19() Flags32 {
- const mask = Flags32(1) << 19
- return f | mask
-}
-
-// Unset19 will unset the flag bit value at index 19.
-func (f Flags32) Unset19() Flags32 {
- const mask = Flags32(1) << 19
- return f & ^mask
-}
-
-// Get20 will fetch the flag bit value at index 20.
-func (f Flags32) Get20() bool {
- const mask = Flags32(1) << 20
- return (f&mask != 0)
-}
-
-// Set20 will set the flag bit value at index 20.
-func (f Flags32) Set20() Flags32 {
- const mask = Flags32(1) << 20
- return f | mask
-}
-
-// Unset20 will unset the flag bit value at index 20.
-func (f Flags32) Unset20() Flags32 {
- const mask = Flags32(1) << 20
- return f & ^mask
-}
-
-// Get21 will fetch the flag bit value at index 21.
-func (f Flags32) Get21() bool {
- const mask = Flags32(1) << 21
- return (f&mask != 0)
-}
-
-// Set21 will set the flag bit value at index 21.
-func (f Flags32) Set21() Flags32 {
- const mask = Flags32(1) << 21
- return f | mask
-}
-
-// Unset21 will unset the flag bit value at index 21.
-func (f Flags32) Unset21() Flags32 {
- const mask = Flags32(1) << 21
- return f & ^mask
-}
-
-// Get22 will fetch the flag bit value at index 22.
-func (f Flags32) Get22() bool {
- const mask = Flags32(1) << 22
- return (f&mask != 0)
-}
-
-// Set22 will set the flag bit value at index 22.
-func (f Flags32) Set22() Flags32 {
- const mask = Flags32(1) << 22
- return f | mask
-}
-
-// Unset22 will unset the flag bit value at index 22.
-func (f Flags32) Unset22() Flags32 {
- const mask = Flags32(1) << 22
- return f & ^mask
-}
-
-// Get23 will fetch the flag bit value at index 23.
-func (f Flags32) Get23() bool {
- const mask = Flags32(1) << 23
- return (f&mask != 0)
-}
-
-// Set23 will set the flag bit value at index 23.
-func (f Flags32) Set23() Flags32 {
- const mask = Flags32(1) << 23
- return f | mask
-}
-
-// Unset23 will unset the flag bit value at index 23.
-func (f Flags32) Unset23() Flags32 {
- const mask = Flags32(1) << 23
- return f & ^mask
-}
-
-// Get24 will fetch the flag bit value at index 24.
-func (f Flags32) Get24() bool {
- const mask = Flags32(1) << 24
- return (f&mask != 0)
-}
-
-// Set24 will set the flag bit value at index 24.
-func (f Flags32) Set24() Flags32 {
- const mask = Flags32(1) << 24
- return f | mask
-}
-
-// Unset24 will unset the flag bit value at index 24.
-func (f Flags32) Unset24() Flags32 {
- const mask = Flags32(1) << 24
- return f & ^mask
-}
-
-// Get25 will fetch the flag bit value at index 25.
-func (f Flags32) Get25() bool {
- const mask = Flags32(1) << 25
- return (f&mask != 0)
-}
-
-// Set25 will set the flag bit value at index 25.
-func (f Flags32) Set25() Flags32 {
- const mask = Flags32(1) << 25
- return f | mask
-}
-
-// Unset25 will unset the flag bit value at index 25.
-func (f Flags32) Unset25() Flags32 {
- const mask = Flags32(1) << 25
- return f & ^mask
-}
-
-// Get26 will fetch the flag bit value at index 26.
-func (f Flags32) Get26() bool {
- const mask = Flags32(1) << 26
- return (f&mask != 0)
-}
-
-// Set26 will set the flag bit value at index 26.
-func (f Flags32) Set26() Flags32 {
- const mask = Flags32(1) << 26
- return f | mask
-}
-
-// Unset26 will unset the flag bit value at index 26.
-func (f Flags32) Unset26() Flags32 {
- const mask = Flags32(1) << 26
- return f & ^mask
-}
-
-// Get27 will fetch the flag bit value at index 27.
-func (f Flags32) Get27() bool {
- const mask = Flags32(1) << 27
- return (f&mask != 0)
-}
-
-// Set27 will set the flag bit value at index 27.
-func (f Flags32) Set27() Flags32 {
- const mask = Flags32(1) << 27
- return f | mask
-}
-
-// Unset27 will unset the flag bit value at index 27.
-func (f Flags32) Unset27() Flags32 {
- const mask = Flags32(1) << 27
- return f & ^mask
-}
-
-// Get28 will fetch the flag bit value at index 28.
-func (f Flags32) Get28() bool {
- const mask = Flags32(1) << 28
- return (f&mask != 0)
-}
-
-// Set28 will set the flag bit value at index 28.
-func (f Flags32) Set28() Flags32 {
- const mask = Flags32(1) << 28
- return f | mask
-}
-
-// Unset28 will unset the flag bit value at index 28.
-func (f Flags32) Unset28() Flags32 {
- const mask = Flags32(1) << 28
- return f & ^mask
-}
-
-// Get29 will fetch the flag bit value at index 29.
-func (f Flags32) Get29() bool {
- const mask = Flags32(1) << 29
- return (f&mask != 0)
-}
-
-// Set29 will set the flag bit value at index 29.
-func (f Flags32) Set29() Flags32 {
- const mask = Flags32(1) << 29
- return f | mask
-}
-
-// Unset29 will unset the flag bit value at index 29.
-func (f Flags32) Unset29() Flags32 {
- const mask = Flags32(1) << 29
- return f & ^mask
-}
-
-// Get30 will fetch the flag bit value at index 30.
-func (f Flags32) Get30() bool {
- const mask = Flags32(1) << 30
- return (f&mask != 0)
-}
-
-// Set30 will set the flag bit value at index 30.
-func (f Flags32) Set30() Flags32 {
- const mask = Flags32(1) << 30
- return f | mask
-}
-
-// Unset30 will unset the flag bit value at index 30.
-func (f Flags32) Unset30() Flags32 {
- const mask = Flags32(1) << 30
- return f & ^mask
-}
-
-// Get31 will fetch the flag bit value at index 31.
-func (f Flags32) Get31() bool {
- const mask = Flags32(1) << 31
- return (f&mask != 0)
-}
-
-// Set31 will set the flag bit value at index 31.
-func (f Flags32) Set31() Flags32 {
- const mask = Flags32(1) << 31
- return f | mask
-}
-
-// Unset31 will unset the flag bit value at index 31.
-func (f Flags32) Unset31() Flags32 {
- const mask = Flags32(1) << 31
- return f & ^mask
-}
-
-// String returns a human readable representation of Flags32.
-func (f Flags32) String() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteByte('{')
-
- val = f.Get0()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get1()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get2()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get3()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get4()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get5()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get6()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get7()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get8()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get9()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get10()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get11()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get12()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get13()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get14()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get15()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get16()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get17()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get18()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get19()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get20()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get21()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get22()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get23()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get24()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get25()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get26()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get27()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get28()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get29()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get30()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get31()
- buf.WriteString(bool2str(val) + " ")
-
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-// GoString returns a more verbose human readable representation of Flags32.
-func (f Flags32) GoString() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteString("bitutil.Flags32{")
-
- val = f.Get0()
- buf.WriteString("0=" + bool2str(val) + " ")
-
- val = f.Get1()
- buf.WriteString("1=" + bool2str(val) + " ")
-
- val = f.Get2()
- buf.WriteString("2=" + bool2str(val) + " ")
-
- val = f.Get3()
- buf.WriteString("3=" + bool2str(val) + " ")
-
- val = f.Get4()
- buf.WriteString("4=" + bool2str(val) + " ")
-
- val = f.Get5()
- buf.WriteString("5=" + bool2str(val) + " ")
-
- val = f.Get6()
- buf.WriteString("6=" + bool2str(val) + " ")
-
- val = f.Get7()
- buf.WriteString("7=" + bool2str(val) + " ")
-
- val = f.Get8()
- buf.WriteString("8=" + bool2str(val) + " ")
-
- val = f.Get9()
- buf.WriteString("9=" + bool2str(val) + " ")
-
- val = f.Get10()
- buf.WriteString("10=" + bool2str(val) + " ")
-
- val = f.Get11()
- buf.WriteString("11=" + bool2str(val) + " ")
-
- val = f.Get12()
- buf.WriteString("12=" + bool2str(val) + " ")
-
- val = f.Get13()
- buf.WriteString("13=" + bool2str(val) + " ")
-
- val = f.Get14()
- buf.WriteString("14=" + bool2str(val) + " ")
-
- val = f.Get15()
- buf.WriteString("15=" + bool2str(val) + " ")
-
- val = f.Get16()
- buf.WriteString("16=" + bool2str(val) + " ")
-
- val = f.Get17()
- buf.WriteString("17=" + bool2str(val) + " ")
-
- val = f.Get18()
- buf.WriteString("18=" + bool2str(val) + " ")
-
- val = f.Get19()
- buf.WriteString("19=" + bool2str(val) + " ")
-
- val = f.Get20()
- buf.WriteString("20=" + bool2str(val) + " ")
-
- val = f.Get21()
- buf.WriteString("21=" + bool2str(val) + " ")
-
- val = f.Get22()
- buf.WriteString("22=" + bool2str(val) + " ")
-
- val = f.Get23()
- buf.WriteString("23=" + bool2str(val) + " ")
-
- val = f.Get24()
- buf.WriteString("24=" + bool2str(val) + " ")
-
- val = f.Get25()
- buf.WriteString("25=" + bool2str(val) + " ")
-
- val = f.Get26()
- buf.WriteString("26=" + bool2str(val) + " ")
-
- val = f.Get27()
- buf.WriteString("27=" + bool2str(val) + " ")
-
- val = f.Get28()
- buf.WriteString("28=" + bool2str(val) + " ")
-
- val = f.Get29()
- buf.WriteString("29=" + bool2str(val) + " ")
-
- val = f.Get30()
- buf.WriteString("30=" + bool2str(val) + " ")
-
- val = f.Get31()
- buf.WriteString("31=" + bool2str(val) + " ")
-
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-// Flags64 is a type-casted unsigned integer with helper
-// methods for easily managing up to 64 bit flags.
-type Flags64 uint64
-
-// Get will fetch the flag bit value at index 'bit'.
-func (f Flags64) Get(bit uint8) bool {
- mask := Flags64(1) << bit
- return (f&mask != 0)
-}
-
-// Set will set the flag bit value at index 'bit'.
-func (f Flags64) Set(bit uint8) Flags64 {
- mask := Flags64(1) << bit
- return f | mask
-}
-
-// Unset will unset the flag bit value at index 'bit'.
-func (f Flags64) Unset(bit uint8) Flags64 {
- mask := Flags64(1) << bit
- return f & ^mask
-}
-
-// Get0 will fetch the flag bit value at index 0.
-func (f Flags64) Get0() bool {
- const mask = Flags64(1) << 0
- return (f&mask != 0)
-}
-
-// Set0 will set the flag bit value at index 0.
-func (f Flags64) Set0() Flags64 {
- const mask = Flags64(1) << 0
- return f | mask
-}
-
-// Unset0 will unset the flag bit value at index 0.
-func (f Flags64) Unset0() Flags64 {
- const mask = Flags64(1) << 0
- return f & ^mask
-}
-
-// Get1 will fetch the flag bit value at index 1.
-func (f Flags64) Get1() bool {
- const mask = Flags64(1) << 1
- return (f&mask != 0)
-}
-
-// Set1 will set the flag bit value at index 1.
-func (f Flags64) Set1() Flags64 {
- const mask = Flags64(1) << 1
- return f | mask
-}
-
-// Unset1 will unset the flag bit value at index 1.
-func (f Flags64) Unset1() Flags64 {
- const mask = Flags64(1) << 1
- return f & ^mask
-}
-
-// Get2 will fetch the flag bit value at index 2.
-func (f Flags64) Get2() bool {
- const mask = Flags64(1) << 2
- return (f&mask != 0)
-}
-
-// Set2 will set the flag bit value at index 2.
-func (f Flags64) Set2() Flags64 {
- const mask = Flags64(1) << 2
- return f | mask
-}
-
-// Unset2 will unset the flag bit value at index 2.
-func (f Flags64) Unset2() Flags64 {
- const mask = Flags64(1) << 2
- return f & ^mask
-}
-
-// Get3 will fetch the flag bit value at index 3.
-func (f Flags64) Get3() bool {
- const mask = Flags64(1) << 3
- return (f&mask != 0)
-}
-
-// Set3 will set the flag bit value at index 3.
-func (f Flags64) Set3() Flags64 {
- const mask = Flags64(1) << 3
- return f | mask
-}
-
-// Unset3 will unset the flag bit value at index 3.
-func (f Flags64) Unset3() Flags64 {
- const mask = Flags64(1) << 3
- return f & ^mask
-}
-
-// Get4 will fetch the flag bit value at index 4.
-func (f Flags64) Get4() bool {
- const mask = Flags64(1) << 4
- return (f&mask != 0)
-}
-
-// Set4 will set the flag bit value at index 4.
-func (f Flags64) Set4() Flags64 {
- const mask = Flags64(1) << 4
- return f | mask
-}
-
-// Unset4 will unset the flag bit value at index 4.
-func (f Flags64) Unset4() Flags64 {
- const mask = Flags64(1) << 4
- return f & ^mask
-}
-
-// Get5 will fetch the flag bit value at index 5.
-func (f Flags64) Get5() bool {
- const mask = Flags64(1) << 5
- return (f&mask != 0)
-}
-
-// Set5 will set the flag bit value at index 5.
-func (f Flags64) Set5() Flags64 {
- const mask = Flags64(1) << 5
- return f | mask
-}
-
-// Unset5 will unset the flag bit value at index 5.
-func (f Flags64) Unset5() Flags64 {
- const mask = Flags64(1) << 5
- return f & ^mask
-}
-
-// Get6 will fetch the flag bit value at index 6.
-func (f Flags64) Get6() bool {
- const mask = Flags64(1) << 6
- return (f&mask != 0)
-}
-
-// Set6 will set the flag bit value at index 6.
-func (f Flags64) Set6() Flags64 {
- const mask = Flags64(1) << 6
- return f | mask
-}
-
-// Unset6 will unset the flag bit value at index 6.
-func (f Flags64) Unset6() Flags64 {
- const mask = Flags64(1) << 6
- return f & ^mask
-}
-
-// Get7 will fetch the flag bit value at index 7.
-func (f Flags64) Get7() bool {
- const mask = Flags64(1) << 7
- return (f&mask != 0)
-}
-
-// Set7 will set the flag bit value at index 7.
-func (f Flags64) Set7() Flags64 {
- const mask = Flags64(1) << 7
- return f | mask
-}
-
-// Unset7 will unset the flag bit value at index 7.
-func (f Flags64) Unset7() Flags64 {
- const mask = Flags64(1) << 7
- return f & ^mask
-}
-
-// Get8 will fetch the flag bit value at index 8.
-func (f Flags64) Get8() bool {
- const mask = Flags64(1) << 8
- return (f&mask != 0)
-}
-
-// Set8 will set the flag bit value at index 8.
-func (f Flags64) Set8() Flags64 {
- const mask = Flags64(1) << 8
- return f | mask
-}
-
-// Unset8 will unset the flag bit value at index 8.
-func (f Flags64) Unset8() Flags64 {
- const mask = Flags64(1) << 8
- return f & ^mask
-}
-
-// Get9 will fetch the flag bit value at index 9.
-func (f Flags64) Get9() bool {
- const mask = Flags64(1) << 9
- return (f&mask != 0)
-}
-
-// Set9 will set the flag bit value at index 9.
-func (f Flags64) Set9() Flags64 {
- const mask = Flags64(1) << 9
- return f | mask
-}
-
-// Unset9 will unset the flag bit value at index 9.
-func (f Flags64) Unset9() Flags64 {
- const mask = Flags64(1) << 9
- return f & ^mask
-}
-
-// Get10 will fetch the flag bit value at index 10.
-func (f Flags64) Get10() bool {
- const mask = Flags64(1) << 10
- return (f&mask != 0)
-}
-
-// Set10 will set the flag bit value at index 10.
-func (f Flags64) Set10() Flags64 {
- const mask = Flags64(1) << 10
- return f | mask
-}
-
-// Unset10 will unset the flag bit value at index 10.
-func (f Flags64) Unset10() Flags64 {
- const mask = Flags64(1) << 10
- return f & ^mask
-}
-
-// Get11 will fetch the flag bit value at index 11.
-func (f Flags64) Get11() bool {
- const mask = Flags64(1) << 11
- return (f&mask != 0)
-}
-
-// Set11 will set the flag bit value at index 11.
-func (f Flags64) Set11() Flags64 {
- const mask = Flags64(1) << 11
- return f | mask
-}
-
-// Unset11 will unset the flag bit value at index 11.
-func (f Flags64) Unset11() Flags64 {
- const mask = Flags64(1) << 11
- return f & ^mask
-}
-
-// Get12 will fetch the flag bit value at index 12.
-func (f Flags64) Get12() bool {
- const mask = Flags64(1) << 12
- return (f&mask != 0)
-}
-
-// Set12 will set the flag bit value at index 12.
-func (f Flags64) Set12() Flags64 {
- const mask = Flags64(1) << 12
- return f | mask
-}
-
-// Unset12 will unset the flag bit value at index 12.
-func (f Flags64) Unset12() Flags64 {
- const mask = Flags64(1) << 12
- return f & ^mask
-}
-
-// Get13 will fetch the flag bit value at index 13.
-func (f Flags64) Get13() bool {
- const mask = Flags64(1) << 13
- return (f&mask != 0)
-}
-
-// Set13 will set the flag bit value at index 13.
-func (f Flags64) Set13() Flags64 {
- const mask = Flags64(1) << 13
- return f | mask
-}
-
-// Unset13 will unset the flag bit value at index 13.
-func (f Flags64) Unset13() Flags64 {
- const mask = Flags64(1) << 13
- return f & ^mask
-}
-
-// Get14 will fetch the flag bit value at index 14.
-func (f Flags64) Get14() bool {
- const mask = Flags64(1) << 14
- return (f&mask != 0)
-}
-
-// Set14 will set the flag bit value at index 14.
-func (f Flags64) Set14() Flags64 {
- const mask = Flags64(1) << 14
- return f | mask
-}
-
-// Unset14 will unset the flag bit value at index 14.
-func (f Flags64) Unset14() Flags64 {
- const mask = Flags64(1) << 14
- return f & ^mask
-}
-
-// Get15 will fetch the flag bit value at index 15.
-func (f Flags64) Get15() bool {
- const mask = Flags64(1) << 15
- return (f&mask != 0)
-}
-
-// Set15 will set the flag bit value at index 15.
-func (f Flags64) Set15() Flags64 {
- const mask = Flags64(1) << 15
- return f | mask
-}
-
-// Unset15 will unset the flag bit value at index 15.
-func (f Flags64) Unset15() Flags64 {
- const mask = Flags64(1) << 15
- return f & ^mask
-}
-
-// Get16 will fetch the flag bit value at index 16.
-func (f Flags64) Get16() bool {
- const mask = Flags64(1) << 16
- return (f&mask != 0)
-}
-
-// Set16 will set the flag bit value at index 16.
-func (f Flags64) Set16() Flags64 {
- const mask = Flags64(1) << 16
- return f | mask
-}
-
-// Unset16 will unset the flag bit value at index 16.
-func (f Flags64) Unset16() Flags64 {
- const mask = Flags64(1) << 16
- return f & ^mask
-}
-
-// Get17 will fetch the flag bit value at index 17.
-func (f Flags64) Get17() bool {
- const mask = Flags64(1) << 17
- return (f&mask != 0)
-}
-
-// Set17 will set the flag bit value at index 17.
-func (f Flags64) Set17() Flags64 {
- const mask = Flags64(1) << 17
- return f | mask
-}
-
-// Unset17 will unset the flag bit value at index 17.
-func (f Flags64) Unset17() Flags64 {
- const mask = Flags64(1) << 17
- return f & ^mask
-}
-
-// Get18 will fetch the flag bit value at index 18.
-func (f Flags64) Get18() bool {
- const mask = Flags64(1) << 18
- return (f&mask != 0)
-}
-
-// Set18 will set the flag bit value at index 18.
-func (f Flags64) Set18() Flags64 {
- const mask = Flags64(1) << 18
- return f | mask
-}
-
-// Unset18 will unset the flag bit value at index 18.
-func (f Flags64) Unset18() Flags64 {
- const mask = Flags64(1) << 18
- return f & ^mask
-}
-
-// Get19 will fetch the flag bit value at index 19.
-func (f Flags64) Get19() bool {
- const mask = Flags64(1) << 19
- return (f&mask != 0)
-}
-
-// Set19 will set the flag bit value at index 19.
-func (f Flags64) Set19() Flags64 {
- const mask = Flags64(1) << 19
- return f | mask
-}
-
-// Unset19 will unset the flag bit value at index 19.
-func (f Flags64) Unset19() Flags64 {
- const mask = Flags64(1) << 19
- return f & ^mask
-}
-
-// Get20 will fetch the flag bit value at index 20.
-func (f Flags64) Get20() bool {
- const mask = Flags64(1) << 20
- return (f&mask != 0)
-}
-
-// Set20 will set the flag bit value at index 20.
-func (f Flags64) Set20() Flags64 {
- const mask = Flags64(1) << 20
- return f | mask
-}
-
-// Unset20 will unset the flag bit value at index 20.
-func (f Flags64) Unset20() Flags64 {
- const mask = Flags64(1) << 20
- return f & ^mask
-}
-
-// Get21 will fetch the flag bit value at index 21.
-func (f Flags64) Get21() bool {
- const mask = Flags64(1) << 21
- return (f&mask != 0)
-}
-
-// Set21 will set the flag bit value at index 21.
-func (f Flags64) Set21() Flags64 {
- const mask = Flags64(1) << 21
- return f | mask
-}
-
-// Unset21 will unset the flag bit value at index 21.
-func (f Flags64) Unset21() Flags64 {
- const mask = Flags64(1) << 21
- return f & ^mask
-}
-
-// Get22 will fetch the flag bit value at index 22.
-func (f Flags64) Get22() bool {
- const mask = Flags64(1) << 22
- return (f&mask != 0)
-}
-
-// Set22 will set the flag bit value at index 22.
-func (f Flags64) Set22() Flags64 {
- const mask = Flags64(1) << 22
- return f | mask
-}
-
-// Unset22 will unset the flag bit value at index 22.
-func (f Flags64) Unset22() Flags64 {
- const mask = Flags64(1) << 22
- return f & ^mask
-}
-
-// Get23 will fetch the flag bit value at index 23.
-func (f Flags64) Get23() bool {
- const mask = Flags64(1) << 23
- return (f&mask != 0)
-}
-
-// Set23 will set the flag bit value at index 23.
-func (f Flags64) Set23() Flags64 {
- const mask = Flags64(1) << 23
- return f | mask
-}
-
-// Unset23 will unset the flag bit value at index 23.
-func (f Flags64) Unset23() Flags64 {
- const mask = Flags64(1) << 23
- return f & ^mask
-}
-
-// Get24 will fetch the flag bit value at index 24.
-func (f Flags64) Get24() bool {
- const mask = Flags64(1) << 24
- return (f&mask != 0)
-}
-
-// Set24 will set the flag bit value at index 24.
-func (f Flags64) Set24() Flags64 {
- const mask = Flags64(1) << 24
- return f | mask
-}
-
-// Unset24 will unset the flag bit value at index 24.
-func (f Flags64) Unset24() Flags64 {
- const mask = Flags64(1) << 24
- return f & ^mask
-}
-
-// Get25 will fetch the flag bit value at index 25.
-func (f Flags64) Get25() bool {
- const mask = Flags64(1) << 25
- return (f&mask != 0)
-}
-
-// Set25 will set the flag bit value at index 25.
-func (f Flags64) Set25() Flags64 {
- const mask = Flags64(1) << 25
- return f | mask
-}
-
-// Unset25 will unset the flag bit value at index 25.
-func (f Flags64) Unset25() Flags64 {
- const mask = Flags64(1) << 25
- return f & ^mask
-}
-
-// Get26 will fetch the flag bit value at index 26.
-func (f Flags64) Get26() bool {
- const mask = Flags64(1) << 26
- return (f&mask != 0)
-}
-
-// Set26 will set the flag bit value at index 26.
-func (f Flags64) Set26() Flags64 {
- const mask = Flags64(1) << 26
- return f | mask
-}
-
-// Unset26 will unset the flag bit value at index 26.
-func (f Flags64) Unset26() Flags64 {
- const mask = Flags64(1) << 26
- return f & ^mask
-}
-
-// Get27 will fetch the flag bit value at index 27.
-func (f Flags64) Get27() bool {
- const mask = Flags64(1) << 27
- return (f&mask != 0)
-}
-
-// Set27 will set the flag bit value at index 27.
-func (f Flags64) Set27() Flags64 {
- const mask = Flags64(1) << 27
- return f | mask
-}
-
-// Unset27 will unset the flag bit value at index 27.
-func (f Flags64) Unset27() Flags64 {
- const mask = Flags64(1) << 27
- return f & ^mask
-}
-
-// Get28 will fetch the flag bit value at index 28.
-func (f Flags64) Get28() bool {
- const mask = Flags64(1) << 28
- return (f&mask != 0)
-}
-
-// Set28 will set the flag bit value at index 28.
-func (f Flags64) Set28() Flags64 {
- const mask = Flags64(1) << 28
- return f | mask
-}
-
-// Unset28 will unset the flag bit value at index 28.
-func (f Flags64) Unset28() Flags64 {
- const mask = Flags64(1) << 28
- return f & ^mask
-}
-
-// Get29 will fetch the flag bit value at index 29.
-func (f Flags64) Get29() bool {
- const mask = Flags64(1) << 29
- return (f&mask != 0)
-}
-
-// Set29 will set the flag bit value at index 29.
-func (f Flags64) Set29() Flags64 {
- const mask = Flags64(1) << 29
- return f | mask
-}
-
-// Unset29 will unset the flag bit value at index 29.
-func (f Flags64) Unset29() Flags64 {
- const mask = Flags64(1) << 29
- return f & ^mask
-}
-
-// Get30 will fetch the flag bit value at index 30.
-func (f Flags64) Get30() bool {
- const mask = Flags64(1) << 30
- return (f&mask != 0)
-}
-
-// Set30 will set the flag bit value at index 30.
-func (f Flags64) Set30() Flags64 {
- const mask = Flags64(1) << 30
- return f | mask
-}
-
-// Unset30 will unset the flag bit value at index 30.
-func (f Flags64) Unset30() Flags64 {
- const mask = Flags64(1) << 30
- return f & ^mask
-}
-
-// Get31 will fetch the flag bit value at index 31.
-func (f Flags64) Get31() bool {
- const mask = Flags64(1) << 31
- return (f&mask != 0)
-}
-
-// Set31 will set the flag bit value at index 31.
-func (f Flags64) Set31() Flags64 {
- const mask = Flags64(1) << 31
- return f | mask
-}
-
-// Unset31 will unset the flag bit value at index 31.
-func (f Flags64) Unset31() Flags64 {
- const mask = Flags64(1) << 31
- return f & ^mask
-}
-
-// Get32 will fetch the flag bit value at index 32.
-func (f Flags64) Get32() bool {
- const mask = Flags64(1) << 32
- return (f&mask != 0)
-}
-
-// Set32 will set the flag bit value at index 32.
-func (f Flags64) Set32() Flags64 {
- const mask = Flags64(1) << 32
- return f | mask
-}
-
-// Unset32 will unset the flag bit value at index 32.
-func (f Flags64) Unset32() Flags64 {
- const mask = Flags64(1) << 32
- return f & ^mask
-}
-
-// Get33 will fetch the flag bit value at index 33.
-func (f Flags64) Get33() bool {
- const mask = Flags64(1) << 33
- return (f&mask != 0)
-}
-
-// Set33 will set the flag bit value at index 33.
-func (f Flags64) Set33() Flags64 {
- const mask = Flags64(1) << 33
- return f | mask
-}
-
-// Unset33 will unset the flag bit value at index 33.
-func (f Flags64) Unset33() Flags64 {
- const mask = Flags64(1) << 33
- return f & ^mask
-}
-
-// Get34 will fetch the flag bit value at index 34.
-func (f Flags64) Get34() bool {
- const mask = Flags64(1) << 34
- return (f&mask != 0)
-}
-
-// Set34 will set the flag bit value at index 34.
-func (f Flags64) Set34() Flags64 {
- const mask = Flags64(1) << 34
- return f | mask
-}
-
-// Unset34 will unset the flag bit value at index 34.
-func (f Flags64) Unset34() Flags64 {
- const mask = Flags64(1) << 34
- return f & ^mask
-}
-
-// Get35 will fetch the flag bit value at index 35.
-func (f Flags64) Get35() bool {
- const mask = Flags64(1) << 35
- return (f&mask != 0)
-}
-
-// Set35 will set the flag bit value at index 35.
-func (f Flags64) Set35() Flags64 {
- const mask = Flags64(1) << 35
- return f | mask
-}
-
-// Unset35 will unset the flag bit value at index 35.
-func (f Flags64) Unset35() Flags64 {
- const mask = Flags64(1) << 35
- return f & ^mask
-}
-
-// Get36 will fetch the flag bit value at index 36.
-func (f Flags64) Get36() bool {
- const mask = Flags64(1) << 36
- return (f&mask != 0)
-}
-
-// Set36 will set the flag bit value at index 36.
-func (f Flags64) Set36() Flags64 {
- const mask = Flags64(1) << 36
- return f | mask
-}
-
-// Unset36 will unset the flag bit value at index 36.
-func (f Flags64) Unset36() Flags64 {
- const mask = Flags64(1) << 36
- return f & ^mask
-}
-
-// Get37 will fetch the flag bit value at index 37.
-func (f Flags64) Get37() bool {
- const mask = Flags64(1) << 37
- return (f&mask != 0)
-}
-
-// Set37 will set the flag bit value at index 37.
-func (f Flags64) Set37() Flags64 {
- const mask = Flags64(1) << 37
- return f | mask
-}
-
-// Unset37 will unset the flag bit value at index 37.
-func (f Flags64) Unset37() Flags64 {
- const mask = Flags64(1) << 37
- return f & ^mask
-}
-
-// Get38 will fetch the flag bit value at index 38.
-func (f Flags64) Get38() bool {
- const mask = Flags64(1) << 38
- return (f&mask != 0)
-}
-
-// Set38 will set the flag bit value at index 38.
-func (f Flags64) Set38() Flags64 {
- const mask = Flags64(1) << 38
- return f | mask
-}
-
-// Unset38 will unset the flag bit value at index 38.
-func (f Flags64) Unset38() Flags64 {
- const mask = Flags64(1) << 38
- return f & ^mask
-}
-
-// Get39 will fetch the flag bit value at index 39.
-func (f Flags64) Get39() bool {
- const mask = Flags64(1) << 39
- return (f&mask != 0)
-}
-
-// Set39 will set the flag bit value at index 39.
-func (f Flags64) Set39() Flags64 {
- const mask = Flags64(1) << 39
- return f | mask
-}
-
-// Unset39 will unset the flag bit value at index 39.
-func (f Flags64) Unset39() Flags64 {
- const mask = Flags64(1) << 39
- return f & ^mask
-}
-
-// Get40 will fetch the flag bit value at index 40.
-func (f Flags64) Get40() bool {
- const mask = Flags64(1) << 40
- return (f&mask != 0)
-}
-
-// Set40 will set the flag bit value at index 40.
-func (f Flags64) Set40() Flags64 {
- const mask = Flags64(1) << 40
- return f | mask
-}
-
-// Unset40 will unset the flag bit value at index 40.
-func (f Flags64) Unset40() Flags64 {
- const mask = Flags64(1) << 40
- return f & ^mask
-}
-
-// Get41 will fetch the flag bit value at index 41.
-func (f Flags64) Get41() bool {
- const mask = Flags64(1) << 41
- return (f&mask != 0)
-}
-
-// Set41 will set the flag bit value at index 41.
-func (f Flags64) Set41() Flags64 {
- const mask = Flags64(1) << 41
- return f | mask
-}
-
-// Unset41 will unset the flag bit value at index 41.
-func (f Flags64) Unset41() Flags64 {
- const mask = Flags64(1) << 41
- return f & ^mask
-}
-
-// Get42 will fetch the flag bit value at index 42.
-func (f Flags64) Get42() bool {
- const mask = Flags64(1) << 42
- return (f&mask != 0)
-}
-
-// Set42 will set the flag bit value at index 42.
-func (f Flags64) Set42() Flags64 {
- const mask = Flags64(1) << 42
- return f | mask
-}
-
-// Unset42 will unset the flag bit value at index 42.
-func (f Flags64) Unset42() Flags64 {
- const mask = Flags64(1) << 42
- return f & ^mask
-}
-
-// Get43 will fetch the flag bit value at index 43.
-func (f Flags64) Get43() bool {
- const mask = Flags64(1) << 43
- return (f&mask != 0)
-}
-
-// Set43 will set the flag bit value at index 43.
-func (f Flags64) Set43() Flags64 {
- const mask = Flags64(1) << 43
- return f | mask
-}
-
-// Unset43 will unset the flag bit value at index 43.
-func (f Flags64) Unset43() Flags64 {
- const mask = Flags64(1) << 43
- return f & ^mask
-}
-
-// Get44 will fetch the flag bit value at index 44.
-func (f Flags64) Get44() bool {
- const mask = Flags64(1) << 44
- return (f&mask != 0)
-}
-
-// Set44 will set the flag bit value at index 44.
-func (f Flags64) Set44() Flags64 {
- const mask = Flags64(1) << 44
- return f | mask
-}
-
-// Unset44 will unset the flag bit value at index 44.
-func (f Flags64) Unset44() Flags64 {
- const mask = Flags64(1) << 44
- return f & ^mask
-}
-
-// Get45 will fetch the flag bit value at index 45.
-func (f Flags64) Get45() bool {
- const mask = Flags64(1) << 45
- return (f&mask != 0)
-}
-
-// Set45 will set the flag bit value at index 45.
-func (f Flags64) Set45() Flags64 {
- const mask = Flags64(1) << 45
- return f | mask
-}
-
-// Unset45 will unset the flag bit value at index 45.
-func (f Flags64) Unset45() Flags64 {
- const mask = Flags64(1) << 45
- return f & ^mask
-}
-
-// Get46 will fetch the flag bit value at index 46.
-func (f Flags64) Get46() bool {
- const mask = Flags64(1) << 46
- return (f&mask != 0)
-}
-
-// Set46 will set the flag bit value at index 46.
-func (f Flags64) Set46() Flags64 {
- const mask = Flags64(1) << 46
- return f | mask
-}
-
-// Unset46 will unset the flag bit value at index 46.
-func (f Flags64) Unset46() Flags64 {
- const mask = Flags64(1) << 46
- return f & ^mask
-}
-
-// Get47 will fetch the flag bit value at index 47.
-func (f Flags64) Get47() bool {
- const mask = Flags64(1) << 47
- return (f&mask != 0)
-}
-
-// Set47 will set the flag bit value at index 47.
-func (f Flags64) Set47() Flags64 {
- const mask = Flags64(1) << 47
- return f | mask
-}
-
-// Unset47 will unset the flag bit value at index 47.
-func (f Flags64) Unset47() Flags64 {
- const mask = Flags64(1) << 47
- return f & ^mask
-}
-
-// Get48 will fetch the flag bit value at index 48.
-func (f Flags64) Get48() bool {
- const mask = Flags64(1) << 48
- return (f&mask != 0)
-}
-
-// Set48 will set the flag bit value at index 48.
-func (f Flags64) Set48() Flags64 {
- const mask = Flags64(1) << 48
- return f | mask
-}
-
-// Unset48 will unset the flag bit value at index 48.
-func (f Flags64) Unset48() Flags64 {
- const mask = Flags64(1) << 48
- return f & ^mask
-}
-
-// Get49 will fetch the flag bit value at index 49.
-func (f Flags64) Get49() bool {
- const mask = Flags64(1) << 49
- return (f&mask != 0)
-}
-
-// Set49 will set the flag bit value at index 49.
-func (f Flags64) Set49() Flags64 {
- const mask = Flags64(1) << 49
- return f | mask
-}
-
-// Unset49 will unset the flag bit value at index 49.
-func (f Flags64) Unset49() Flags64 {
- const mask = Flags64(1) << 49
- return f & ^mask
-}
-
-// Get50 will fetch the flag bit value at index 50.
-func (f Flags64) Get50() bool {
- const mask = Flags64(1) << 50
- return (f&mask != 0)
-}
-
-// Set50 will set the flag bit value at index 50.
-func (f Flags64) Set50() Flags64 {
- const mask = Flags64(1) << 50
- return f | mask
-}
-
-// Unset50 will unset the flag bit value at index 50.
-func (f Flags64) Unset50() Flags64 {
- const mask = Flags64(1) << 50
- return f & ^mask
-}
-
-// Get51 will fetch the flag bit value at index 51.
-func (f Flags64) Get51() bool {
- const mask = Flags64(1) << 51
- return (f&mask != 0)
-}
-
-// Set51 will set the flag bit value at index 51.
-func (f Flags64) Set51() Flags64 {
- const mask = Flags64(1) << 51
- return f | mask
-}
-
-// Unset51 will unset the flag bit value at index 51.
-func (f Flags64) Unset51() Flags64 {
- const mask = Flags64(1) << 51
- return f & ^mask
-}
-
-// Get52 will fetch the flag bit value at index 52.
-func (f Flags64) Get52() bool {
- const mask = Flags64(1) << 52
- return (f&mask != 0)
-}
-
-// Set52 will set the flag bit value at index 52.
-func (f Flags64) Set52() Flags64 {
- const mask = Flags64(1) << 52
- return f | mask
-}
-
-// Unset52 will unset the flag bit value at index 52.
-func (f Flags64) Unset52() Flags64 {
- const mask = Flags64(1) << 52
- return f & ^mask
-}
-
-// Get53 will fetch the flag bit value at index 53.
-func (f Flags64) Get53() bool {
- const mask = Flags64(1) << 53
- return (f&mask != 0)
-}
-
-// Set53 will set the flag bit value at index 53.
-func (f Flags64) Set53() Flags64 {
- const mask = Flags64(1) << 53
- return f | mask
-}
-
-// Unset53 will unset the flag bit value at index 53.
-func (f Flags64) Unset53() Flags64 {
- const mask = Flags64(1) << 53
- return f & ^mask
-}
-
-// Get54 will fetch the flag bit value at index 54.
-func (f Flags64) Get54() bool {
- const mask = Flags64(1) << 54
- return (f&mask != 0)
-}
-
-// Set54 will set the flag bit value at index 54.
-func (f Flags64) Set54() Flags64 {
- const mask = Flags64(1) << 54
- return f | mask
-}
-
-// Unset54 will unset the flag bit value at index 54.
-func (f Flags64) Unset54() Flags64 {
- const mask = Flags64(1) << 54
- return f & ^mask
-}
-
-// Get55 will fetch the flag bit value at index 55.
-func (f Flags64) Get55() bool {
- const mask = Flags64(1) << 55
- return (f&mask != 0)
-}
-
-// Set55 will set the flag bit value at index 55.
-func (f Flags64) Set55() Flags64 {
- const mask = Flags64(1) << 55
- return f | mask
-}
-
-// Unset55 will unset the flag bit value at index 55.
-func (f Flags64) Unset55() Flags64 {
- const mask = Flags64(1) << 55
- return f & ^mask
-}
-
-// Get56 will fetch the flag bit value at index 56.
-func (f Flags64) Get56() bool {
- const mask = Flags64(1) << 56
- return (f&mask != 0)
-}
-
-// Set56 will set the flag bit value at index 56.
-func (f Flags64) Set56() Flags64 {
- const mask = Flags64(1) << 56
- return f | mask
-}
-
-// Unset56 will unset the flag bit value at index 56.
-func (f Flags64) Unset56() Flags64 {
- const mask = Flags64(1) << 56
- return f & ^mask
-}
-
-// Get57 will fetch the flag bit value at index 57.
-func (f Flags64) Get57() bool {
- const mask = Flags64(1) << 57
- return (f&mask != 0)
-}
-
-// Set57 will set the flag bit value at index 57.
-func (f Flags64) Set57() Flags64 {
- const mask = Flags64(1) << 57
- return f | mask
-}
-
-// Unset57 will unset the flag bit value at index 57.
-func (f Flags64) Unset57() Flags64 {
- const mask = Flags64(1) << 57
- return f & ^mask
-}
-
-// Get58 will fetch the flag bit value at index 58.
-func (f Flags64) Get58() bool {
- const mask = Flags64(1) << 58
- return (f&mask != 0)
-}
-
-// Set58 will set the flag bit value at index 58.
-func (f Flags64) Set58() Flags64 {
- const mask = Flags64(1) << 58
- return f | mask
-}
-
-// Unset58 will unset the flag bit value at index 58.
-func (f Flags64) Unset58() Flags64 {
- const mask = Flags64(1) << 58
- return f & ^mask
-}
-
-// Get59 will fetch the flag bit value at index 59.
-func (f Flags64) Get59() bool {
- const mask = Flags64(1) << 59
- return (f&mask != 0)
-}
-
-// Set59 will set the flag bit value at index 59.
-func (f Flags64) Set59() Flags64 {
- const mask = Flags64(1) << 59
- return f | mask
-}
-
-// Unset59 will unset the flag bit value at index 59.
-func (f Flags64) Unset59() Flags64 {
- const mask = Flags64(1) << 59
- return f & ^mask
-}
-
-// Get60 will fetch the flag bit value at index 60.
-func (f Flags64) Get60() bool {
- const mask = Flags64(1) << 60
- return (f&mask != 0)
-}
-
-// Set60 will set the flag bit value at index 60.
-func (f Flags64) Set60() Flags64 {
- const mask = Flags64(1) << 60
- return f | mask
-}
-
-// Unset60 will unset the flag bit value at index 60.
-func (f Flags64) Unset60() Flags64 {
- const mask = Flags64(1) << 60
- return f & ^mask
-}
-
-// Get61 will fetch the flag bit value at index 61.
-func (f Flags64) Get61() bool {
- const mask = Flags64(1) << 61
- return (f&mask != 0)
-}
-
-// Set61 will set the flag bit value at index 61.
-func (f Flags64) Set61() Flags64 {
- const mask = Flags64(1) << 61
- return f | mask
-}
-
-// Unset61 will unset the flag bit value at index 61.
-func (f Flags64) Unset61() Flags64 {
- const mask = Flags64(1) << 61
- return f & ^mask
-}
-
-// Get62 will fetch the flag bit value at index 62.
-func (f Flags64) Get62() bool {
- const mask = Flags64(1) << 62
- return (f&mask != 0)
-}
-
-// Set62 will set the flag bit value at index 62.
-func (f Flags64) Set62() Flags64 {
- const mask = Flags64(1) << 62
- return f | mask
-}
-
-// Unset62 will unset the flag bit value at index 62.
-func (f Flags64) Unset62() Flags64 {
- const mask = Flags64(1) << 62
- return f & ^mask
-}
-
-// Get63 will fetch the flag bit value at index 63.
-func (f Flags64) Get63() bool {
- const mask = Flags64(1) << 63
- return (f&mask != 0)
-}
-
-// Set63 will set the flag bit value at index 63.
-func (f Flags64) Set63() Flags64 {
- const mask = Flags64(1) << 63
- return f | mask
-}
-
-// Unset63 will unset the flag bit value at index 63.
-func (f Flags64) Unset63() Flags64 {
- const mask = Flags64(1) << 63
- return f & ^mask
-}
-
-// String returns a human readable representation of Flags64.
-func (f Flags64) String() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteByte('{')
-
- val = f.Get0()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get1()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get2()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get3()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get4()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get5()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get6()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get7()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get8()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get9()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get10()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get11()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get12()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get13()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get14()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get15()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get16()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get17()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get18()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get19()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get20()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get21()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get22()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get23()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get24()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get25()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get26()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get27()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get28()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get29()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get30()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get31()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get32()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get33()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get34()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get35()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get36()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get37()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get38()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get39()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get40()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get41()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get42()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get43()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get44()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get45()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get46()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get47()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get48()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get49()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get50()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get51()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get52()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get53()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get54()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get55()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get56()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get57()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get58()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get59()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get60()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get61()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get62()
- buf.WriteString(bool2str(val) + " ")
-
- val = f.Get63()
- buf.WriteString(bool2str(val) + " ")
-
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-// GoString returns a more verbose human readable representation of Flags64.
-func (f Flags64) GoString() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteString("bitutil.Flags64{")
-
- val = f.Get0()
- buf.WriteString("0=" + bool2str(val) + " ")
-
- val = f.Get1()
- buf.WriteString("1=" + bool2str(val) + " ")
-
- val = f.Get2()
- buf.WriteString("2=" + bool2str(val) + " ")
-
- val = f.Get3()
- buf.WriteString("3=" + bool2str(val) + " ")
-
- val = f.Get4()
- buf.WriteString("4=" + bool2str(val) + " ")
-
- val = f.Get5()
- buf.WriteString("5=" + bool2str(val) + " ")
-
- val = f.Get6()
- buf.WriteString("6=" + bool2str(val) + " ")
-
- val = f.Get7()
- buf.WriteString("7=" + bool2str(val) + " ")
-
- val = f.Get8()
- buf.WriteString("8=" + bool2str(val) + " ")
-
- val = f.Get9()
- buf.WriteString("9=" + bool2str(val) + " ")
-
- val = f.Get10()
- buf.WriteString("10=" + bool2str(val) + " ")
-
- val = f.Get11()
- buf.WriteString("11=" + bool2str(val) + " ")
-
- val = f.Get12()
- buf.WriteString("12=" + bool2str(val) + " ")
-
- val = f.Get13()
- buf.WriteString("13=" + bool2str(val) + " ")
-
- val = f.Get14()
- buf.WriteString("14=" + bool2str(val) + " ")
-
- val = f.Get15()
- buf.WriteString("15=" + bool2str(val) + " ")
-
- val = f.Get16()
- buf.WriteString("16=" + bool2str(val) + " ")
-
- val = f.Get17()
- buf.WriteString("17=" + bool2str(val) + " ")
-
- val = f.Get18()
- buf.WriteString("18=" + bool2str(val) + " ")
-
- val = f.Get19()
- buf.WriteString("19=" + bool2str(val) + " ")
-
- val = f.Get20()
- buf.WriteString("20=" + bool2str(val) + " ")
-
- val = f.Get21()
- buf.WriteString("21=" + bool2str(val) + " ")
-
- val = f.Get22()
- buf.WriteString("22=" + bool2str(val) + " ")
-
- val = f.Get23()
- buf.WriteString("23=" + bool2str(val) + " ")
-
- val = f.Get24()
- buf.WriteString("24=" + bool2str(val) + " ")
-
- val = f.Get25()
- buf.WriteString("25=" + bool2str(val) + " ")
-
- val = f.Get26()
- buf.WriteString("26=" + bool2str(val) + " ")
-
- val = f.Get27()
- buf.WriteString("27=" + bool2str(val) + " ")
-
- val = f.Get28()
- buf.WriteString("28=" + bool2str(val) + " ")
-
- val = f.Get29()
- buf.WriteString("29=" + bool2str(val) + " ")
-
- val = f.Get30()
- buf.WriteString("30=" + bool2str(val) + " ")
-
- val = f.Get31()
- buf.WriteString("31=" + bool2str(val) + " ")
-
- val = f.Get32()
- buf.WriteString("32=" + bool2str(val) + " ")
-
- val = f.Get33()
- buf.WriteString("33=" + bool2str(val) + " ")
-
- val = f.Get34()
- buf.WriteString("34=" + bool2str(val) + " ")
-
- val = f.Get35()
- buf.WriteString("35=" + bool2str(val) + " ")
-
- val = f.Get36()
- buf.WriteString("36=" + bool2str(val) + " ")
-
- val = f.Get37()
- buf.WriteString("37=" + bool2str(val) + " ")
-
- val = f.Get38()
- buf.WriteString("38=" + bool2str(val) + " ")
-
- val = f.Get39()
- buf.WriteString("39=" + bool2str(val) + " ")
-
- val = f.Get40()
- buf.WriteString("40=" + bool2str(val) + " ")
-
- val = f.Get41()
- buf.WriteString("41=" + bool2str(val) + " ")
-
- val = f.Get42()
- buf.WriteString("42=" + bool2str(val) + " ")
-
- val = f.Get43()
- buf.WriteString("43=" + bool2str(val) + " ")
-
- val = f.Get44()
- buf.WriteString("44=" + bool2str(val) + " ")
-
- val = f.Get45()
- buf.WriteString("45=" + bool2str(val) + " ")
-
- val = f.Get46()
- buf.WriteString("46=" + bool2str(val) + " ")
-
- val = f.Get47()
- buf.WriteString("47=" + bool2str(val) + " ")
-
- val = f.Get48()
- buf.WriteString("48=" + bool2str(val) + " ")
-
- val = f.Get49()
- buf.WriteString("49=" + bool2str(val) + " ")
-
- val = f.Get50()
- buf.WriteString("50=" + bool2str(val) + " ")
-
- val = f.Get51()
- buf.WriteString("51=" + bool2str(val) + " ")
-
- val = f.Get52()
- buf.WriteString("52=" + bool2str(val) + " ")
-
- val = f.Get53()
- buf.WriteString("53=" + bool2str(val) + " ")
-
- val = f.Get54()
- buf.WriteString("54=" + bool2str(val) + " ")
-
- val = f.Get55()
- buf.WriteString("55=" + bool2str(val) + " ")
-
- val = f.Get56()
- buf.WriteString("56=" + bool2str(val) + " ")
-
- val = f.Get57()
- buf.WriteString("57=" + bool2str(val) + " ")
-
- val = f.Get58()
- buf.WriteString("58=" + bool2str(val) + " ")
-
- val = f.Get59()
- buf.WriteString("59=" + bool2str(val) + " ")
-
- val = f.Get60()
- buf.WriteString("60=" + bool2str(val) + " ")
-
- val = f.Get61()
- buf.WriteString("61=" + bool2str(val) + " ")
-
- val = f.Get62()
- buf.WriteString("62=" + bool2str(val) + " ")
-
- val = f.Get63()
- buf.WriteString("63=" + bool2str(val) + " ")
-
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-func bool2str(b bool) string {
- if b {
- return "true"
- }
- return "false"
-}
diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag.tpl b/vendor/codeberg.org/gruf/go-bitutil/flag.tpl
deleted file mode 100644
index 89f881930..000000000
--- a/vendor/codeberg.org/gruf/go-bitutil/flag.tpl
+++ /dev/null
@@ -1,94 +0,0 @@
-package bitutil
-
-import (
- "strings"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-{{ range $idx, $size := . }}
-
-// Flags{{ $size.Size }} is a type-casted unsigned integer with helper
-// methods for easily managing up to {{ $size.Size }} bit flags.
-type Flags{{ $size.Size }} uint{{ $size.Size }}
-
-// Get will fetch the flag bit value at index 'bit'.
-func (f Flags{{ $size.Size }}) Get(bit uint8) bool {
- mask := Flags{{ $size.Size }}(1) << bit
- return (f & mask != 0)
-}
-
-// Set will set the flag bit value at index 'bit'.
-func (f Flags{{ $size.Size }}) Set(bit uint8) Flags{{ $size.Size }} {
- mask := Flags{{ $size.Size }}(1) << bit
- return f | mask
-}
-
-// Unset will unset the flag bit value at index 'bit'.
-func (f Flags{{ $size.Size }}) Unset(bit uint8) Flags{{ $size.Size }} {
- mask := Flags{{ $size.Size }}(1) << bit
- return f & ^mask
-}
-
-{{ range $idx := $size.Bits }}
-
-// Get{{ $idx }} will fetch the flag bit value at index {{ $idx }}.
-func (f Flags{{ $size.Size }}) Get{{ $idx }}() bool {
- const mask = Flags{{ $size.Size }}(1) << {{ $idx }}
- return (f & mask != 0)
-}
-
-// Set{{ $idx }} will set the flag bit value at index {{ $idx }}.
-func (f Flags{{ $size.Size }}) Set{{ $idx }}() Flags{{ $size.Size }} {
- const mask = Flags{{ $size.Size }}(1) << {{ $idx }}
- return f | mask
-}
-
-// Unset{{ $idx }} will unset the flag bit value at index {{ $idx }}.
-func (f Flags{{ $size.Size }}) Unset{{ $idx }}() Flags{{ $size.Size }} {
- const mask = Flags{{ $size.Size }}(1) << {{ $idx }}
- return f & ^mask
-}
-
-{{ end }}
-
-// String returns a human readable representation of Flags{{ $size.Size }}.
-func (f Flags{{ $size.Size }}) String() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteByte('{')
- {{ range $idx := .Bits }}
- val = f.Get{{ $idx }}()
- buf.WriteString(bool2str(val) + " ")
- {{ end }}
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-// GoString returns a more verbose human readable representation of Flags{{ $size.Size }}.
-func (f Flags{{ $size.Size }})GoString() string {
- var val bool
- var buf byteutil.Buffer
-
- buf.WriteString("bitutil.Flags{{ $size.Size }}{")
- {{ range $idx := .Bits }}
- val = f.Get{{ $idx }}()
- buf.WriteString("{{ $idx }}="+bool2str(val)+" ")
- {{ end }}
- buf.Truncate(1)
- buf.WriteByte('}')
-
- return buf.String()
-}
-
-{{ end }}
-
-func bool2str(b bool) string {
- if b {
- return "true"
- }
- return "false"
-} \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl b/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl
deleted file mode 100644
index e85cc2dff..000000000
--- a/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl
+++ /dev/null
@@ -1,98 +0,0 @@
-package bitutil_test
-
-import (
- "strings"
- "testing"
-
- "codeberg.org/gruf/go-bytes"
-)
-
-{{ range $idx, $size := . }}
-
-func TestFlags{{ $size.Size }}Get(t *testing.T) {
- var mask, flags bitutil.Flags{{ $size.Size }}
-
- {{ range $idx := $size.Bits }}
-
- mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }}
-
- flags = 0
-
- flags |= mask
- if !flags.Get({{ $idx }}) {
- t.Error("failed .Get() set Flags{{ $size.Size }} bit at index {{ $idx }}")
- }
-
- flags = ^bitutil.Flags{{ $size.Size }}(0)
-
- flags &= ^mask
- if flags.Get({{ $idx }}) {
- t.Error("failed .Get() unset Flags{{ $size.Size }} bit at index {{ $idx }}")
- }
-
- flags = 0
-
- flags |= mask
- if !flags.Get{{ $idx }}() {
- t.Error("failed .Get{{ $idx }}() set Flags{{ $size.Size }} bit at index {{ $idx }}")
- }
-
- flags = ^bitutil.Flags{{ $size.Size }}(0)
-
- flags &= ^mask
- if flags.Get{{ $idx }}() {
- t.Error("failed .Get{{ $idx }}() unset Flags{{ $size.Size }} bit at index {{ $idx }}")
- }
-
- {{ end }}
-}
-
-func TestFlags{{ $size.Size }}Set(t *testing.T) {
- var mask, flags bitutil.Flags{{ $size.Size }}
-
- {{ range $idx := $size.Bits }}
-
- mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }}
-
- flags = 0
-
- flags = flags.Set({{ $idx }})
- if flags & mask == 0 {
- t.Error("failed .Set() Flags{{ $size.Size }} bit at index {{ $idx }}")
- }
-
- flags = 0
-
- flags = flags.Set{{ $idx }}()
- if flags & mask == 0 {
- t.Error("failed .Set{{ $idx }}() Flags{{ $size.Size }} bit at index {{ $idx }}")
- }
-
- {{ end }}
-}
-
-func TestFlags{{ $size.Size }}Unset(t *testing.T) {
- var mask, flags bitutil.Flags{{ $size.Size }}
-
- {{ range $idx := $size.Bits }}
-
- mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }}
-
- flags = ^bitutil.Flags{{ $size.Size }}(0)
-
- flags = flags.Unset({{ $idx }})
- if flags & mask != 0 {
- t.Error("failed .Unset() Flags{{ $size.Size }} bit at index {{ $idx }}")
- }
-
- flags = ^bitutil.Flags{{ $size.Size }}(0)
-
- flags = flags.Unset{{ $idx }}()
- if flags & mask != 0 {
- t.Error("failed .Unset{{ $idx }}() Flags{{ $size.Size }} bit at index {{ $idx }}")
- }
-
- {{ end }}
-}
-
-{{ end }} \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-bitutil/pack.go b/vendor/codeberg.org/gruf/go-bitutil/pack.go
deleted file mode 100644
index 2a57d3294..000000000
--- a/vendor/codeberg.org/gruf/go-bitutil/pack.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package bitutil
-
-// PackInt8s will pack two signed 8bit integers into an unsigned 16bit integer.
-func PackInt8s(i1, i2 int8) uint16 {
- const bits = 8
- const mask = (1 << bits) - 1
- return uint16(i1)<<bits | uint16(i2)&mask
-}
-
-// UnpackInt8s will unpack two signed 8bit integers from an unsigned 16bit integer.
-func UnpackInt8s(i uint16) (int8, int8) {
- const bits = 8
- const mask = (1 << bits) - 1
- return int8(i >> bits), int8(i & mask)
-}
-
-// PackInt16s will pack two signed 16bit integers into an unsigned 32bit integer.
-func PackInt16s(i1, i2 int16) uint32 {
- const bits = 16
- const mask = (1 << bits) - 1
- return uint32(i1)<<bits | uint32(i2)&mask
-}
-
-// UnpackInt16s will unpack two signed 16bit integers from an unsigned 32bit integer.
-func UnpackInt16s(i uint32) (int16, int16) {
- const bits = 16
- const mask = (1 << bits) - 1
- return int16(i >> bits), int16(i & mask)
-}
-
-// PackInt32s will pack two signed 32bit integers into an unsigned 64bit integer.
-func PackInt32s(i1, i2 int32) uint64 {
- const bits = 32
- const mask = (1 << bits) - 1
- return uint64(i1)<<bits | uint64(i2)&mask
-}
-
-// UnpackInt32s will unpack two signed 32bit integers from an unsigned 64bit integer.
-func UnpackInt32s(i uint64) (int32, int32) {
- const bits = 32
- const mask = (1 << bits) - 1
- return int32(i >> bits), int32(i & mask)
-}
-
-// PackUint8s will pack two unsigned 8bit integers into an unsigned 16bit integer.
-func PackUint8s(u1, u2 uint8) uint16 {
- const bits = 8
- const mask = (1 << bits) - 1
- return uint16(u1)<<bits | uint16(u2)&mask
-}
-
-// UnpackUint8s will unpack two unsigned 8bit integers from an unsigned 16bit integer.
-func UnpackUint8s(u uint16) (uint8, uint8) {
- const bits = 8
- const mask = (1 << bits) - 1
- return uint8(u >> bits), uint8(u & mask)
-}
-
-// PackUint16s will pack two unsigned 16bit integers into an unsigned 32bit integer.
-func PackUint16s(u1, u2 uint16) uint32 {
- const bits = 16
- const mask = (1 << bits) - 1
- return uint32(u1)<<bits | uint32(u2)&mask
-}
-
-// UnpackUint16s will unpack two unsigned 16bit integers from an unsigned 32bit integer.
-func UnpackUint16s(u uint32) (uint16, uint16) {
- const bits = 16
- const mask = (1 << bits) - 1
- return uint16(u >> bits), uint16(u & mask)
-}
-
-// PackUint32s will pack two unsigned 32bit integers into an unsigned 64bit integer.
-func PackUint32s(u1, u2 uint32) uint64 {
- const bits = 32
- const mask = (1 << bits) - 1
- return uint64(u1)<<bits | uint64(u2)&mask
-}
-
-// UnpackUint32s will unpack two unsigned 32bit integers from an unsigned 64bit integer.
-func UnpackUint32s(u uint64) (uint32, uint32) {
- const bits = 32
- const mask = (1 << bits) - 1
- return uint32(u >> bits), uint32(u & mask)
-}
diff --git a/vendor/codeberg.org/gruf/go-bitutil/test.tpl b/vendor/codeberg.org/gruf/go-bitutil/test.tpl
deleted file mode 100644
index 4e659d81f..000000000
--- a/vendor/codeberg.org/gruf/go-bitutil/test.tpl
+++ /dev/null
@@ -1,60 +0,0 @@
-package atomics_test
-
-import (
- "atomic"
- "unsafe"
- "testing"
-
- "codeberg.org/gruf/go-atomics"
-)
-
-func Test{{ .Name }}StoreLoad(t *testing.T) {
- for _, test := range {{ .Name }}Tests {
- val := atomics.New{{ .Name }}()
-
- val.Store(test.V1)
-
- if !({{ call .Compare "val.Load()" "test.V1" }}) {
- t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V1)
- }
-
- val.Store(test.V2)
-
- if !({{ call .Compare "val.Load()" "test.V2" }}) {
- t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V2)
- }
- }
-}
-
-func Test{{ .Name }}CAS(t *testing.T) {
- for _, test := range {{ .Name }}Tests {
- val := atomics.New{{ .Name }}()
-
- val.Store(test.V1)
-
- if val.CAS(test.V2, test.V1) {
- t.Fatalf("failed testing negative .CAS: test=%+v state=%v", test, val.Load())
- }
-
- if !val.CAS(test.V1, test.V2) {
- t.Fatalf("failed testing positive .CAS: test=%+v state=%v", test, val.Load())
- }
- }
-}
-
-func Test{{ .Name }}Swap(t *testing.T) {
- for _, test := range {{ .Name }}Tests {
- val := atomics.New{{ .Name }}()
-
- val.Store(test.V1)
-
- if !({{ call .Compare "val.Swap(test.V2)" "test.V1" }}) {
- t.Fatal("failed testing .Swap")
- }
-
- if !({{ call .Compare "val.Swap(test.V1)" "test.V2" }}) {
- t.Fatal("failed testing .Swap")
- }
- }
-}
-
diff --git a/vendor/codeberg.org/gruf/go-bytes/LICENSE b/vendor/codeberg.org/gruf/go-bytes/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-bytes/README.md b/vendor/codeberg.org/gruf/go-bytes/README.md
deleted file mode 100644
index fbdf99798..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-drop-in replacement for standard "bytes" library
-
-contains alternative Buffer implementation that provides direct access to the
-underlying byte-slice, with some interesting alternative struct methods. provides
-no safety guards, if you pass bad values it will blow up in your face...
-
-and alternative `ToUpper()` and `ToLower()` implementations that use lookup
-tables for improved performance
-
-provides direct call-throughs to most of the "bytes" library functions to facilitate
-this being a direct drop-in. in some time, i may offer alternative implementations
-for other functions too \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-bytes/buffer.go b/vendor/codeberg.org/gruf/go-bytes/buffer.go
deleted file mode 100644
index 5c3b2cb5b..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/buffer.go
+++ /dev/null
@@ -1,131 +0,0 @@
-package bytes
-
-import (
- "unicode/utf8"
-)
-
-// Buffer is a very simple buffer implementation that allows
-// access to and reslicing of the underlying byte slice.
-type Buffer struct {
- B []byte
-}
-
-func NewBuffer(b []byte) Buffer {
- return Buffer{
- B: b,
- }
-}
-
-func (b *Buffer) Write(p []byte) (int, error) {
- b.Grow(len(p))
- return copy(b.B[b.Len()-len(p):], p), nil
-}
-
-func (b *Buffer) WriteString(s string) (int, error) {
- b.Grow(len(s))
- return copy(b.B[b.Len()-len(s):], s), nil
-}
-
-func (b *Buffer) WriteByte(c byte) error {
- l := b.Len()
- b.Grow(1)
- b.B[l] = c
- return nil
-}
-
-func (b *Buffer) WriteRune(r rune) (int, error) {
- if r < utf8.RuneSelf {
- b.WriteByte(byte(r))
- return 1, nil
- }
-
- l := b.Len()
- b.Grow(utf8.UTFMax)
- n := utf8.EncodeRune(b.B[l:b.Len()], r)
- b.B = b.B[:l+n]
-
- return n, nil
-}
-
-func (b *Buffer) WriteAt(p []byte, start int64) (int, error) {
- b.Grow(len(p) - int(int64(b.Len())-start))
- return copy(b.B[start:], p), nil
-}
-
-func (b *Buffer) WriteStringAt(s string, start int64) (int, error) {
- b.Grow(len(s) - int(int64(b.Len())-start))
- return copy(b.B[start:], s), nil
-}
-
-func (b *Buffer) Truncate(size int) {
- b.B = b.B[:b.Len()-size]
-}
-
-func (b *Buffer) ShiftByte(index int) {
- copy(b.B[index:], b.B[index+1:])
-}
-
-func (b *Buffer) Shift(start int64, size int) {
- copy(b.B[start:], b.B[start+int64(size):])
-}
-
-func (b *Buffer) DeleteByte(index int) {
- b.ShiftByte(index)
- b.Truncate(1)
-}
-
-func (b *Buffer) Delete(start int64, size int) {
- b.Shift(start, size)
- b.Truncate(size)
-}
-
-func (b *Buffer) InsertByte(index int64, c byte) {
- l := b.Len()
- b.Grow(1)
- copy(b.B[index+1:], b.B[index:l])
- b.B[index] = c
-}
-
-func (b *Buffer) Insert(index int64, p []byte) {
- l := b.Len()
- b.Grow(len(p))
- copy(b.B[index+int64(len(p)):], b.B[index:l])
- copy(b.B[index:], p)
-}
-
-func (b *Buffer) Bytes() []byte {
- return b.B
-}
-
-func (b *Buffer) String() string {
- return string(b.B)
-}
-
-func (b *Buffer) StringPtr() string {
- return BytesToString(b.B)
-}
-
-func (b *Buffer) Cap() int {
- return cap(b.B)
-}
-
-func (b *Buffer) Len() int {
- return len(b.B)
-}
-
-func (b *Buffer) Reset() {
- b.B = b.B[:0]
-}
-
-func (b *Buffer) Grow(size int) {
- b.Guarantee(size)
- b.B = b.B[:b.Len()+size]
-}
-
-func (b *Buffer) Guarantee(size int) {
- if size > b.Cap()-b.Len() {
- nb := make([]byte, 2*b.Cap()+size)
- copy(nb, b.B)
- b.B = nb[:b.Len()]
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-bytes/bytes.go b/vendor/codeberg.org/gruf/go-bytes/bytes.go
deleted file mode 100644
index 5fef75d56..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/bytes.go
+++ /dev/null
@@ -1,261 +0,0 @@
-package bytes
-
-import (
- "bytes"
- "reflect"
- "unsafe"
-)
-
-var (
- _ Bytes = &Buffer{}
- _ Bytes = bytesType{}
-)
-
-// Bytes defines a standard way of retrieving the content of a
-// byte buffer of some-kind.
-type Bytes interface {
- // Bytes returns the byte slice content
- Bytes() []byte
-
- // String returns byte slice cast directly to string, this
- // will cause an allocation but comes with the safety of
- // being an immutable Go string
- String() string
-
- // StringPtr returns byte slice cast to string via the unsafe
- // package. This comes with the same caveats of accessing via
- // .Bytes() in that the content is liable change and is NOT
- // immutable, despite being a string type
- StringPtr() string
-}
-
-type bytesType []byte
-
-func (b bytesType) Bytes() []byte {
- return b
-}
-
-func (b bytesType) String() string {
- return string(b)
-}
-
-func (b bytesType) StringPtr() string {
- return BytesToString(b)
-}
-
-// ToBytes casts the provided byte slice as the simplest possible
-// Bytes interface implementation
-func ToBytes(b []byte) Bytes {
- return bytesType(b)
-}
-
-// Copy returns a new copy of slice b, does NOT maintain nil values
-func Copy(b []byte) []byte {
- p := make([]byte, len(b))
- copy(p, b)
- return p
-}
-
-// BytesToString returns byte slice cast to string via the "unsafe" package
-func BytesToString(b []byte) string {
- return *(*string)(unsafe.Pointer(&b))
-}
-
-// StringToBytes returns the string cast to string via the "unsafe" and "reflect" packages
-func StringToBytes(s string) []byte {
- // thank you to https://github.com/valyala/fasthttp/blob/master/bytesconv.go
- var b []byte
-
- // Get byte + string headers
- bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
- sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
-
- // Manually set bytes to string
- bh.Data = sh.Data
- bh.Len = sh.Len
- bh.Cap = sh.Len
-
- return b
-}
-
-// // InsertByte inserts the supplied byte into the slice at provided position
-// func InsertByte(b []byte, at int, c byte) []byte {
-// return append(append(b[:at], c), b[at:]...)
-// }
-
-// // Insert inserts the supplied byte slice into the slice at provided position
-// func Insert(b []byte, at int, s []byte) []byte {
-// return append(append(b[:at], s...), b[at:]...)
-// }
-
-// ToUpper offers a faster ToUpper implementation using a lookup table
-func ToUpper(b []byte) {
- for i := 0; i < len(b); i++ {
- c := &b[i]
- *c = toUpperTable[*c]
- }
-}
-
-// ToLower offers a faster ToLower implementation using a lookup table
-func ToLower(b []byte) {
- for i := 0; i < len(b); i++ {
- c := &b[i]
- *c = toLowerTable[*c]
- }
-}
-
-// HasBytePrefix returns whether b has the provided byte prefix
-func HasBytePrefix(b []byte, c byte) bool {
- return (len(b) > 0) && (b[0] == c)
-}
-
-// HasByteSuffix returns whether b has the provided byte suffix
-func HasByteSuffix(b []byte, c byte) bool {
- return (len(b) > 0) && (b[len(b)-1] == c)
-}
-
-// HasBytePrefix returns b without the provided leading byte
-func TrimBytePrefix(b []byte, c byte) []byte {
- if HasBytePrefix(b, c) {
- return b[1:]
- }
- return b
-}
-
-// TrimByteSuffix returns b without the provided trailing byte
-func TrimByteSuffix(b []byte, c byte) []byte {
- if HasByteSuffix(b, c) {
- return b[:len(b)-1]
- }
- return b
-}
-
-// Compare is a direct call-through to standard library bytes.Compare()
-func Compare(b, s []byte) int {
- return bytes.Compare(b, s)
-}
-
-// Contains is a direct call-through to standard library bytes.Contains()
-func Contains(b, s []byte) bool {
- return bytes.Contains(b, s)
-}
-
-// TrimPrefix is a direct call-through to standard library bytes.TrimPrefix()
-func TrimPrefix(b, s []byte) []byte {
- return bytes.TrimPrefix(b, s)
-}
-
-// TrimSuffix is a direct call-through to standard library bytes.TrimSuffix()
-func TrimSuffix(b, s []byte) []byte {
- return bytes.TrimSuffix(b, s)
-}
-
-// Equal is a direct call-through to standard library bytes.Equal()
-func Equal(b, s []byte) bool {
- return bytes.Equal(b, s)
-}
-
-// EqualFold is a direct call-through to standard library bytes.EqualFold()
-func EqualFold(b, s []byte) bool {
- return bytes.EqualFold(b, s)
-}
-
-// Fields is a direct call-through to standard library bytes.Fields()
-func Fields(b []byte) [][]byte {
- return bytes.Fields(b)
-}
-
-// FieldsFunc is a direct call-through to standard library bytes.FieldsFunc()
-func FieldsFunc(b []byte, fn func(rune) bool) [][]byte {
- return bytes.FieldsFunc(b, fn)
-}
-
-// HasPrefix is a direct call-through to standard library bytes.HasPrefix()
-func HasPrefix(b, s []byte) bool {
- return bytes.HasPrefix(b, s)
-}
-
-// HasSuffix is a direct call-through to standard library bytes.HasSuffix()
-func HasSuffix(b, s []byte) bool {
- return bytes.HasSuffix(b, s)
-}
-
-// Index is a direct call-through to standard library bytes.Index()
-func Index(b, s []byte) int {
- return bytes.Index(b, s)
-}
-
-// IndexByte is a direct call-through to standard library bytes.IndexByte()
-func IndexByte(b []byte, c byte) int {
- return bytes.IndexByte(b, c)
-}
-
-// IndexAny is a direct call-through to standard library bytes.IndexAny()
-func IndexAny(b []byte, s string) int {
- return bytes.IndexAny(b, s)
-}
-
-// IndexRune is a direct call-through to standard library bytes.IndexRune()
-func IndexRune(b []byte, r rune) int {
- return bytes.IndexRune(b, r)
-}
-
-// IndexFunc is a direct call-through to standard library bytes.IndexFunc()
-func IndexFunc(b []byte, fn func(rune) bool) int {
- return bytes.IndexFunc(b, fn)
-}
-
-// LastIndex is a direct call-through to standard library bytes.LastIndex()
-func LastIndex(b, s []byte) int {
- return bytes.LastIndex(b, s)
-}
-
-// LastIndexByte is a direct call-through to standard library bytes.LastIndexByte()
-func LastIndexByte(b []byte, c byte) int {
- return bytes.LastIndexByte(b, c)
-}
-
-// LastIndexAny is a direct call-through to standard library bytes.LastIndexAny()
-func LastIndexAny(b []byte, s string) int {
- return bytes.LastIndexAny(b, s)
-}
-
-// LastIndexFunc is a direct call-through to standard library bytes.LastIndexFunc()
-func LastIndexFunc(b []byte, fn func(rune) bool) int {
- return bytes.LastIndexFunc(b, fn)
-}
-
-// Replace is a direct call-through to standard library bytes.Replace()
-func Replace(b, s, r []byte, c int) []byte {
- return bytes.Replace(b, s, r, c)
-}
-
-// ReplaceAll is a direct call-through to standard library bytes.ReplaceAll()
-func ReplaceAll(b, s, r []byte) []byte {
- return bytes.ReplaceAll(b, s, r)
-}
-
-// Split is a direct call-through to standard library bytes.Split()
-func Split(b, s []byte) [][]byte {
- return bytes.Split(b, s)
-}
-
-// SplitAfter is a direct call-through to standard library bytes.SplitAfter()
-func SplitAfter(b, s []byte) [][]byte {
- return bytes.SplitAfter(b, s)
-}
-
-// SplitN is a direct call-through to standard library bytes.SplitN()
-func SplitN(b, s []byte, c int) [][]byte {
- return bytes.SplitN(b, s, c)
-}
-
-// SplitAfterN is a direct call-through to standard library bytes.SplitAfterN()
-func SplitAfterN(b, s []byte, c int) [][]byte {
- return bytes.SplitAfterN(b, s, c)
-}
-
-// NewReader is a direct call-through to standard library bytes.NewReader()
-func NewReader(b []byte) *bytes.Reader {
- return bytes.NewReader(b)
-}
diff --git a/vendor/codeberg.org/gruf/go-bytes/bytesconv_table.go b/vendor/codeberg.org/gruf/go-bytes/bytesconv_table.go
deleted file mode 100644
index 3d3058ada..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/bytesconv_table.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package bytes
-
-// Code generated by go run bytesconv_table_gen.go; DO NOT EDIT.
-// See bytesconv_table_gen.go for more information about these tables.
-//
-// Source: https://github.com/valyala/fasthttp/blob/master/bytes_table_gen.go
-
-const (
- toLowerTable = "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
- toUpperTable = "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~\u007f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
-)
diff --git a/vendor/codeberg.org/gruf/go-bytesize/LICENSE b/vendor/codeberg.org/gruf/go-bytesize/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-bytesize/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-bytesize/README.md b/vendor/codeberg.org/gruf/go-bytesize/README.md
deleted file mode 100644
index 46a0457ca..000000000
--- a/vendor/codeberg.org/gruf/go-bytesize/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-Byte size formatting and parsing.
-
-todo: more robust tests \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-bytesize/bytesize.go b/vendor/codeberg.org/gruf/go-bytesize/bytesize.go
deleted file mode 100644
index c2fedc8d7..000000000
--- a/vendor/codeberg.org/gruf/go-bytesize/bytesize.go
+++ /dev/null
@@ -1,306 +0,0 @@
-package bytesize
-
-import (
- "errors"
- "math/bits"
- "unsafe"
-)
-
-var (
- // ErrInvalidUnit is returned when an invalid IEC/SI is provided.
- ErrInvalidUnit = errors.New("bytesize: invalid unit")
-
- // ErrInvalidFormat is returned when an invalid size value is provided.
- ErrInvalidFormat = errors.New("bytesize: invalid format")
-
- // bunits are the binary unit chars.
- units = `kMGTPE`
-
- // iecpows is a precomputed table of 1024^n.
- iecpows = [...]float64{
- float64(1024), // KiB
- float64(1024 * 1024), // MiB
- float64(1024 * 1024 * 1024), // GiB
- float64(1024 * 1024 * 1024 * 1024), // TiB
- float64(1024 * 1024 * 1024 * 1024 * 1024), // PiB
- float64(1024 * 1024 * 1024 * 1024 * 1024 * 1024), // EiB
- }
-
- // sipows is a precomputed table of 1000^n.
- sipows = [...]float64{
- float64(1e3), // KB
- float64(1e6), // MB
- float64(1e9), // GB
- float64(1e12), // TB
- float64(1e15), // PB
- float64(1e18), // EB
- }
-
- // bvals is a precomputed table of IEC unit values.
- iecvals = [...]uint64{
- 'k': 1024,
- 'K': 1024,
- 'M': 1024 * 1024,
- 'G': 1024 * 1024 * 1024,
- 'T': 1024 * 1024 * 1024 * 1024,
- 'P': 1024 * 1024 * 1024 * 1024 * 1024,
- 'E': 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
- }
-
- // sivals is a precomputed table of SI unit values.
- sivals = [...]uint64{
- // ASCII numbers _aren't_ valid SI unit values,
- // BUT if the space containing a possible unit
- // char is checked with this table -- it is valid
- // to provide no unit char so unit=1 works.
- '0': 1,
- '1': 1,
- '2': 1,
- '3': 1,
- '4': 1,
- '5': 1,
- '6': 1,
- '7': 1,
- '8': 1,
- '9': 1,
-
- 'k': 1e3,
- 'M': 1e6,
- 'G': 1e9,
- 'T': 1e12,
- 'P': 1e15,
- 'E': 1e18,
- }
-)
-
-// Size is a casting for uint64 types that provides formatting
-// methods for byte sizes in both IEC and SI units.
-type Size uint64
-
-// ParseSize will parse a valid Size from given string. Both IEC and SI units are supported.
-func ParseSize(s string) (Size, error) {
- // Parse units from string
- unit, l, err := parseUnit(s)
- if err != nil {
- return 0, err
- }
-
- // Parse remaining string as float
- f, n, err := atof64(s[:l])
- if err != nil || n != l {
- return 0, ErrInvalidFormat
- }
-
- return Size(uint64(f) * unit), nil
-}
-
-// AppendFormat defaults to using Size.AppendFormatIEC().
-func (sz Size) AppendFormat(dst []byte) []byte {
- return sz.AppendFormatIEC(dst) // default
-}
-
-// AppendFormatSI will append SI formatted size to 'dst'.
-func (sz Size) AppendFormatSI(dst []byte) []byte {
- if uint64(sz) < 1000 {
- dst = itoa(dst, uint64(sz))
- dst = append(dst, 'B')
- return dst
- } // above is fast-path, .appendFormat() is outlined
- return sz.appendFormat(dst, 1000, &sipows, "B")
-}
-
-// AppendFormatIEC will append IEC formatted size to 'dst'.
-func (sz Size) AppendFormatIEC(dst []byte) []byte {
- if uint64(sz) < 1024 {
- dst = itoa(dst, uint64(sz))
- dst = append(dst, 'B')
- return dst
- } // above is fast-path, .appendFormat() is outlined
- return sz.appendFormat(dst, 1024, &iecpows, "iB")
-}
-
-// appendFormat will append formatted Size to 'dst', depending on base, powers table and single unit suffix.
-func (sz Size) appendFormat(dst []byte, base uint64, pows *[6]float64, sunit string) []byte {
- const min = 0.75
-
- // Larger number: get value of
- // i / unit size. We have a 'min'
- // threshold after which we prefer
- // using the unit 1 down
- n := bits.Len64(uint64(sz)) / 10
- f := float64(sz) / pows[n-1]
- if f < min {
- f *= float64(base)
- n--
- }
-
- // Append formatted float with units
- dst = ftoa(dst, f)
- dst = append(dst, units[n-1])
- dst = append(dst, sunit...)
- return dst
-}
-
-// StringSI returns an SI unit string format of Size.
-func (sz Size) StringSI() string {
- b := sz.AppendFormatSI(make([]byte, 0, 6))
- return *(*string)(unsafe.Pointer(&b))
-}
-
-// StringIEC returns an IEC unit string format of Size.
-func (sz Size) StringIEC() string {
- b := sz.AppendFormatIEC(make([]byte, 0, 7))
- return *(*string)(unsafe.Pointer(&b))
-}
-
-// String returns a string format of Size, defaults to IEC unit format.
-func (sz Size) String() string {
- return sz.StringIEC()
-}
-
-// parseUnit will parse the byte size unit from string 's'.
-func parseUnit(s string) (uint64, int, error) {
- var isIEC bool
-
- // Check for string
- if len(s) < 1 {
- return 0, 0, ErrInvalidFormat
- }
-
- // Strip 'byte' unit suffix
- if l := len(s) - 1; s[l] == 'B' {
- s = s[:l]
-
- // Check str remains
- if len(s) < 1 {
- return 0, 0, ErrInvalidFormat
- }
- }
-
- // Strip IEC binary unit suffix
- if l := len(s) - 1; s[l] == 'i' {
- s = s[:l]
- isIEC = true
-
- // Check str remains
- if len(s) < 1 {
- return 0, 0, ErrInvalidFormat
- }
- }
-
- // Location of unit char.
- l := len(s) - 1
-
- var unit uint64
- switch c := int(s[l]); {
- // Determine IEC unit in use
- case isIEC && c < len(iecvals):
- unit = iecvals[c]
- if unit == 0 {
- return 0, 0, ErrInvalidUnit
- }
-
- // Determine SI unit in use
- case c < len(sivals):
- unit = sivals[c]
- switch unit {
- case 0:
- return 0, 0, ErrInvalidUnit
- case 1:
- l++
- }
- }
-
- return unit, l, nil
-}
-
-// ftoa appends string formatted 'f' to 'dst', assumed < ~800.
-func ftoa(dst []byte, f float64) []byte {
- switch i := uint64(f); {
- // Append with 2 d.p.
- case i < 10:
- f *= 10
-
- // Calculate next dec. value
- d1 := uint8(uint64(f) % 10)
-
- f *= 10
-
- // Calculate next dec. value
- d2 := uint8(uint64(f) % 10)
-
- // Round the final value
- if uint64(f*10)%10 > 4 {
- d2++
-
- // Overflow, incr 'd1'
- if d2 == 10 {
- d2 = 0
- d1++
-
- // Overflow, incr 'i'
- if d1 == 10 {
- d1 = 0
- i++
- }
- }
- }
-
- // Append decimal value
- dst = itoa(dst, i)
- dst = append(dst,
- '.',
- '0'+d1,
- '0'+d2,
- )
-
- // Append with 1 d.p.
- case i < 100:
- f *= 10
-
- // Calculate next dec. value
- d1 := uint8(uint64(f) % 10)
-
- // Round the final value
- if uint64(f*10)%10 > 4 {
- d1++
-
- // Overflow, incr 'i'
- if d1 == 10 {
- d1 = 0
- i++
- }
- }
-
- // Append decimal value
- dst = itoa(dst, i)
- dst = append(dst, '.', '0'+d1)
-
- // No decimal places
- default:
- dst = itoa(dst, i)
- }
-
- return dst
-}
-
-// itoa appends string formatted 'i' to 'dst'.
-func itoa(dst []byte, i uint64) []byte {
- // Assemble int in reverse order.
- var b [4]byte
- bp := len(b) - 1
-
- // Append integer
- for i >= 10 {
- q := i / 10
- b[bp] = byte('0' + i - q*10)
- bp--
- i = q
- } // i < 10
- b[bp] = byte('0' + i)
-
- return append(dst, b[bp:]...)
-}
-
-//go:linkname atof64 strconv.atof64
-func atof64(string) (float64, int, error)
diff --git a/vendor/codeberg.org/gruf/go-byteutil/LICENSE b/vendor/codeberg.org/gruf/go-byteutil/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-byteutil/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-byteutil/README.md b/vendor/codeberg.org/gruf/go-byteutil/README.md
deleted file mode 100644
index e1f81d969..000000000
--- a/vendor/codeberg.org/gruf/go-byteutil/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-byteutil
-
-A useful package of byte utilities. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-byteutil/buffer.go b/vendor/codeberg.org/gruf/go-byteutil/buffer.go
deleted file mode 100644
index 9e15c8ade..000000000
--- a/vendor/codeberg.org/gruf/go-byteutil/buffer.go
+++ /dev/null
@@ -1,134 +0,0 @@
-package byteutil
-
-import (
- "errors"
- "io"
- "unicode/utf8"
-)
-
-var (
- // ensure we conform to interfaces.
- _ interface {
- io.Writer
- io.ByteWriter
- WriteRune(rune) (int, error)
- io.StringWriter
- io.WriterAt
- WriteStringAt(string, int64) (int, error)
- } = (*Buffer)(nil)
-
- // ErrBeyondBufferLen is returned if .WriteAt() is attempted beyond buffer length.
- ErrBeyondBufferLen = errors.New("start beyond buffer length")
-)
-
-// Buffer is a simple wrapper around a byte slice.
-type Buffer struct{ B []byte }
-
-// WriteByte will append given byte to buffer, fulfilling io.ByteWriter.
-func (buf *Buffer) WriteByte(c byte) error {
- buf.B = append(buf.B, c)
- return nil
-}
-
-// WriteRune will append given rune to buffer.
-func (buf *Buffer) WriteRune(r rune) (int, error) {
- // Check for single-byte rune
- if r < utf8.RuneSelf {
- buf.B = append(buf.B, byte(r))
- return 1, nil
- }
-
- // Before-len
- l := len(buf.B)
-
- // Grow to max size rune
- buf.Grow(utf8.UTFMax)
-
- // Write encoded rune to buffer
- n := utf8.EncodeRune(buf.B[l:len(buf.B)], r)
- buf.B = buf.B[:l+n]
-
- return n, nil
-}
-
-// Write will append given byte slice to buffer, fulfilling io.Writer.
-func (buf *Buffer) Write(b []byte) (int, error) {
- buf.B = append(buf.B, b...)
- return len(b), nil
-}
-
-// WriteString will append given string to buffer, fulfilling io.StringWriter.
-func (buf *Buffer) WriteString(s string) (int, error) {
- buf.B = append(buf.B, s...)
- return len(s), nil
-}
-
-// WriteAt will append given byte slice to buffer at index 'start', fulfilling io.WriterAt.
-func (buf *Buffer) WriteAt(b []byte, start int64) (int, error) {
- if start > int64(len(buf.B)) {
- return 0, ErrBeyondBufferLen
- }
- buf.Grow(len(b) - int(int64(len(buf.B))-start))
- return copy(buf.B[start:], b), nil
-}
-
-// WriteStringAt will append given string to buffer at index 'start'.
-func (buf *Buffer) WriteStringAt(s string, start int64) (int, error) {
- if start > int64(len(buf.B)) {
- return 0, ErrBeyondBufferLen
- }
- buf.Grow(len(s) - int(int64(len(buf.B))-start))
- return copy(buf.B[start:], s), nil
-}
-
-// Len returns the length of the buffer's underlying byte slice.
-func (buf *Buffer) Len() int {
- return len(buf.B)
-}
-
-// Cap returns the capacity of the buffer's underlying byte slice.
-func (buf *Buffer) Cap() int {
- return cap(buf.B)
-}
-
-// Grow will increase the buffers length by 'sz', and the capacity by at least this.
-func (buf *Buffer) Grow(sz int) {
- buf.Guarantee(sz)
- buf.B = buf.B[:len(buf.B)+sz]
-}
-
-// Guarantee will guarantee buffer containers at least 'sz' remaining capacity.
-func (buf *Buffer) Guarantee(sz int) {
- if sz > cap(buf.B)-len(buf.B) {
- nb := make([]byte, 2*cap(buf.B)+sz)
- copy(nb, buf.B)
- buf.B = nb[:len(buf.B)]
- }
-}
-
-// Truncate will reduce the length of the buffer by 'n'.
-func (buf *Buffer) Truncate(n int) {
- if n > len(buf.B) {
- n = len(buf.B)
- }
- buf.B = buf.B[:len(buf.B)-n]
-}
-
-// Reset will reset the buffer length to 0 (retains capacity).
-func (buf *Buffer) Reset() {
- buf.B = buf.B[:0]
-}
-
-// String returns the underlying byte slice as a string. Please note
-// this value is tied directly to the underlying byte slice, if you
-// write to the buffer then returned string values will also change.
-//
-// To get an immutable string from buffered data, use string(buf.B).
-func (buf *Buffer) String() string {
- return B2S(buf.B)
-}
-
-// Full returns the full capacity byteslice allocated for this buffer.
-func (buf *Buffer) Full() []byte {
- return buf.B[0:cap(buf.B)]
-}
diff --git a/vendor/codeberg.org/gruf/go-byteutil/bytes.go b/vendor/codeberg.org/gruf/go-byteutil/bytes.go
deleted file mode 100644
index eb57a90de..000000000
--- a/vendor/codeberg.org/gruf/go-byteutil/bytes.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package byteutil
-
-import (
- "reflect"
- "unsafe"
-)
-
-// Copy returns a copy of []byte.
-func Copy(b []byte) []byte {
- if b == nil {
- return nil
- }
- p := make([]byte, len(b))
- copy(p, b)
- return p
-}
-
-// B2S returns a string representation of []byte without allocation.
-//
-// According to the Go spec strings are immutable and byte slices are not. The way this gets implemented is strings under the hood are:
-// type StringHeader struct {
-// Data uintptr
-// Len int
-// }
-//
-// while slices are:
-// type SliceHeader struct {
-// Data uintptr
-// Len int
-// Cap int
-// }
-// because being mutable, you can change the data, length etc, but the string has to promise to be read-only to all who get copies of it.
-//
-// So in practice when you do a conversion of `string(byteSlice)` it actually performs an allocation because it has to copy the contents of the byte slice into a safe read-only state.
-//
-// Being that the shared fields are in the same struct indices (no different offsets), means that if you have a byte slice you can "forcibly" cast it to a string. Which in a lot of situations can be risky, because then it means you have a string that is NOT immutable, as if someone changes the data in the originating byte slice then the string will reflect that change! Now while this does seem hacky, and it _kind_ of is, it is something that you see performed in the standard library. If you look at the definition for `strings.Builder{}.String()` you'll see this :)
-func B2S(b []byte) string {
- return *(*string)(unsafe.Pointer(&b))
-}
-
-// S2B returns a []byte representation of string without allocation (minus slice header).
-// See B2S() code comment, and this function's implementation for a better understanding.
-func S2B(s string) []byte {
- var b []byte
-
- // Get byte + string headers
- bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
- sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
-
- // Manually set bytes to string
- bh.Data = sh.Data
- bh.Len = sh.Len
- bh.Cap = sh.Len
-
- return b
-}
-
-// ToUpper offers a faster ToUpper implementation using a lookup table.
-func ToUpper(b []byte) {
- const toUpperTable = "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" +
- " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~" +
- "\u007f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96" +
- "\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" +
- "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8" +
- "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1" +
- "\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
- for i := 0; i < len(b); i++ {
- b[i] = toUpperTable[b[i]]
- }
-}
-
-// ToLower offers a faster ToLower implementation using a lookup table.
-func ToLower(b []byte) {
- const toLowerTable = "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" +
- " !\"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" +
- "\u007f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96" +
- "\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" +
- "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8" +
- "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1" +
- "\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
- for i := 0; i < len(b); i++ {
- b[i] = toLowerTable[b[i]]
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v2/LICENSE b/vendor/codeberg.org/gruf/go-cache/v2/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v2/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-cache/v2/README.md b/vendor/codeberg.org/gruf/go-cache/v2/README.md
deleted file mode 100644
index 69eee7039..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v2/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-cache
-
-A TTL cache designed to be used as a base for your own customizations, or used straight out of the box \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-cache/v2/cache.go b/vendor/codeberg.org/gruf/go-cache/v2/cache.go
deleted file mode 100644
index b0d697687..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v2/cache.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package cache
-
-import "time"
-
-// Cache represents a TTL cache with customizable callbacks, it
-// exists here to abstract away the "unsafe" methods in the case that
-// you do not want your own implementation atop TTLCache{}.
-type Cache[Key comparable, Value any] interface {
- // Start will start the cache background eviction routine with given sweep frequency.
- // If already running or a freq <= 0 provided, this is a no-op. This will block until
- // the eviction routine has started
- Start(freq time.Duration) bool
-
- // Stop will stop cache background eviction routine. If not running this is a no-op. This
- // will block until the eviction routine has stopped
- Stop() bool
-
- // SetEvictionCallback sets the eviction callback to the provided hook
- SetEvictionCallback(hook Hook[Key, Value])
-
- // SetInvalidateCallback sets the invalidate callback to the provided hook
- SetInvalidateCallback(hook Hook[Key, Value])
-
- // SetTTL sets the cache item TTL. Update can be specified to force updates of existing items in
- // the cache, this will simply add the change in TTL to their current expiry time
- SetTTL(ttl time.Duration, update bool)
-
- // Get fetches the value with key from the cache, extending its TTL
- Get(key Key) (value Value, ok bool)
-
- // Put attempts to place the value at key in the cache, doing nothing if
- // a value with this key already exists. Returned bool is success state
- Put(key Key, value Value) bool
-
- // Set places the value at key in the cache. This will overwrite any
- // existing value, and call the update callback so. Existing values
- // will have their TTL extended upon update
- Set(key Key, value Value)
-
- // CAS will attempt to perform a CAS operation on 'key', using provided
- // comparison and swap values. Returned bool is success.
- CAS(key Key, cmp, swp Value) bool
-
- // Swap will attempt to perform a swap on 'key', replacing the value there
- // and returning the existing value. If no value exists for key, this will
- // set the value and return the zero value for V.
- Swap(key Key, swp Value) Value
-
- // Has checks the cache for a value with key, this will not update TTL
- Has(key Key) bool
-
- // Invalidate deletes a value from the cache, calling the invalidate callback
- Invalidate(key Key) bool
-
- // Clear empties the cache, calling the invalidate callback
- Clear()
-
- // Size returns the current size of the cache
- Size() int
-}
-
-// New returns a new initialized Cache.
-func New[K comparable, V any]() Cache[K, V] {
- c := &TTLCache[K, V]{}
- c.Init()
- return c
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v2/compare.go b/vendor/codeberg.org/gruf/go-cache/v2/compare.go
deleted file mode 100644
index 749d6c05f..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v2/compare.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package cache
-
-import (
- "reflect"
-)
-
-type Comparable interface {
- Equal(any) bool
-}
-
-// Compare returns whether 2 values are equal using the Comparable
-// interface, or failing that falls back to use reflect.DeepEqual().
-func Compare(i1, i2 any) bool {
- c1, ok1 := i1.(Comparable)
- if ok1 {
- return c1.Equal(i2)
- }
- c2, ok2 := i2.(Comparable)
- if ok2 {
- return c2.Equal(i1)
- }
- return reflect.DeepEqual(i1, i2)
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v2/hook.go b/vendor/codeberg.org/gruf/go-cache/v2/hook.go
deleted file mode 100644
index 45ef8c92e..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v2/hook.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package cache
-
-// Hook defines a function hook that can be supplied as a callback.
-type Hook[Key comparable, Value any] func(key Key, value Value)
-
-func emptyHook[K comparable, V any](K, V) {}
diff --git a/vendor/codeberg.org/gruf/go-cache/v2/lookup.go b/vendor/codeberg.org/gruf/go-cache/v2/lookup.go
deleted file mode 100644
index d353b2959..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v2/lookup.go
+++ /dev/null
@@ -1,210 +0,0 @@
-package cache
-
-// LookupCfg is the LookupCache configuration.
-type LookupCfg[OGKey, AltKey comparable, Value any] struct {
- // RegisterLookups is called on init to register lookups
- // within LookupCache's internal LookupMap
- RegisterLookups func(*LookupMap[OGKey, AltKey])
-
- // AddLookups is called on each addition to the cache, to
- // set any required additional key lookups for supplied item
- AddLookups func(*LookupMap[OGKey, AltKey], Value)
-
- // DeleteLookups is called on each eviction/invalidation of
- // an item in the cache, to remove any unused key lookups
- DeleteLookups func(*LookupMap[OGKey, AltKey], Value)
-}
-
-// LookupCache is a cache built on-top of TTLCache, providing multi-key
-// lookups for items in the cache by means of additional lookup maps. These
-// maps simply store additional keys => original key, with hook-ins to automatically
-// call user supplied functions on adding an item, or on updating/deleting an
-// item to keep the LookupMap up-to-date.
-type LookupCache[OGKey, AltKey comparable, Value any] interface {
- Cache[OGKey, Value]
-
- // GetBy fetches a cached value by supplied lookup identifier and key
- GetBy(lookup string, key AltKey) (value Value, ok bool)
-
- // CASBy will attempt to perform a CAS operation on supplied lookup identifier and key
- CASBy(lookup string, key AltKey, cmp, swp Value) bool
-
- // SwapBy will attempt to perform a swap operation on supplied lookup identifier and key
- SwapBy(lookup string, key AltKey, swp Value) Value
-
- // HasBy checks if a value is cached under supplied lookup identifier and key
- HasBy(lookup string, key AltKey) bool
-
- // InvalidateBy invalidates a value by supplied lookup identifier and key
- InvalidateBy(lookup string, key AltKey) bool
-}
-
-type lookupTTLCache[OK, AK comparable, V any] struct {
- TTLCache[OK, V]
- config LookupCfg[OK, AK, V]
- lookup LookupMap[OK, AK]
-}
-
-// NewLookup returns a new initialized LookupCache.
-func NewLookup[OK, AK comparable, V any](cfg LookupCfg[OK, AK, V]) LookupCache[OK, AK, V] {
- switch {
- case cfg.RegisterLookups == nil:
- panic("cache: nil lookups register function")
- case cfg.AddLookups == nil:
- panic("cache: nil lookups add function")
- case cfg.DeleteLookups == nil:
- panic("cache: nil delete lookups function")
- }
- c := &lookupTTLCache[OK, AK, V]{config: cfg}
- c.TTLCache.Init()
- c.lookup.lookup = make(map[string]map[AK]OK)
- c.config.RegisterLookups(&c.lookup)
- c.SetEvictionCallback(nil)
- c.SetInvalidateCallback(nil)
- return c
-}
-
-func (c *lookupTTLCache[OK, AK, V]) SetEvictionCallback(hook Hook[OK, V]) {
- if hook == nil {
- hook = emptyHook[OK, V]
- }
- c.TTLCache.SetEvictionCallback(func(key OK, value V) {
- hook(key, value)
- c.config.DeleteLookups(&c.lookup, value)
- })
-}
-
-func (c *lookupTTLCache[OK, AK, V]) SetInvalidateCallback(hook Hook[OK, V]) {
- if hook == nil {
- hook = emptyHook[OK, V]
- }
- c.TTLCache.SetInvalidateCallback(func(key OK, value V) {
- hook(key, value)
- c.config.DeleteLookups(&c.lookup, value)
- })
-}
-
-func (c *lookupTTLCache[OK, AK, V]) GetBy(lookup string, key AK) (V, bool) {
- c.Lock()
- origKey, ok := c.lookup.Get(lookup, key)
- if !ok {
- c.Unlock()
- var value V
- return value, false
- }
- v, ok := c.GetUnsafe(origKey)
- c.Unlock()
- return v, ok
-}
-
-func (c *lookupTTLCache[OK, AK, V]) Put(key OK, value V) bool {
- c.Lock()
- put := c.PutUnsafe(key, value)
- if put {
- c.config.AddLookups(&c.lookup, value)
- }
- c.Unlock()
- return put
-}
-
-func (c *lookupTTLCache[OK, AK, V]) Set(key OK, value V) {
- c.Lock()
- defer c.Unlock()
- c.SetUnsafe(key, value)
- c.config.AddLookups(&c.lookup, value)
-}
-
-func (c *lookupTTLCache[OK, AK, V]) CASBy(lookup string, key AK, cmp, swp V) bool {
- c.Lock()
- defer c.Unlock()
- origKey, ok := c.lookup.Get(lookup, key)
- if !ok {
- return false
- }
- return c.CASUnsafe(origKey, cmp, swp)
-}
-
-func (c *lookupTTLCache[OK, AK, V]) SwapBy(lookup string, key AK, swp V) V {
- c.Lock()
- defer c.Unlock()
- origKey, ok := c.lookup.Get(lookup, key)
- if !ok {
- var value V
- return value
- }
- return c.SwapUnsafe(origKey, swp)
-}
-
-func (c *lookupTTLCache[OK, AK, V]) HasBy(lookup string, key AK) bool {
- c.Lock()
- has := c.lookup.Has(lookup, key)
- c.Unlock()
- return has
-}
-
-func (c *lookupTTLCache[OK, AK, V]) InvalidateBy(lookup string, key AK) bool {
- c.Lock()
- defer c.Unlock()
- origKey, ok := c.lookup.Get(lookup, key)
- if !ok {
- return false
- }
- c.InvalidateUnsafe(origKey)
- return true
-}
-
-// LookupMap is a structure that provides lookups for
-// keys to primary keys under supplied lookup identifiers.
-// This is essentially a wrapper around map[string](map[K1]K2).
-type LookupMap[OK comparable, AK comparable] struct {
- lookup map[string](map[AK]OK)
-}
-
-// RegisterLookup registers a lookup identifier in the LookupMap,
-// note this can only be doing during the cfg.RegisterLookups() hook.
-func (l *LookupMap[OK, AK]) RegisterLookup(id string) {
- if _, ok := l.lookup[id]; ok {
- panic("cache: lookup mapping already exists for identifier")
- }
- l.lookup[id] = make(map[AK]OK, 100)
-}
-
-// Get fetches an entry's primary key for lookup identifier and key.
-func (l *LookupMap[OK, AK]) Get(id string, key AK) (OK, bool) {
- keys, ok := l.lookup[id]
- if !ok {
- var key OK
- return key, false
- }
- origKey, ok := keys[key]
- return origKey, ok
-}
-
-// Set adds a lookup to the LookupMap under supplied lookup identifier,
-// linking supplied key to the supplied primary (original) key.
-func (l *LookupMap[OK, AK]) Set(id string, key AK, origKey OK) {
- keys, ok := l.lookup[id]
- if !ok {
- panic("cache: invalid lookup identifier")
- }
- keys[key] = origKey
-}
-
-// Has checks if there exists a lookup for supplied identifier and key.
-func (l *LookupMap[OK, AK]) Has(id string, key AK) bool {
- keys, ok := l.lookup[id]
- if !ok {
- return false
- }
- _, ok = keys[key]
- return ok
-}
-
-// Delete removes a lookup from LookupMap with supplied identifier and key.
-func (l *LookupMap[OK, AK]) Delete(id string, key AK) {
- keys, ok := l.lookup[id]
- if !ok {
- return
- }
- delete(keys, key)
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v2/scheduler.go b/vendor/codeberg.org/gruf/go-cache/v2/scheduler.go
deleted file mode 100644
index bc1d8074a..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v2/scheduler.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package cache
-
-import (
- "time"
-
- "codeberg.org/gruf/go-sched"
-)
-
-// scheduler is the global cache runtime scheduler
-// for handling regular cache evictions.
-var scheduler = sched.NewScheduler(5)
-
-// schedule will given sweep routine to the global scheduler, and start global scheduler.
-func schedule(sweep func(time.Time), freq time.Duration) func() {
- go scheduler.Start() // does nothing if already running
- return scheduler.Schedule(sched.NewJob(sweep).Every(freq))
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v2/ttl.go b/vendor/codeberg.org/gruf/go-cache/v2/ttl.go
deleted file mode 100644
index a5b6637b2..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v2/ttl.go
+++ /dev/null
@@ -1,310 +0,0 @@
-package cache
-
-import (
- "sync"
- "time"
-)
-
-// TTLCache is the underlying Cache implementation, providing both the base
-// Cache interface and access to "unsafe" methods so that you may build your
-// customized caches ontop of this structure.
-type TTLCache[Key comparable, Value any] struct {
- cache map[Key](*entry[Value])
- evict Hook[Key, Value] // the evict hook is called when an item is evicted from the cache, includes manual delete
- invalid Hook[Key, Value] // the invalidate hook is called when an item's data in the cache is invalidated
- ttl time.Duration // ttl is the item TTL
- stop func() // stop is the cancel function for the scheduled eviction routine
- mu sync.Mutex // mu protects TTLCache for concurrent access
-}
-
-// Init performs Cache initialization. MUST be called.
-func (c *TTLCache[K, V]) Init() {
- c.cache = make(map[K](*entry[V]), 100)
- c.evict = emptyHook[K, V]
- c.invalid = emptyHook[K, V]
- c.ttl = time.Minute * 5
-}
-
-func (c *TTLCache[K, V]) Start(freq time.Duration) (ok bool) {
- // Nothing to start
- if freq <= 0 {
- return false
- }
-
- // Safely start
- c.mu.Lock()
-
- if ok = c.stop == nil; ok {
- // Not yet running, schedule us
- c.stop = schedule(c.sweep, freq)
- }
-
- // Done with lock
- c.mu.Unlock()
-
- return
-}
-
-func (c *TTLCache[K, V]) Stop() (ok bool) {
- // Safely stop
- c.mu.Lock()
-
- if ok = c.stop != nil; ok {
- // We're running, cancel evicts
- c.stop()
- c.stop = nil
- }
-
- // Done with lock
- c.mu.Unlock()
-
- return
-}
-
-// sweep attempts to evict expired items (with callback!) from cache.
-func (c *TTLCache[K, V]) sweep(now time.Time) {
- // Lock and defer unlock (in case of hook panic)
- c.mu.Lock()
- defer c.mu.Unlock()
-
- // Sweep the cache for old items!
- for key, item := range c.cache {
- if now.After(item.expiry) {
- c.evict(key, item.value)
- delete(c.cache, key)
- }
- }
-}
-
-// Lock locks the cache mutex.
-func (c *TTLCache[K, V]) Lock() {
- c.mu.Lock()
-}
-
-// Unlock unlocks the cache mutex.
-func (c *TTLCache[K, V]) Unlock() {
- c.mu.Unlock()
-}
-
-func (c *TTLCache[K, V]) SetEvictionCallback(hook Hook[K, V]) {
- // Ensure non-nil hook
- if hook == nil {
- hook = emptyHook[K, V]
- }
-
- // Safely set evict hook
- c.mu.Lock()
- c.evict = hook
- c.mu.Unlock()
-}
-
-func (c *TTLCache[K, V]) SetInvalidateCallback(hook Hook[K, V]) {
- // Ensure non-nil hook
- if hook == nil {
- hook = emptyHook[K, V]
- }
-
- // Safely set invalidate hook
- c.mu.Lock()
- c.invalid = hook
- c.mu.Unlock()
-}
-
-func (c *TTLCache[K, V]) SetTTL(ttl time.Duration, update bool) {
- // Safely update TTL
- c.mu.Lock()
- diff := ttl - c.ttl
- c.ttl = ttl
-
- if update {
- // Update existing cache entries
- for _, entry := range c.cache {
- entry.expiry.Add(diff)
- }
- }
-
- // We're done
- c.mu.Unlock()
-}
-
-func (c *TTLCache[K, V]) Get(key K) (V, bool) {
- c.mu.Lock()
- value, ok := c.GetUnsafe(key)
- c.mu.Unlock()
- return value, ok
-}
-
-// GetUnsafe is the mutex-unprotected logic for Cache.Get().
-func (c *TTLCache[K, V]) GetUnsafe(key K) (V, bool) {
- item, ok := c.cache[key]
- if !ok {
- var value V
- return value, false
- }
- item.expiry = time.Now().Add(c.ttl)
- return item.value, true
-}
-
-func (c *TTLCache[K, V]) Put(key K, value V) bool {
- c.mu.Lock()
- success := c.PutUnsafe(key, value)
- c.mu.Unlock()
- return success
-}
-
-// PutUnsafe is the mutex-unprotected logic for Cache.Put().
-func (c *TTLCache[K, V]) PutUnsafe(key K, value V) bool {
- // If already cached, return
- if _, ok := c.cache[key]; ok {
- return false
- }
-
- // Create new cached item
- c.cache[key] = &entry[V]{
- value: value,
- expiry: time.Now().Add(c.ttl),
- }
-
- return true
-}
-
-func (c *TTLCache[K, V]) Set(key K, value V) {
- c.mu.Lock()
- defer c.mu.Unlock() // defer in case of hook panic
- c.SetUnsafe(key, value)
-}
-
-// SetUnsafe is the mutex-unprotected logic for Cache.Set(), it calls externally-set functions.
-func (c *TTLCache[K, V]) SetUnsafe(key K, value V) {
- item, ok := c.cache[key]
- if ok {
- // call invalidate hook
- c.invalid(key, item.value)
- } else {
- // alloc new item
- item = &entry[V]{}
- c.cache[key] = item
- }
-
- // Update the item + expiry
- item.value = value
- item.expiry = time.Now().Add(c.ttl)
-}
-
-func (c *TTLCache[K, V]) CAS(key K, cmp V, swp V) bool {
- c.mu.Lock()
- ok := c.CASUnsafe(key, cmp, swp)
- c.mu.Unlock()
- return ok
-}
-
-// CASUnsafe is the mutex-unprotected logic for Cache.CAS().
-func (c *TTLCache[K, V]) CASUnsafe(key K, cmp V, swp V) bool {
- // Check for item
- item, ok := c.cache[key]
- if !ok || !Compare(item.value, cmp) {
- return false
- }
-
- // Invalidate item
- c.invalid(key, item.value)
-
- // Update item + expiry
- item.value = swp
- item.expiry = time.Now().Add(c.ttl)
-
- return ok
-}
-
-func (c *TTLCache[K, V]) Swap(key K, swp V) V {
- c.mu.Lock()
- old := c.SwapUnsafe(key, swp)
- c.mu.Unlock()
- return old
-}
-
-// SwapUnsafe is the mutex-unprotected logic for Cache.Swap().
-func (c *TTLCache[K, V]) SwapUnsafe(key K, swp V) V {
- // Check for item
- item, ok := c.cache[key]
- if !ok {
- var value V
- return value
- }
-
- // invalidate old item
- c.invalid(key, item.value)
- old := item.value
-
- // update item + expiry
- item.value = swp
- item.expiry = time.Now().Add(c.ttl)
-
- return old
-}
-
-func (c *TTLCache[K, V]) Has(key K) bool {
- c.mu.Lock()
- ok := c.HasUnsafe(key)
- c.mu.Unlock()
- return ok
-}
-
-// HasUnsafe is the mutex-unprotected logic for Cache.Has().
-func (c *TTLCache[K, V]) HasUnsafe(key K) bool {
- _, ok := c.cache[key]
- return ok
-}
-
-func (c *TTLCache[K, V]) Invalidate(key K) bool {
- c.mu.Lock()
- defer c.mu.Unlock()
- return c.InvalidateUnsafe(key)
-}
-
-// InvalidateUnsafe is mutex-unprotected logic for Cache.Invalidate().
-func (c *TTLCache[K, V]) InvalidateUnsafe(key K) bool {
- // Check if we have item with key
- item, ok := c.cache[key]
- if !ok {
- return false
- }
-
- // Call hook, remove from cache
- c.invalid(key, item.value)
- delete(c.cache, key)
- return true
-}
-
-func (c *TTLCache[K, V]) Clear() {
- c.mu.Lock()
- defer c.mu.Unlock()
- c.ClearUnsafe()
-}
-
-// ClearUnsafe is mutex-unprotected logic for Cache.Clean().
-func (c *TTLCache[K, V]) ClearUnsafe() {
- for key, item := range c.cache {
- c.invalid(key, item.value)
- delete(c.cache, key)
- }
-}
-
-func (c *TTLCache[K, V]) Size() int {
- c.mu.Lock()
- sz := c.SizeUnsafe()
- c.mu.Unlock()
- return sz
-}
-
-// SizeUnsafe is mutex unprotected logic for Cache.Size().
-func (c *TTLCache[K, V]) SizeUnsafe() int {
- return len(c.cache)
-}
-
-// entry represents an item in the cache, with
-// it's currently calculated expiry time.
-type entry[Value any] struct {
- value Value
- expiry time.Time
-}
diff --git a/vendor/codeberg.org/gruf/go-debug/LICENSE b/vendor/codeberg.org/gruf/go-debug/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-debug/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-debug/README.md b/vendor/codeberg.org/gruf/go-debug/README.md
deleted file mode 100644
index 44cbc9d5f..000000000
--- a/vendor/codeberg.org/gruf/go-debug/README.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# go-debug
-
-This library provides a very simple method for compile-time or runtime determined debug checks, set using build tags.
-
-The compile-time checks use Go constants, so when disabled your debug code will not be compiled.
-
-The possible build tags are:
-
-- "debug" || "" = debug determined at compile-time
-
-- "debugenv" = debug determined at runtime using the $DEBUG environment variable
-
-An example for how this works in practice can be seen by the following code:
-
-```
-func main() {
- println("debug.DEBUG() =", debug.DEBUG())
-}
-```
-
-```
-# Debug determined at compile-time, it is disabled
-$ go run .
-debug.DEBUG() = false
-
-# Debug determined at compile-time, it is enabled
-$ go run -tags=debug .
-debug.DEBUG() = true
-
-# Debug determined at runtime, $DEBUG is not set
-$ go run -tags=debugenv .
-debug.DEBUG() = false
-
-# Debug determined at runtime, $DEBUG is set
-$ DEBUG=y go run -tags=debugenv .
-debug.DEBUG() = true
-``` \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-debug/debug.go b/vendor/codeberg.org/gruf/go-debug/debug.go
deleted file mode 100644
index 6b5e56548..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package debug
-
-import (
- _debug "runtime/debug"
-)
-
-// DEBUG returns whether debugging is enabled.
-func DEBUG() bool {
- return debug
-}
-
-// Run will only call fn if DEBUG is enabled.
-func Run(fn func()) {
- if debug {
- fn()
- }
-}
-
-// BuildInfo will return a useful new-line separated build info string for current binary, setting name as given value.
-func BuildInfo(name string) string {
- // Read build info from current binary
- build, ok := _debug.ReadBuildInfo()
- if !ok {
- return "name=" + name + "\n"
- }
-
- var flags, vcs, commit, time string
-
- // Parse build information from BuildInfo.Settings
- for i := 0; i < len(build.Settings); i++ {
- switch build.Settings[i].Key {
- case "-gcflags":
- flags += ` -gcflags="` + build.Settings[i].Value + `"`
- case "-ldflags":
- flags += ` -ldflags="` + build.Settings[i].Value + `"`
- case "-tags":
- flags += ` -tags="` + build.Settings[i].Value + `"`
- case "vcs":
- vcs = build.Settings[i].Value
- case "vcs.revision":
- commit = build.Settings[i].Value
- if len(commit) > 8 {
- commit = commit[:8]
- }
- case "vcs.time":
- time = build.Settings[i].Value
- }
- }
-
- return "" +
- "name=" + name + "\n" +
- "vcs=" + vcs + "\n" +
- "commit=" + commit + "\n" +
- "version=" + build.Main.Version + "\n" +
- "path=" + build.Path + "\n" +
- "build=" + build.GoVersion + flags + "\n" +
- "time=" + time + "\n"
-}
diff --git a/vendor/codeberg.org/gruf/go-debug/debug_env.go b/vendor/codeberg.org/gruf/go-debug/debug_env.go
deleted file mode 100644
index 7ab231b08..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug_env.go
+++ /dev/null
@@ -1,9 +0,0 @@
-//go:build debugenv
-// +build debugenv
-
-package debug
-
-import "os"
-
-// check if debug env variable is set
-var debug = (os.Getenv("DEBUG") != "")
diff --git a/vendor/codeberg.org/gruf/go-debug/debug_off.go b/vendor/codeberg.org/gruf/go-debug/debug_off.go
deleted file mode 100644
index a7eb9daac..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug_off.go
+++ /dev/null
@@ -1,7 +0,0 @@
-//go:build !debug && !debugenv
-// +build !debug,!debugenv
-
-package debug
-
-// debug always off.
-const debug = false
diff --git a/vendor/codeberg.org/gruf/go-debug/debug_on.go b/vendor/codeberg.org/gruf/go-debug/debug_on.go
deleted file mode 100644
index 744d70178..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug_on.go
+++ /dev/null
@@ -1,7 +0,0 @@
-//go:build debug && !debugenv
-// +build debug,!debugenv
-
-package debug
-
-// debug always on.
-const debug = true
diff --git a/vendor/codeberg.org/gruf/go-debug/pprof_off.go b/vendor/codeberg.org/gruf/go-debug/pprof_off.go
deleted file mode 100644
index 5ad77ce0d..000000000
--- a/vendor/codeberg.org/gruf/go-debug/pprof_off.go
+++ /dev/null
@@ -1,16 +0,0 @@
-//go:build !debug && !debugenv
-// +build !debug,!debugenv
-
-package debug
-
-import "net/http"
-
-// ServePprof will start an HTTP server serving /debug/pprof only if debug enabled.
-func ServePprof(addr string) error {
- return nil
-}
-
-// WithPprof will add /debug/pprof handling (provided by "net/http/pprof") only if debug enabled.
-func WithPprof(handler http.Handler) http.Handler {
- return handler
-}
diff --git a/vendor/codeberg.org/gruf/go-debug/pprof_on.go b/vendor/codeberg.org/gruf/go-debug/pprof_on.go
deleted file mode 100644
index a569ab823..000000000
--- a/vendor/codeberg.org/gruf/go-debug/pprof_on.go
+++ /dev/null
@@ -1,63 +0,0 @@
-//go:build debug || debugenv
-// +build debug debugenv
-
-package debug
-
-import (
- "net/http"
- "net/http/pprof"
- "strings"
-)
-
-// ServePprof will start an HTTP server serving /debug/pprof only if debug enabled.
-func ServePprof(addr string) error {
- if !debug {
- // debug disabled in env
- return nil
- }
- handler := WithPprof(nil)
- return http.ListenAndServe(addr, handler)
-}
-
-// WithPprof will add /debug/pprof handling (provided by "net/http/pprof") only if debug enabled.
-func WithPprof(handler http.Handler) http.Handler {
- if !debug {
- // debug disabled in env
- return handler
- }
-
- // Default serve mux is setup with pprof
- pprofmux := http.DefaultServeMux
-
- if pprofmux == nil {
- // Someone nil'ed the default mux
- pprofmux = &http.ServeMux{}
- pprofmux.HandleFunc("/debug/pprof/", pprof.Index)
- pprofmux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
- pprofmux.HandleFunc("/debug/pprof/profile", pprof.Profile)
- pprofmux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
- pprofmux.HandleFunc("/debug/pprof/trace", pprof.Trace)
- }
-
- if handler == nil {
- // Ensure handler is non-nil
- handler = http.NotFoundHandler()
- }
-
- // Debug enabled, return wrapped handler func
- return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
- const prefix = "/debug/pprof"
-
- // /debug/pprof(/.*)? -> pass to pprofmux
- if strings.HasPrefix(r.URL.Path, prefix) {
- path := r.URL.Path[len(prefix):]
- if path == "" || path[0] == '/' {
- pprofmux.ServeHTTP(rw, r)
- return
- }
- }
-
- // .* -> pass to handler
- handler.ServeHTTP(rw, r)
- })
-}
diff --git a/vendor/codeberg.org/gruf/go-debug/run_tests.sh b/vendor/codeberg.org/gruf/go-debug/run_tests.sh
deleted file mode 100644
index f7ef1d60d..000000000
--- a/vendor/codeberg.org/gruf/go-debug/run_tests.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-(
- # Run in subshell with cmd echo
- set -ex
-
- # Run debug tests
- DEBUG= go test -tags= -v
- DEBUG= go test -tags=debug -v
- DEBUG= go test -tags=debugenv -v
- DEBUG=y go test -tags=debugenv -v
- DEBUG=1 go test -tags=debugenv -v
- DEBUG=y go test -tags=debugenv,debug -v
- DEBUG=y go test -tags= -v
-)
-
-echo 'success!' \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/LICENSE b/vendor/codeberg.org/gruf/go-errors/v2/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/README.md b/vendor/codeberg.org/gruf/go-errors/v2/README.md
deleted file mode 100644
index 90049abec..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# go-errors
-
-simple but powerful errors library that allows easy wrapping and stacktracing of errors.
-
-to disable stacktraces set the `notrace` build tag. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/callers.go b/vendor/codeberg.org/gruf/go-errors/v2/callers.go
deleted file mode 100644
index 77a2c1c1b..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/callers.go
+++ /dev/null
@@ -1,102 +0,0 @@
-package errors
-
-import (
- "encoding/json"
- "runtime"
- "strconv"
- "strings"
- "unsafe"
-)
-
-// Callers is a stacktrace of caller PCs.
-type Callers []uintptr
-
-// GetCallers returns a Callers slice of PCs, of at most 'depth'.
-func GetCallers(skip int, depth int) Callers {
- rpc := make([]uintptr, depth)
- n := runtime.Callers(skip+1, rpc)
- return Callers(rpc[0:n])
-}
-
-// Frames fetches runtime frames for a slice of caller PCs.
-func (f Callers) Frames() []runtime.Frame {
- // Allocate expected frames slice
- frames := make([]runtime.Frame, 0, len(f))
-
- // Get frames iterator for PCs
- iter := runtime.CallersFrames(f)
-
- for {
- // Get next frame in iter
- frame, ok := iter.Next()
- if !ok {
- break
- }
-
- // Append to frames slice
- frames = append(frames, frame)
- }
-
- return frames
-}
-
-// MarshalJSON implements json.Marshaler to provide an easy, simply default.
-func (f Callers) MarshalJSON() ([]byte, error) {
- // JSON-able frame type
- type frame struct {
- Func string `json:"func"`
- File string `json:"file"`
- Line int `json:"line"`
- }
-
- // Allocate expected frames slice
- frames := make([]frame, 0, len(f))
-
- // Get frames iterator for PCs
- iter := runtime.CallersFrames(f)
-
- for {
- // Get next frame
- f, ok := iter.Next()
- if !ok {
- break
- }
-
- // Append to frames slice
- frames = append(frames, frame{
- Func: funcname(f.Function),
- File: f.File,
- Line: f.Line,
- })
- }
-
- // marshal converted frames
- return json.Marshal(frames)
-}
-
-// String will return a simple string representation of receiving Callers slice.
-func (f Callers) String() string {
- // Guess-timate to reduce allocs
- buf := make([]byte, 0, 64*len(f))
-
- // Convert to frames
- frames := f.Frames()
-
- for i := 0; i < len(frames); i++ {
- frame := frames[i]
-
- // Append formatted caller info
- funcname := funcname(frame.Function)
- buf = append(buf, funcname+"()\n\t"+frame.File+":"...)
- buf = strconv.AppendInt(buf, int64(frame.Line), 10)
- buf = append(buf, '\n')
- }
-
- return *(*string)(unsafe.Pointer(&buf))
-}
-
-// funcname splits a function name with pkg from its path prefix.
-func funcname(name string) string {
- i := strings.LastIndex(name, "/")
- return name[i+1:]
-}
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/error.go b/vendor/codeberg.org/gruf/go-errors/v2/error.go
deleted file mode 100644
index ed1217a29..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/error.go
+++ /dev/null
@@ -1,35 +0,0 @@
-//go:build !notrace
-// +build !notrace
-
-package errors
-
-type errormsg struct {
- msg string
- wrap error
- stack Callers
-}
-
-func create(msg string, wrap error) *errormsg {
- return &errormsg{
- msg: msg,
- wrap: wrap,
- stack: GetCallers(2, 10),
- }
-}
-
-func (err *errormsg) Error() string {
- return err.msg
-}
-
-func (err *errormsg) Is(target error) bool {
- other, ok := target.(*errormsg)
- return ok && (err.msg == other.msg)
-}
-
-func (err *errormsg) Unwrap() error {
- return err.wrap
-}
-
-func (err *errormsg) Stacktrace() Callers {
- return err.stack
-}
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/error_notrace.go b/vendor/codeberg.org/gruf/go-errors/v2/error_notrace.go
deleted file mode 100644
index e5faf80a2..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/error_notrace.go
+++ /dev/null
@@ -1,33 +0,0 @@
-//go:build notrace
-// +build notrace
-
-package errors
-
-type errormsg struct {
- msg string
- wrap error
-}
-
-func create(msg string, wrap error) *errormsg {
- return &errormsg{
- msg: msg,
- wrap: wrap,
- }
-}
-
-func (err *errormsg) Error() string {
- return err.msg
-}
-
-func (err *errormsg) Is(target error) bool {
- other, ok := target.(*errormsg)
- return ok && (err.msg == other.msg)
-}
-
-func (err *errormsg) Unwrap() error {
- return err.wrap
-}
-
-func (err *errormsg) Stacktrace() Callers {
- return nil
-}
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/errors.go b/vendor/codeberg.org/gruf/go-errors/v2/errors.go
deleted file mode 100644
index 180fc6799..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/errors.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package errors
-
-import (
- "fmt"
-)
-
-// New returns a new error created from message.
-func New(msg string) error {
- return create(msg, nil)
-}
-
-// Newf returns a new error created from message format and args.
-func Newf(msgf string, args ...interface{}) error {
- return create(fmt.Sprintf(msgf, args...), nil)
-}
-
-// Wrap will wrap supplied error within a new error created from message.
-func Wrap(err error, msg string) error {
- return create(msg, err)
-}
-
-// Wrapf will wrap supplied error within a new error created from message format and args.
-func Wrapf(err error, msgf string, args ...interface{}) error {
- return create(fmt.Sprintf(msgf, args...), err)
-}
-
-// Stacktrace fetches a stored stacktrace of callers from an error, or returns nil.
-func Stacktrace(err error) Callers {
- var callers Callers
- if err, ok := err.(interface { //nolint
- Stacktrace() Callers
- }); ok {
- callers = err.Stacktrace()
- }
- return callers
-}
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/once.go b/vendor/codeberg.org/gruf/go-errors/v2/once.go
deleted file mode 100644
index 83a45a61f..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/once.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package errors
-
-import (
- "sync/atomic"
- "unsafe"
-)
-
-// OnceError is an error structure that supports safe multi
-// threaded usage and setting only once (until reset).
-type OnceError struct{ err unsafe.Pointer }
-
-// NewOnce returns a new OnceError instance.
-func NewOnce() OnceError {
- return OnceError{
- err: nil,
- }
-}
-
-// Store will safely set the OnceError to value, no-op if nil.
-func (e *OnceError) Store(err error) {
- // Nothing to do
- if err == nil {
- return
- }
-
- // Only set if not already
- atomic.CompareAndSwapPointer(
- &e.err,
- nil,
- unsafe.Pointer(&err),
- )
-}
-
-// Load will load the currently stored error.
-func (e *OnceError) Load() error {
- return *(*error)(atomic.LoadPointer(&e.err))
-}
-
-// IsSet returns whether OnceError has been set.
-func (e *OnceError) IsSet() bool {
- return (atomic.LoadPointer(&e.err) != nil)
-}
-
-// Reset will reset the OnceError value.
-func (e *OnceError) Reset() {
- atomic.StorePointer(&e.err, nil)
-}
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/standard.go b/vendor/codeberg.org/gruf/go-errors/v2/standard.go
deleted file mode 100644
index 2a4671153..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/standard.go
+++ /dev/null
@@ -1,106 +0,0 @@
-package errors
-
-import (
- "errors"
- "reflect"
-
- "codeberg.org/gruf/go-bitutil"
-)
-
-// Is reports whether any error in err's chain matches any of targets
-// (up to a max of 64 targets).
-//
-// The chain consists of err itself followed by the sequence of errors obtained by
-// repeatedly calling Unwrap.
-//
-// An error is considered to match a target if it is equal to that target or if
-// it implements a method Is(error) bool such that Is(target) returns true.
-func Is(err error, targets ...error) bool {
- var flags bitutil.Flags64
-
- // Flags only has 64 bit slots
- if len(targets) > 64 {
- panic("too many targets")
- }
-
- // Check if error is nil so we can catch
- // the fast-case where a target is nil
- isNil := (err == nil)
-
- for i := 0; i < len(targets); {
- // Drop nil targets
- if targets[i] == nil {
- if isNil /* match! */ {
- return true
- }
- targets = append(targets[:i], targets[i+1:]...)
- continue
- }
-
- // Check if this error is directly comparable
- if reflect.TypeOf(targets[i]).Comparable() {
- flags = flags.Set(uint8(i))
- }
-
- i++
- }
-
- for err != nil {
- var errorIs func(error) bool
-
- // Check if this layer supports .Is interface
- is, ok := err.(interface{ Is(error) bool })
- if ok {
- errorIs = is.Is
- } else {
- errorIs = neveris
- }
-
- for i := 0; i < len(targets); i++ {
- // Try directly compare errors
- if flags.Get(uint8(i)) &&
- err == targets[i] {
- return true
- }
-
- // Try use .Is() interface
- if errorIs(targets[i]) {
- return true
- }
- }
-
- // Unwrap to next layer
- err = errors.Unwrap(err)
- }
-
- return false
-}
-
-// As finds the first error in err's chain that matches target, and if one is found, sets
-// target to that error value and returns true. Otherwise, it returns false.
-//
-// The chain consists of err itself followed by the sequence of errors obtained by
-// repeatedly calling Unwrap.
-//
-// An error matches target if the error's concrete value is assignable to the value
-// pointed to by target, or if the error has a method As(interface{}) bool such that
-// As(target) returns true. In the latter case, the As method is responsible for
-// setting target.
-//
-// An error type might provide an As method so it can be treated as if it were a
-// different error type.
-//
-// As panics if target is not a non-nil pointer to either a type that implements
-// error, or to any interface type.
-func As(err error, target interface{}) bool {
- return errors.As(err, target)
-}
-
-// Unwrap returns the result of calling the Unwrap method on err, if err's
-// type contains an Unwrap method returning error. Otherwise, Unwrap returns nil.
-func Unwrap(err error) error {
- return errors.Unwrap(err)
-}
-
-// neveris fits the .Is(error) bool interface function always returning false.
-func neveris(error) bool { return false }
diff --git a/vendor/codeberg.org/gruf/go-fastcopy/README.md b/vendor/codeberg.org/gruf/go-fastcopy/README.md
deleted file mode 100644
index 0c1ff68f7..000000000
--- a/vendor/codeberg.org/gruf/go-fastcopy/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-fastcopy
-
-An `io.Copy()` implementation that uses a memory pool for the copy buffer. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-fastcopy/copy.go b/vendor/codeberg.org/gruf/go-fastcopy/copy.go
deleted file mode 100644
index 4716b140f..000000000
--- a/vendor/codeberg.org/gruf/go-fastcopy/copy.go
+++ /dev/null
@@ -1,134 +0,0 @@
-package fastcopy
-
-import (
- "io"
- "sync"
- _ "unsafe" // link to io.errInvalidWrite.
-)
-
-var (
- // global pool instance.
- pool = CopyPool{size: 4096}
-
- //go:linkname errInvalidWrite io.errInvalidWrite
- errInvalidWrite error
-)
-
-// CopyPool provides a memory pool of byte
-// buffers for io copies from readers to writers.
-type CopyPool struct {
- size int
- pool sync.Pool
-}
-
-// See CopyPool.Buffer().
-func Buffer(sz int) int {
- return pool.Buffer(sz)
-}
-
-// See CopyPool.CopyN().
-func CopyN(dst io.Writer, src io.Reader, n int64) (int64, error) {
- return pool.CopyN(dst, src, n)
-}
-
-// See CopyPool.Copy().
-func Copy(dst io.Writer, src io.Reader) (int64, error) {
- return pool.Copy(dst, src)
-}
-
-// Buffer sets the pool buffer size to allocate. Returns current size.
-// Note this is NOT atomically safe, please call BEFORE other calls to CopyPool.
-func (cp *CopyPool) Buffer(sz int) int {
- if sz > 0 {
- // update size
- cp.size = sz
- } else if cp.size < 1 {
- // default size
- return 4096
- }
- return cp.size
-}
-
-// CopyN performs the same logic as io.CopyN(), with the difference
-// being that the byte buffer is acquired from a memory pool.
-func (cp *CopyPool) CopyN(dst io.Writer, src io.Reader, n int64) (int64, error) {
- written, err := cp.Copy(dst, io.LimitReader(src, n))
- if written == n {
- return n, nil
- }
- if written < n && err == nil {
- // src stopped early; must have been EOF.
- err = io.EOF
- }
- return written, err
-}
-
-// Copy performs the same logic as io.Copy(), with the difference
-// being that the byte buffer is acquired from a memory pool.
-func (cp *CopyPool) Copy(dst io.Writer, src io.Reader) (int64, error) {
- // Prefer using io.WriterTo to do the copy (avoids alloc + copy)
- if wt, ok := src.(io.WriterTo); ok {
- return wt.WriteTo(dst)
- }
-
- // Prefer using io.ReaderFrom to do the copy.
- if rt, ok := dst.(io.ReaderFrom); ok {
- return rt.ReadFrom(src)
- }
-
- var buf []byte
-
- if b, ok := cp.pool.Get().([]byte); ok {
- // Acquired buf from pool
- buf = b
- } else {
- // Allocate new buffer of size
- buf = make([]byte, cp.Buffer(0))
- }
-
- // Defer release to pool
- defer cp.pool.Put(buf)
-
- var n int64
- for {
- // Perform next read into buf
- nr, err := src.Read(buf)
- if nr > 0 {
- // We error check AFTER checking
- // no. read bytes so incomplete
- // read still gets written up to nr.
-
- // Perform next write from buf
- nw, ew := dst.Write(buf[0:nr])
-
- // Check for valid write
- if nw < 0 || nr < nw {
- if ew == nil {
- ew = errInvalidWrite
- }
- return n, ew
- }
-
- // Incr total count
- n += int64(nw)
-
- // Check write error
- if ew != nil {
- return n, ew
- }
-
- // Check unequal read/writes
- if nr != nw {
- return n, io.ErrShortWrite
- }
- }
-
- // Return on err
- if err != nil {
- if err == io.EOF {
- err = nil // expected
- }
- return n, err
- }
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-fastpath/LICENSE b/vendor/codeberg.org/gruf/go-fastpath/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-fastpath/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-fastpath/README.md b/vendor/codeberg.org/gruf/go-fastpath/README.md
deleted file mode 100644
index f89700fb3..000000000
--- a/vendor/codeberg.org/gruf/go-fastpath/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Alternative path library with a `strings.Builder` like path builder. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-fastpath/benchmarks.png b/vendor/codeberg.org/gruf/go-fastpath/benchmarks.png
deleted file mode 100644
index 42ddc6d1e..000000000
--- a/vendor/codeberg.org/gruf/go-fastpath/benchmarks.png
+++ /dev/null
Binary files differ
diff --git a/vendor/codeberg.org/gruf/go-fastpath/path.go b/vendor/codeberg.org/gruf/go-fastpath/path.go
deleted file mode 100644
index d8f434fe6..000000000
--- a/vendor/codeberg.org/gruf/go-fastpath/path.go
+++ /dev/null
@@ -1,319 +0,0 @@
-package fastpath
-
-import (
- "unsafe"
-)
-
-// allocate these just once
-var (
- dot = []byte(dotStr)
- dotStr = "."
-)
-
-type Builder struct {
- B []byte // B is the underlying byte buffer
- dd int // pos of last '..' appended to builder
- abs bool // abs stores whether path passed to first .Append() is absolute
- set bool // set stores whether b.abs has been set i.e. not first call to .Append()
-}
-
-// NewBuilder returns a new Builder object using the
-// supplied byte slice as the underlying buffer
-func NewBuilder(b []byte) Builder {
- if b != nil {
- b = b[:0]
- }
- return Builder{
- B: b,
- dd: 0,
-
- abs: false,
- set: false,
- }
-}
-
-// Reset resets the Builder object
-func (b *Builder) Reset() {
- b.B = b.B[:0]
- b.dd = 0
- b.abs = false
- b.set = false
-}
-
-// Len returns the number of accumulated bytes in the Builder
-func (b *Builder) Len() int {
- return len(b.B)
-}
-
-// Cap returns the capacity of the underlying Builder buffer
-func (b *Builder) Cap() int {
- return cap(b.B)
-}
-
-// Bytes returns the accumulated path bytes.
-func (b *Builder) Bytes() []byte {
- if len(b.B) < 1 {
- return dot
- }
- return b.B
-}
-
-// String returns the accumulated path string.
-func (b *Builder) String() string {
- if len(b.B) < 1 {
- return dotStr
- }
- return string(b.B)
-}
-
-// StringPtr returns a ptr to the accumulated path string.
-//
-// Please note the underlying byte slice for this string is
-// tied to the builder, so any changes will result in the
-// returned string changing. Consider using .String() if
-// this is undesired behaviour.
-func (b *Builder) StringPtr() string {
- if len(b.B) < 1 {
- return dotStr
- }
- return *(*string)(unsafe.Pointer(&b.B))
-}
-
-// Absolute returns whether current path is absolute (not relative)
-func (b *Builder) Absolute() bool {
- return b.abs
-}
-
-// SetAbsolute converts the current path to / from absolute
-func (b *Builder) SetAbsolute(val bool) {
- if !b.set {
- if val {
- // .Append() has not been
- // called, add a '/' and set abs
- b.Guarantee(1)
- b.appendByte('/')
- b.abs = true
- }
-
- // Set as having been set
- b.set = true
- return
- }
-
- if !val && b.abs {
- // Already set and absolute. Update
- b.abs = false
-
- // If not empty (i.e. not just '/'),
- // then shift bytes 1 left
- if len(b.B) > 1 {
- copy(b.B, b.B[1:])
- }
-
- // Truncate 1 byte. In the case of empty,
- // i.e. just '/' then it will drop this
- b.truncate(1)
- } else if val && !b.abs {
- // Already set but NOT abs. Update
- b.abs = true
-
- // Guarantee 1 byte available
- b.Guarantee(1)
-
- // If empty, just append '/'
- if len(b.B) < 1 {
- b.appendByte('/')
- return
- }
-
- // Increase length
- l := len(b.B)
- b.B = b.B[:l+1]
-
- // Shift bytes 1 right
- copy(b.B[1:], b.B[:l])
-
- // Set first byte '/'
- b.B[0] = '/'
- }
-}
-
-// Append adds and cleans the supplied path bytes to the
-// builder's internal buffer, growing the buffer if necessary
-// to accomodate the extra path length
-func (b *Builder) Append(p []byte) {
- b.AppendString(*(*string)(unsafe.Pointer(&p)))
-}
-
-// AppendString adds and cleans the supplied path string to the
-// builder's internal buffer, growing the buffer if necessary
-// to accomodate the extra path length
-func (b *Builder) AppendString(path string) {
- defer func() {
- // If buffer is empty, and an absolute
- // path, ensure it starts with a '/'
- if len(b.B) < 1 && b.abs {
- b.appendByte('/')
- }
- }()
-
- // Empty path, nothing to do
- if len(path) == 0 {
- return
- }
-
- // Guarantee at least the total length
- // of supplied path available in the buffer
- b.Guarantee(len(path))
-
- // Try store if absolute
- if !b.set {
- b.abs = len(path) > 0 && path[0] == '/'
- b.set = true
- }
-
- i := 0
- for i < len(path) {
- switch {
- // Empty path segment
- case path[i] == '/':
- i++
-
- // Singular '.' path segment, treat as empty
- case path[i] == '.' && (i+1 == len(path) || path[i+1] == '/'):
- i++
-
- // Backtrack segment
- case path[i] == '.' && path[i+1] == '.' && (i+2 == len(path) || path[i+2] == '/'):
- i += 2
-
- switch {
- // Check if it's possible to backtrack with
- // our current state of the buffer. i.e. is
- // our buffer length longer than the last
- // '..' we placed?
- case len(b.B) > b.dd:
- b.backtrack()
- // b.cp = b.lp
- // b.lp = 0
-
- // If we reached here, need to check if
- // we can append '..' to the path buffer,
- // which is ONLY when path is NOT absolute
- case !b.abs:
- if len(b.B) > 0 {
- b.appendByte('/')
- }
- b.appendByte('.')
- b.appendByte('.')
- b.dd = len(b.B)
- // b.lp = lp - 2
- // b.cp = b.dd
- }
-
- default:
- if (b.abs && len(b.B) != 1) || (!b.abs && len(b.B) > 0) {
- b.appendByte('/')
- }
- // b.lp = b.cp
- // b.cp = len(b.B)
- i += b.appendSlice(path[i:])
- }
- }
-}
-
-// Clean creates the shortest possible functional equivalent
-// to the supplied path, resetting the builder before performing
-// this operation. The builder object is NOT reset after return
-func (b *Builder) Clean(path string) string {
- b.Reset()
- b.AppendString(path)
- return b.String()
-}
-
-// Join connects and cleans multiple paths, resetting the builder before
-// performing this operation and returning the shortest possible combination
-// of all the supplied paths. The builder object is NOT reset after return
-func (b *Builder) Join(base string, paths ...string) string {
- b.Reset()
- b.AppendString(base)
- size := len(base)
- for i := 0; i < len(paths); i++ {
- b.AppendString(paths[i])
- size += len(paths[i])
- }
- if size < 1 {
- return ""
- } else if len(b.B) < 1 {
- return dotStr
- }
- return string(b.B)
-}
-
-// Guarantee ensures there is at least the requested size
-// free bytes available in the buffer, reallocating if necessary
-func (b *Builder) Guarantee(size int) {
- if size > cap(b.B)-len(b.B) {
- nb := make([]byte, 2*cap(b.B)+size)
- copy(nb, b.B)
- b.B = nb[:len(b.B)]
- }
-}
-
-// Truncate reduces the length of the buffer by the requested
-// number of bytes. If the builder is set to absolute, the first
-// byte (i.e. '/') will never be truncated
-func (b *Builder) Truncate(size int) {
- // If absolute and just '/', do nothing
- if b.abs && len(b.B) == 1 {
- return
- }
-
- // Truncate requested bytes
- b.truncate(size)
-}
-
-// truncate reduces the length of the buffer by the requested
-// size, no sanity checks are performed
-func (b *Builder) truncate(size int) {
- b.B = b.B[:len(b.B)-size]
-}
-
-// appendByte appends the supplied byte to the end of
-// the buffer. appending is achieved by continually reslicing the
-// buffer and setting the next byte-at-index, this is safe as guarantee()
-// will have been called beforehand
-func (b *Builder) appendByte(c byte) {
- b.B = b.B[:len(b.B)+1]
- b.B[len(b.B)-1] = c
-}
-
-// appendSlice appends the supplied string slice to
-// the end of the buffer and returns the number of indices
-// we were able to iterate before hitting a path separator '/'.
-// appending is achieved by continually reslicing the buffer
-// and setting the next byte-at-index, this is safe as guarantee()
-// will have been called beforehand
-func (b *Builder) appendSlice(slice string) int {
- i := 0
- for i < len(slice) && slice[i] != '/' {
- b.B = b.B[:len(b.B)+1]
- b.B[len(b.B)-1] = slice[i]
- i++
- }
- return i
-}
-
-// backtrack reduces the end of the buffer back to the last
-// separating '/', or end of buffer
-func (b *Builder) backtrack() {
- b.B = b.B[:len(b.B)-1]
-
- for len(b.B)-1 > b.dd && b.B[len(b.B)-1] != '/' {
- b.B = b.B[:len(b.B)-1]
- }
-
- if len(b.B) > 0 {
- b.B = b.B[:len(b.B)-1]
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-hashenc/LICENSE b/vendor/codeberg.org/gruf/go-hashenc/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-hashenc/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-hashenc/README.md b/vendor/codeberg.org/gruf/go-hashenc/README.md
deleted file mode 100644
index e885d0bb2..000000000
--- a/vendor/codeberg.org/gruf/go-hashenc/README.md
+++ /dev/null
@@ -1 +0,0 @@
-HashEncoder provides a means of quickly hash-summing and encoding data \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-hashenc/enc.go b/vendor/codeberg.org/gruf/go-hashenc/enc.go
deleted file mode 100644
index 0cc8d5986..000000000
--- a/vendor/codeberg.org/gruf/go-hashenc/enc.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package hashenc
-
-import (
- "encoding/base32"
- "encoding/base64"
- "encoding/hex"
-)
-
-// Encoder defines an interface for encoding binary data.
-type Encoder interface {
- // Encode encodes the data at src into dst
- Encode(dst []byte, src []byte)
-
- // EncodedLen returns the encoded length for input data of supplied length
- EncodedLen(int) int
-}
-
-// Base32 returns a new base32 Encoder (StdEncoding, no padding).
-func Base32() Encoder {
- return base32.StdEncoding.WithPadding(base64.NoPadding)
-}
-
-// Base64 returns a new base64 Encoder (URLEncoding, no padding).
-func Base64() Encoder {
- return base64.URLEncoding.WithPadding(base64.NoPadding)
-}
-
-// Hex returns a new hex Encoder.
-func Hex() Encoder {
- return &hexEncoder{}
-}
-
-// hexEncoder simply provides an empty receiver to satisfy Encoder.
-type hexEncoder struct{}
-
-func (*hexEncoder) Encode(dst []byte, src []byte) {
- hex.Encode(dst, src)
-}
-
-func (*hexEncoder) EncodedLen(len int) int {
- return hex.EncodedLen(len)
-}
diff --git a/vendor/codeberg.org/gruf/go-hashenc/hashenc.go b/vendor/codeberg.org/gruf/go-hashenc/hashenc.go
deleted file mode 100644
index fc110c533..000000000
--- a/vendor/codeberg.org/gruf/go-hashenc/hashenc.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package hashenc
-
-import (
- "hash"
-
- "codeberg.org/gruf/go-bytes"
-)
-
-// HashEncoder defines an interface for calculating encoded hash sums of binary data
-type HashEncoder interface {
- // EncodeSum calculates the hash sum of src and encodes (at most) Size() into dst
- EncodeSum(dst []byte, src []byte)
-
- // EncodedSum calculates the encoded hash sum of src and returns data in a newly allocated bytes.Bytes
- EncodedSum(src []byte) bytes.Bytes
-
- // Size returns the expected length of encoded hashes
- Size() int
-}
-
-// New returns a new HashEncoder instance based on supplied hash.Hash and Encoder supplying functions.
-func New(hash hash.Hash, enc Encoder) HashEncoder {
- hashSize := hash.Size()
- return &henc{
- hash: hash,
- hbuf: make([]byte, hashSize),
- enc: enc,
- size: enc.EncodedLen(hashSize),
- }
-}
-
-// henc is the HashEncoder implementation.
-type henc struct {
- hash hash.Hash
- hbuf []byte
- enc Encoder
- size int
-}
-
-func (henc *henc) EncodeSum(dst []byte, src []byte) {
- // Hash supplied bytes
- henc.hash.Reset()
- henc.hash.Write(src)
- henc.hbuf = henc.hash.Sum(henc.hbuf[:0])
-
- // Encode the hashsum and return a copy
- henc.enc.Encode(dst, henc.hbuf)
-}
-
-func (henc *henc) EncodedSum(src []byte) bytes.Bytes {
- dst := make([]byte, henc.size)
- henc.EncodeSum(dst, src)
- return bytes.ToBytes(dst)
-}
-
-func (henc *henc) Size() int {
- return henc.size
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/LICENSE b/vendor/codeberg.org/gruf/go-kv/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-kv/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-kv/README.md b/vendor/codeberg.org/gruf/go-kv/README.md
deleted file mode 100644
index fa4735868..000000000
--- a/vendor/codeberg.org/gruf/go-kv/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# go-kv
-
-This library provides a key-value field structure `kv.Field{}` that plays well with the `"fmt"` package. It gives an easy means of appending key-value fields to log entries, in a manner that also happens to look nice! (it's not far removed from using a `map[string]interface{}`).
-
-The formatting for these key-value fields is handled by the `"fmt"` package by default. If you set the `kvformat` build tag then it will use a custom formatting library found under `format/`. You can see the benchmarks for both below.
-
-![benchmarks](https://codeberg.org/gruf/go-kv/raw/main/benchmark.png)
-
-TODO: benchmarks comparing these to using `fmt.Sprintf("%q=%+v", ...)` yourself. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-kv/benchmark.png b/vendor/codeberg.org/gruf/go-kv/benchmark.png
deleted file mode 100644
index 08d838643..000000000
--- a/vendor/codeberg.org/gruf/go-kv/benchmark.png
+++ /dev/null
Binary files differ
diff --git a/vendor/codeberg.org/gruf/go-kv/field.go b/vendor/codeberg.org/gruf/go-kv/field.go
deleted file mode 100644
index 7ff6f1ca3..000000000
--- a/vendor/codeberg.org/gruf/go-kv/field.go
+++ /dev/null
@@ -1,105 +0,0 @@
-package kv
-
-import (
- "codeberg.org/gruf/go-byteutil"
-)
-
-// bufsize is the default buffer size per field to alloc
-// when calling .AppendFormat() from within .String().
-const bufsize = 64
-
-// Fields is a typedef for a []Field slice to provide
-// slightly more performant string formatting for multiples.
-type Fields []Field
-
-// Get will return the field with given 'key'.
-func (f Fields) Get(key string) (*Field, bool) {
- for i := 0; i < len(f); i++ {
- if f[i].K == key {
- return &f[i], true
- }
- }
- return nil, false
-}
-
-// Set will set an existing field with 'key' to 'value', or append new.
-func (f *Fields) Set(key string, value interface{}) {
- for i := 0; i < len(*f); i++ {
- // Update existing value
- if (*f)[i].K == key {
- (*f)[i].V = value
- return
- }
- }
-
- // Append new field
- *f = append(*f, Field{
- K: key,
- V: value,
- })
-}
-
-// AppendFormat appends a string representation of receiving Field(s) to 'b'.
-func (f Fields) AppendFormat(buf *byteutil.Buffer, vbose bool) {
- for i := 0; i < len(f); i++ {
- f[i].AppendFormat(buf, vbose)
- buf.WriteByte(' ')
- }
- if len(f) > 0 {
- buf.Truncate(1)
- }
-}
-
-// String returns a string representation of receiving Field(s).
-func (f Fields) String() string {
- b := make([]byte, 0, bufsize*len(f))
- buf := byteutil.Buffer{B: b}
- f.AppendFormat(&buf, false)
- return buf.String()
-}
-
-// GoString performs .String() but with type prefix.
-func (f Fields) GoString() string {
- b := make([]byte, 0, bufsize*len(f))
- buf := byteutil.Buffer{B: b}
- f.AppendFormat(&buf, true)
- return "kv.Fields{" + buf.String() + "}"
-}
-
-// Field represents an individual key-value field.
-type Field struct {
- K string // Field key
- V interface{} // Field value
-}
-
-// Key returns the formatted key string of this Field.
-func (f Field) Key() string {
- buf := byteutil.Buffer{B: make([]byte, 0, bufsize/2)}
- appendQuoteKey(&buf, f.K)
- return buf.String()
-}
-
-// String will return a string representation of this Field
-// of the form `key=value` where `value` is formatted using
-// fmt package's `%+v` directive. If the .X = true (verbose),
-// then it uses '%#v'. Both key and value are escaped and
-// quoted if necessary to fit on single line.
-//
-// If the `kvformat` build tag is provided, the formatting
-// will be performed by the `kv/format` package. In this case
-// the value will be formatted using the `{:v}` directive, or
-// `{:?}` if .X = true (verbose).
-func (f Field) String() string {
- b := make([]byte, 0, bufsize)
- buf := byteutil.Buffer{B: b}
- f.AppendFormat(&buf, false)
- return buf.String()
-}
-
-// GoString performs .String() but with verbose always enabled.
-func (f Field) GoString() string {
- b := make([]byte, 0, bufsize)
- buf := byteutil.Buffer{B: b}
- f.AppendFormat(&buf, true)
- return buf.String()
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/field_fmt.go b/vendor/codeberg.org/gruf/go-kv/field_fmt.go
deleted file mode 100644
index c62393fe0..000000000
--- a/vendor/codeberg.org/gruf/go-kv/field_fmt.go
+++ /dev/null
@@ -1,36 +0,0 @@
-//go:build !kvformat
-// +build !kvformat
-
-package kv
-
-import (
- "fmt"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-// AppendFormat will append formatted format of Field to 'buf'. See .String() for details.
-func (f Field) AppendFormat(buf *byteutil.Buffer, vbose bool) {
- var fmtstr string
- if vbose /* verbose */ {
- fmtstr = `%#v`
- } else /* regular */ {
- fmtstr = `%+v`
- }
- appendQuoteKey(buf, f.K)
- buf.WriteByte('=')
- appendQuoteValue(buf, fmt.Sprintf(fmtstr, f.V))
-}
-
-// Value returns the formatted value string of this Field.
-func (f Field) Value(vbose bool) string {
- var fmtstr string
- if vbose /* verbose */ {
- fmtstr = `%#v`
- } else /* regular */ {
- fmtstr = `%+v`
- }
- buf := byteutil.Buffer{B: make([]byte, 0, bufsize/2)}
- appendQuoteValue(&buf, fmt.Sprintf(fmtstr, f.V))
- return buf.String()
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/field_format.go b/vendor/codeberg.org/gruf/go-kv/field_format.go
deleted file mode 100644
index db1ffc721..000000000
--- a/vendor/codeberg.org/gruf/go-kv/field_format.go
+++ /dev/null
@@ -1,35 +0,0 @@
-//go:build kvformat
-// +build kvformat
-
-package kv
-
-import (
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-kv/format"
-)
-
-// AppendFormat will append formatted format of Field to 'buf'. See .String() for details.
-func (f Field) AppendFormat(buf *byteutil.Buffer, vbose bool) {
- var fmtstr string
- if vbose /* verbose */ {
- fmtstr = "{:?}"
- } else /* regular */ {
- fmtstr = "{:v}"
- }
- appendQuoteKey(buf, f.K)
- buf.WriteByte('=')
- format.Appendf(buf, fmtstr, f.V)
-}
-
-// Value returns the formatted value string of this Field.
-func (f Field) Value(vbose bool) string {
- var fmtstr string
- if vbose /* verbose */ {
- fmtstr = "{:?}"
- } else /* regular */ {
- fmtstr = "{:v}"
- }
- buf := byteutil.Buffer{B: make([]byte, 0, bufsize/2)}
- format.Appendf(&buf, fmtstr, f.V)
- return buf.String()
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/format/README.md b/vendor/codeberg.org/gruf/go-kv/format/README.md
deleted file mode 100644
index fe7b2338d..000000000
--- a/vendor/codeberg.org/gruf/go-kv/format/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-String formatting package using Rust-style formatting directives, geared specifcally towards formatting arguments for key-value log output. Provides ONLY default, key, value and verbose formatting directives. For most formatting cases you will be best served by `"fmt"`.
-
-Generally more visually friendly than `"fmt"` and performance is much improved.
-
-![benchmarks](https://codeberg.org/gruf/go-kv/raw/main/format/benchmark.png) \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-kv/format/benchmark.png b/vendor/codeberg.org/gruf/go-kv/format/benchmark.png
deleted file mode 100644
index 7151fbc55..000000000
--- a/vendor/codeberg.org/gruf/go-kv/format/benchmark.png
+++ /dev/null
Binary files differ
diff --git a/vendor/codeberg.org/gruf/go-kv/format/format.go b/vendor/codeberg.org/gruf/go-kv/format/format.go
deleted file mode 100644
index df5a94b7c..000000000
--- a/vendor/codeberg.org/gruf/go-kv/format/format.go
+++ /dev/null
@@ -1,922 +0,0 @@
-package format
-
-import (
- "reflect"
- "strconv"
- "unicode/utf8"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-const (
- // Flag bit constants, note they are prioritised in this order.
- IsKeyBit = uint8(1) << 0 // set to indicate key formatting
- VboseBit = uint8(1) << 1 // set to indicate verbose formatting
- IsValBit = uint8(1) << 2 // set to indicate value formatting
- PanicBit = uint8(1) << 3 // set after panic to prevent recursion
-)
-
-// format provides formatting of values into a Buffer.
-type format struct {
- // Flags are the currently set value flags.
- Flags uint8
-
- // Derefs is the current value dereference count.
- Derefs uint8
-
- // CurDepth is the current Format iterator depth.
- CurDepth uint8
-
- // VType is the current value type.
- VType string
-
- // Config is the set Formatter config (MUST NOT be nil).
- Config *Formatter
-
- // Buffer is the currently set output buffer.
- Buffer *byteutil.Buffer
-}
-
-// AtMaxDepth returns whether format is currently at max depth.
-func (f format) AtMaxDepth() bool {
- return f.CurDepth > f.Config.MaxDepth
-}
-
-// Key returns whether the isKey flag is set.
-func (f format) Key() bool {
- return (f.Flags & IsKeyBit) != 0
-}
-
-// Value returns whether the isVal flag is set.
-func (f format) Value() bool {
- return (f.Flags & IsValBit) != 0
-}
-
-// Verbose returns whether the verbose flag is set.
-func (f format) Verbose() bool {
- return (f.Flags & VboseBit) != 0
-}
-
-// Panic returns whether the panic flag is set.
-func (f format) Panic() bool {
- return (f.Flags & PanicBit) != 0
-}
-
-// SetKey returns format instance with the IsKey bit set to true,
-// note this resets the dereference count.
-func (f format) SetKey() format {
- flags := f.Flags | IsKeyBit
- flags &= ^IsValBit
- return format{
- Flags: flags,
- CurDepth: f.CurDepth,
- Config: f.Config,
- Buffer: f.Buffer,
- }
-}
-
-// SetValue returns format instance with the IsVal bit set to true,
-// note this resets the dereference count.
-func (f format) SetValue() format {
- flags := f.Flags | IsValBit
- flags &= ^IsKeyBit
- return format{
- Flags: flags,
- CurDepth: f.CurDepth,
- Config: f.Config,
- Buffer: f.Buffer,
- }
-}
-
-// SetVerbose returns format instance with the Vbose bit set to true,
-// note this resets the dereference count.
-func (f format) SetVerbose() format {
- return format{
- Flags: f.Flags | VboseBit,
- CurDepth: f.CurDepth,
- Config: f.Config,
- Buffer: f.Buffer,
- }
-}
-
-// SetPanic returns format instance with the panic bit set to true,
-// note this resets the dereference count and sets IsVal (unsetting IsKey) bit.
-func (f format) SetPanic() format {
- flags := f.Flags | PanicBit
- flags |= IsValBit
- flags &= ^IsKeyBit
- return format{
- Flags: flags,
- CurDepth: f.CurDepth,
- Config: f.Config,
- Buffer: f.Buffer,
- }
-}
-
-// IncrDepth returns format instance with depth incremented and derefs reset.
-func (f format) IncrDepth() format {
- return format{
- Flags: f.Flags,
- Derefs: f.Derefs,
- CurDepth: f.CurDepth + 1,
- Config: f.Config,
- Buffer: f.Buffer,
- }
-}
-
-// IncrDerefs returns format instance with dereference count incremented.
-func (f format) IncrDerefs() format {
- return format{
- Flags: f.Flags,
- Derefs: f.Derefs + 1,
- CurDepth: f.CurDepth,
- Config: f.Config,
- Buffer: f.Buffer,
- }
-}
-
-func (f format) AppendType() {
- const derefs = `********************************` +
- `********************************` +
- `********************************` +
- `********************************` +
- `********************************` +
- `********************************` +
- `********************************` +
- `********************************`
- f.Buffer.B = append(f.Buffer.B, derefs[:f.Derefs]...)
- f.Buffer.B = append(f.Buffer.B, f.VType...)
-}
-
-func (f format) AppendNil() {
- if !f.Verbose() {
- f.Buffer.B = append(f.Buffer.B, `nil`...)
- return
- }
-
- // Append nil with type
- f.Buffer.B = append(f.Buffer.B, '(')
- f.AppendType()
- f.Buffer.B = append(f.Buffer.B, `)(nil`...)
- f.Buffer.B = append(f.Buffer.B, ')')
-}
-
-func (f format) AppendByte(b byte) {
- switch {
- // Always quoted
- case f.Key():
- f.Buffer.B = append(f.Buffer.B, '\'')
- f.Buffer.B = append(f.Buffer.B, byte2str(b)...)
- f.Buffer.B = append(f.Buffer.B, '\'')
-
- // Always quoted ASCII with type
- case f.Verbose():
- f._AppendPrimitiveTyped(func(f format) {
- f.Buffer.B = append(f.Buffer.B, '\'')
- f.Buffer.B = append(f.Buffer.B, byte2str(b)...)
- f.Buffer.B = append(f.Buffer.B, '\'')
- })
-
- // Always quoted
- case f.Value():
- f.Buffer.B = append(f.Buffer.B, '\'')
- f.Buffer.B = append(f.Buffer.B, byte2str(b)...)
- f.Buffer.B = append(f.Buffer.B, '\'')
-
- // Append as raw byte
- default:
- f.Buffer.B = append(f.Buffer.B, b)
- }
-}
-
-func (f format) AppendBytes(b []byte) {
- switch {
- // Bytes CAN be nil formatted
- case b == nil:
- f.AppendNil()
-
- // Handle bytes as string key
- case f.Key():
- f.AppendStringKey(b2s(b))
-
- // Append as separate ASCII quoted bytes in slice
- case f.Verbose():
- f._AppendArrayTyped(func(f format) {
- for i := 0; i < len(b); i++ {
- f.Buffer.B = append(f.Buffer.B, '\'')
- f.Buffer.B = append(f.Buffer.B, byte2str(b[i])...)
- f.Buffer.B = append(f.Buffer.B, `',`...)
- }
- if len(b) > 0 {
- f.Buffer.Truncate(1)
- }
- })
-
- // Append as quoted string
- case f.Value():
- f.AppendStringQuoted(b2s(b))
-
- // Append as raw bytes
- default:
- f.Buffer.B = append(f.Buffer.B, b...)
- }
-}
-
-func (f format) AppendRune(r rune) {
- switch {
- // Quoted only if spaces/requires escaping
- case f.Key():
- f.AppendRuneKey(r)
-
- // Always quoted ASCII with type
- case f.Verbose():
- f._AppendPrimitiveTyped(func(f format) {
- f.Buffer.B = strconv.AppendQuoteRuneToASCII(f.Buffer.B, r)
- })
-
- // Always quoted value
- case f.Value():
- f.Buffer.B = strconv.AppendQuoteRune(f.Buffer.B, r)
-
- // Append as raw rune
- default:
- f.Buffer.WriteRune(r)
- }
-}
-
-func (f format) AppendRuneKey(r rune) {
- if utf8.RuneLen(r) > 1 && (r < ' ' && r != '\t') || r == '`' || r == '\u007F' {
- // Quote and escape this rune
- f.Buffer.B = strconv.AppendQuoteRuneToASCII(f.Buffer.B, r)
- } else {
- // Simply append rune
- f.Buffer.WriteRune(r)
- }
-}
-
-func (f format) AppendRunes(r []rune) {
- switch {
- // Runes CAN be nil formatted
- case r == nil:
- f.AppendNil()
-
- // Handle bytes as string key
- case f.Key():
- f.AppendStringKey(string(r))
-
- // Append as separate ASCII quoted bytes in slice
- case f.Verbose():
- f._AppendArrayTyped(func(f format) {
- for i := 0; i < len(r); i++ {
- f.Buffer.B = strconv.AppendQuoteRuneToASCII(f.Buffer.B, r[i])
- f.Buffer.B = append(f.Buffer.B, ',')
- }
- if len(r) > 0 {
- f.Buffer.Truncate(1)
- }
- })
-
- // Append as quoted string
- case f.Value():
- f.AppendStringQuoted(string(r))
-
- // Append as raw bytes
- default:
- for i := 0; i < len(r); i++ {
- f.Buffer.WriteRune(r[i])
- }
- }
-}
-
-func (f format) AppendString(s string) {
- switch {
- // Quoted only if spaces/requires escaping
- case f.Key():
- f.AppendStringKey(s)
-
- // Always quoted with type
- case f.Verbose():
- f._AppendPrimitiveTyped(func(f format) {
- f.AppendStringQuoted(s)
- })
-
- // Always quoted string
- case f.Value():
- f.AppendStringQuoted(s)
-
- // All else
- default:
- f.Buffer.B = append(f.Buffer.B, s...)
- }
-}
-
-func (f format) AppendStringKey(s string) {
- if !strconv.CanBackquote(s) {
- // Requires quoting AND escaping
- f.Buffer.B = strconv.AppendQuote(f.Buffer.B, s)
- } else if ContainsDoubleQuote(s) {
- // Contains double quotes, needs escaping
- f.Buffer.B = AppendEscape(f.Buffer.B, s)
- } else if len(s) < 1 || ContainsSpaceOrTab(s) {
- // Contains space, needs quotes
- f.Buffer.B = append(f.Buffer.B, '"')
- f.Buffer.B = append(f.Buffer.B, s...)
- f.Buffer.B = append(f.Buffer.B, '"')
- } else {
- // All else write as-is
- f.Buffer.B = append(f.Buffer.B, s...)
- }
-}
-
-func (f format) AppendStringQuoted(s string) {
- if !strconv.CanBackquote(s) {
- // Requires quoting AND escaping
- f.Buffer.B = strconv.AppendQuote(f.Buffer.B, s)
- } else if ContainsDoubleQuote(s) {
- // Contains double quotes, needs escaping
- f.Buffer.B = append(f.Buffer.B, '"')
- f.Buffer.B = AppendEscape(f.Buffer.B, s)
- f.Buffer.B = append(f.Buffer.B, '"')
- } else {
- // Simply append with quotes
- f.Buffer.B = append(f.Buffer.B, '"')
- f.Buffer.B = append(f.Buffer.B, s...)
- f.Buffer.B = append(f.Buffer.B, '"')
- }
-}
-
-func (f format) AppendBool(b bool) {
- if f.Verbose() {
- // Append as bool with type information
- f._AppendPrimitiveTyped(func(f format) {
- f.Buffer.B = strconv.AppendBool(f.Buffer.B, b)
- })
- } else {
- // Simply append as bool
- f.Buffer.B = strconv.AppendBool(f.Buffer.B, b)
- }
-}
-
-func (f format) AppendInt(i int64) {
- f._AppendPrimitiveType(func(f format) {
- f.Buffer.B = strconv.AppendInt(f.Buffer.B, i, 10)
- })
-}
-
-func (f format) AppendUint(u uint64) {
- f._AppendPrimitiveType(func(f format) {
- f.Buffer.B = strconv.AppendUint(f.Buffer.B, u, 10)
- })
-}
-
-func (f format) AppendFloat(l float64) {
- f._AppendPrimitiveType(func(f format) {
- f.AppendFloatValue(l)
- })
-}
-
-func (f format) AppendFloatValue(l float64) {
- f.Buffer.B = strconv.AppendFloat(f.Buffer.B, l, 'f', -1, 64)
-}
-
-func (f format) AppendComplex(c complex128) {
- f._AppendPrimitiveType(func(f format) {
- f.AppendFloatValue(real(c))
- f.Buffer.B = append(f.Buffer.B, '+')
- f.AppendFloatValue(imag(c))
- f.Buffer.B = append(f.Buffer.B, 'i')
- })
-}
-
-func (f format) AppendPtr(u uint64) {
- f._AppendPtrType(func(f format) {
- if u == 0 {
- // Append as nil
- f.Buffer.B = append(f.Buffer.B, `nil`...)
- } else {
- // Append as hex number
- f.Buffer.B = append(f.Buffer.B, `0x`...)
- f.Buffer.B = strconv.AppendUint(f.Buffer.B, u, 16)
- }
- })
-}
-
-func (f format) AppendInterfaceOrReflect(i interface{}) {
- if !f.AppendInterface(i) {
- // Interface append failed, used reflected value + type
- f.AppendReflectValue(reflect.ValueOf(i), reflect.TypeOf(i))
- }
-}
-
-func (f format) AppendInterfaceOrReflectNext(v reflect.Value, t reflect.Type) {
- // Check we haven't hit max
- if f.AtMaxDepth() {
- f.Buffer.B = append(f.Buffer.B, `...`...)
- return
- }
-
- // Incr the depth
- f = f.IncrDepth()
-
- // Make actual call
- f.AppendReflectOrInterface(v, t)
-}
-
-func (f format) AppendReflectOrInterface(v reflect.Value, t reflect.Type) {
- if !v.CanInterface() ||
- !f.AppendInterface(v.Interface()) {
- // Interface append failed, use reflect
- f.AppendReflectValue(v, t)
- }
-}
-
-func (f format) AppendInterface(i interface{}) bool {
- switch i := i.(type) {
- // Reflect types
- case reflect.Type:
- f.AppendReflectType(i)
- case reflect.Value:
- f.Buffer.B = append(f.Buffer.B, `reflect.Value`...)
- f.Buffer.B = append(f.Buffer.B, '(')
- f.Buffer.B = append(f.Buffer.B, i.String()...)
- f.Buffer.B = append(f.Buffer.B, ')')
-
- // Bytes, runes and string types
- case rune:
- f.VType = `int32`
- f.AppendRune(i)
- case []rune:
- f.VType = `[]int32`
- f.AppendRunes(i)
- case byte:
- f.VType = `uint8`
- f.AppendByte(i)
- case []byte:
- f.VType = `[]uint8`
- f.AppendBytes(i)
- case string:
- f.VType = `string`
- f.AppendString(i)
-
- // Int types
- case int:
- f.VType = `int`
- f.AppendInt(int64(i))
- case int8:
- f.VType = `int8`
- f.AppendInt(int64(i))
- case int16:
- f.VType = `int16`
- f.AppendInt(int64(i))
- case int64:
- f.VType = `int64`
- f.AppendInt(int64(i))
-
- // Uint types
- case uint:
- f.VType = `uint`
- f.AppendUint(uint64(i))
- case uint16:
- f.VType = `uint16`
- f.AppendUint(uint64(i))
- case uint32:
- f.VType = `uint32`
- f.AppendUint(uint64(i))
- case uint64:
- f.VType = `uint64`
- f.AppendUint(uint64(i))
-
- // Float types
- case float32:
- f.VType = `float32`
- f.AppendFloat(float64(i))
- case float64:
- f.VType = `float64`
- f.AppendFloat(float64(i))
-
- // Bool type
- case bool:
- f.VType = `bool`
- f.AppendBool(i)
-
- // Complex types
- case complex64:
- f.VType = `complex64`
- f.AppendComplex(complex128(i))
- case complex128:
- f.VType = `complex128`
- f.AppendComplex(complex128(i))
-
- // Method types
- case error:
- return f._AppendMethodType(func() string {
- return i.Error()
- }, i)
- case interface{ String() string }:
- return f._AppendMethodType(func() string {
- return i.String()
- }, i)
-
- // No quick handler
- default:
- return false
- }
-
- return true
-}
-
-func (f format) AppendReflectType(t reflect.Type) {
- switch f.VType = `reflect.Type`; {
- case isNil(t) /* safer nil check */ :
- f.AppendNil()
- case f.Verbose():
- f.AppendType()
- f.Buffer.B = append(f.Buffer.B, '(')
- f.Buffer.B = append(f.Buffer.B, t.String()...)
- f.Buffer.B = append(f.Buffer.B, ')')
- default:
- f.Buffer.B = append(f.Buffer.B, t.String()...)
- }
-}
-
-func (f format) AppendReflectValue(v reflect.Value, t reflect.Type) {
- switch v.Kind() {
- // String/byte types
- case reflect.String:
- f.VType = t.String()
- f.AppendString(v.String())
- case reflect.Uint8:
- f.VType = t.String()
- f.AppendByte(byte(v.Uint()))
- case reflect.Int32:
- f.VType = t.String()
- f.AppendRune(rune(v.Int()))
-
- // Float tpyes
- case reflect.Float32, reflect.Float64:
- f.VType = t.String()
- f.AppendFloat(v.Float())
-
- // Int types
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int64:
- f.VType = t.String()
- f.AppendInt(v.Int())
-
- // Uint types
- case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- f.VType = t.String()
- f.AppendUint(v.Uint())
-
- // Complex types
- case reflect.Complex64, reflect.Complex128:
- f.VType = t.String()
- f.AppendComplex(v.Complex())
-
- // Bool type
- case reflect.Bool:
- f.VType = t.String()
- f.AppendBool(v.Bool())
-
- // Slice and array types
- case reflect.Array:
- f.AppendArray(v, t)
- case reflect.Slice:
- f.AppendSlice(v, t)
-
- // Map types
- case reflect.Map:
- f.AppendMap(v, t)
-
- // Struct types
- case reflect.Struct:
- f.AppendStruct(v, t)
-
- // Interface type
- case reflect.Interface:
- if v.IsNil() {
- // Append nil ptr type
- f.VType = t.String()
- f.AppendNil()
- } else {
- // Append interface
- v = v.Elem()
- t = v.Type()
- f.AppendReflectOrInterface(v, t)
- }
-
- // Deref'able ptr type
- case reflect.Ptr:
- if v.IsNil() {
- // Append nil ptr type
- f.VType = t.String()
- f.AppendNil()
- } else {
- // Deref to next level
- f = f.IncrDerefs()
- v, t = v.Elem(), t.Elem()
- f.AppendReflectOrInterface(v, t)
- }
-
- // 'raw' pointer types
- case reflect.UnsafePointer, reflect.Func, reflect.Chan:
- f.VType = t.String()
- f.AppendPtr(uint64(v.Pointer()))
- case reflect.Uintptr:
- f.VType = t.String()
- f.AppendPtr(v.Uint())
-
- // Zero reflect value
- case reflect.Invalid:
- f.Buffer.B = append(f.Buffer.B, `nil`...)
-
- // All others
- default:
- f.VType = t.String()
- f.AppendType()
- }
-}
-
-func (f format) AppendSlice(v reflect.Value, t reflect.Type) {
- // Get slice value type
- f.VType = t.String()
-
- if t.Elem().Kind() == reflect.Uint8 {
- // This is a byte slice
- f.AppendBytes(v.Bytes())
- return
- }
-
- if v.IsNil() {
- // Nil slice
- f.AppendNil()
- return
- }
-
- if f.Verbose() {
- // Append array with type information
- f._AppendArrayTyped(func(f format) {
- f.AppendArrayElems(v, t)
- })
- } else {
- // Simply append array as elems
- f._AppendArray(func(f format) {
- f.AppendArrayElems(v, t)
- })
- }
-}
-
-func (f format) AppendArray(v reflect.Value, t reflect.Type) {
- // Get array value type
- f.VType = t.String()
-
- if f.Verbose() {
- // Append array with type information
- f._AppendArrayTyped(func(f format) {
- f.AppendArrayElems(v, t)
- })
- } else {
- // Simply append array as elems
- f._AppendArray(func(f format) {
- f.AppendArrayElems(v, t)
- })
- }
-}
-
-func (f format) AppendArrayElems(v reflect.Value, t reflect.Type) {
- // Get no. elems
- n := v.Len()
-
- // Get elem type
- et := t.Elem()
-
- // Append values
- for i := 0; i < n; i++ {
- f.SetValue().AppendInterfaceOrReflectNext(v.Index(i), et)
- f.Buffer.B = append(f.Buffer.B, ',')
- }
-
- // Drop last comma
- if n > 0 {
- f.Buffer.Truncate(1)
- }
-}
-
-func (f format) AppendMap(v reflect.Value, t reflect.Type) {
- // Get value type
- f.VType = t.String()
-
- if v.IsNil() {
- // Nil map -- no fields
- f.AppendNil()
- return
- }
-
- // Append field formatted map fields
- f._AppendFieldType(func(f format) {
- f.AppendMapFields(v, t)
- })
-}
-
-func (f format) AppendMapFields(v reflect.Value, t reflect.Type) {
- // Get a map iterator
- r := v.MapRange()
- n := v.Len()
-
- // Get key/val types
- kt := t.Key()
- kv := t.Elem()
-
- // Iterate pairs
- for r.Next() {
- f.SetKey().AppendInterfaceOrReflectNext(r.Key(), kt)
- f.Buffer.B = append(f.Buffer.B, '=')
- f.SetValue().AppendInterfaceOrReflectNext(r.Value(), kv)
- f.Buffer.B = append(f.Buffer.B, ' ')
- }
-
- // Drop last space
- if n > 0 {
- f.Buffer.Truncate(1)
- }
-}
-
-func (f format) AppendStruct(v reflect.Value, t reflect.Type) {
- // Get value type
- f.VType = t.String()
-
- // Append field formatted struct fields
- f._AppendFieldType(func(f format) {
- f.AppendStructFields(v, t)
- })
-}
-
-func (f format) AppendStructFields(v reflect.Value, t reflect.Type) {
- // Get field no.
- n := v.NumField()
-
- // Iterate struct fields
- for i := 0; i < n; i++ {
- vfield := v.Field(i)
- tfield := t.Field(i)
-
- // Append field name
- f.AppendStringKey(tfield.Name)
- f.Buffer.B = append(f.Buffer.B, '=')
- f.SetValue().AppendInterfaceOrReflectNext(vfield, tfield.Type)
-
- // Append separator
- f.Buffer.B = append(f.Buffer.B, ' ')
- }
-
- // Drop last space
- if n > 0 {
- f.Buffer.Truncate(1)
- }
-}
-
-func (f format) _AppendMethodType(method func() string, i interface{}) (ok bool) {
- // Verbose -- no methods
- if f.Verbose() {
- return false
- }
-
- // Catch nil type
- if isNil(i) {
- f.AppendNil()
- return true
- }
-
- // Catch any panics
- defer func() {
- if r := recover(); r != nil {
- // DON'T recurse catchPanic()
- if f.Panic() {
- panic(r)
- }
-
- // Attempt to decode panic into buf
- f.Buffer.B = append(f.Buffer.B, `!{PANIC=`...)
- f.SetPanic().AppendInterfaceOrReflect(r)
- f.Buffer.B = append(f.Buffer.B, '}')
-
- // Ensure no further attempts
- // to format after return
- ok = true
- }
- }()
-
- // Get method result
- result := method()
-
- switch {
- // Append as key formatted
- case f.Key():
- f.AppendStringKey(result)
-
- // Append as always quoted
- case f.Value():
- f.AppendStringQuoted(result)
-
- // Append as-is
- default:
- f.Buffer.B = append(f.Buffer.B, result...)
- }
-
- return true
-}
-
-// _AppendPrimitiveType is a helper to append prefix/suffix for primitives (numbers/bools/bytes/runes).
-func (f format) _AppendPrimitiveType(appendPrimitive func(format)) {
- if f.Verbose() {
- // Append value with type information
- f._AppendPrimitiveTyped(appendPrimitive)
- } else {
- // Append simply as-is
- appendPrimitive(f)
- }
-}
-
-// _AppendPrimitiveTyped is a helper to append prefix/suffix for primitives (numbers/bools/bytes/runes) with their types (if deref'd).
-func (f format) _AppendPrimitiveTyped(appendPrimitive func(format)) {
- if f.Derefs > 0 {
- // Is deref'd, append type info
- f.Buffer.B = append(f.Buffer.B, '(')
- f.AppendType()
- f.Buffer.WriteString(`)(`)
- appendPrimitive(f)
- f.Buffer.B = append(f.Buffer.B, ')')
- } else {
- // Simply append value
- appendPrimitive(f)
- }
-}
-
-// _AppendPtrType is a helper to append prefix/suffix for ptr types (with type if necessary).
-func (f format) _AppendPtrType(appendPtr func(format)) {
- if f.Verbose() {
- // Append value with type information
- f.Buffer.B = append(f.Buffer.B, '(')
- f.AppendType()
- f.Buffer.WriteString(`)(`)
- appendPtr(f)
- f.Buffer.B = append(f.Buffer.B, ')')
- } else {
- // Append simply as-is
- appendPtr(f)
- }
-}
-
-// _AppendArray is a helper to append prefix/suffix for array-types.
-func (f format) _AppendArray(appendArray func(format)) {
- f.Buffer.B = append(f.Buffer.B, '[')
- appendArray(f)
- f.Buffer.B = append(f.Buffer.B, ']')
-}
-
-// _AppendArrayTyped is a helper to append prefix/suffix for array-types with their types.
-func (f format) _AppendArrayTyped(appendArray func(format)) {
- f.AppendType()
- f.Buffer.B = append(f.Buffer.B, '{')
- appendArray(f)
- f.Buffer.B = append(f.Buffer.B, '}')
-}
-
-// _AppendFields is a helper to append prefix/suffix for field-types (with type if necessary).
-func (f format) _AppendFieldType(appendFields func(format)) {
- if f.Verbose() {
- f.AppendType()
- }
- f.Buffer.B = append(f.Buffer.B, '{')
- appendFields(f)
- f.Buffer.B = append(f.Buffer.B, '}')
-}
-
-// byte2str returns 'c' as a string, escaping if necessary.
-func byte2str(c byte) string {
- switch c {
- case '\a':
- return `\a`
- case '\b':
- return `\b`
- case '\f':
- return `\f`
- case '\n':
- return `\n`
- case '\r':
- return `\r`
- case '\t':
- return `\t`
- case '\v':
- return `\v`
- case '\'':
- return `\\`
- default:
- if c < ' ' {
- const hex = "0123456789abcdef"
- return `\x` +
- string(hex[c>>4]) +
- string(hex[c&0xF])
- }
- return string(c)
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/format/formatter.go b/vendor/codeberg.org/gruf/go-kv/format/formatter.go
deleted file mode 100644
index fd8cf98df..000000000
--- a/vendor/codeberg.org/gruf/go-kv/format/formatter.go
+++ /dev/null
@@ -1,349 +0,0 @@
-package format
-
-import (
- "strconv"
- "strings"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-// Formatter allows configuring value and string formatting.
-type Formatter struct {
- // MaxDepth specifies the max depth of fields the formatter will iterate.
- // Once max depth is reached, value will simply be formatted as "...".
- // e.g.
- //
- // MaxDepth=1
- // type A struct{
- // Nested B
- // }
- // type B struct{
- // Nested C
- // }
- // type C struct{
- // Field string
- // }
- //
- // Append(&buf, A{}) => {Nested={Nested={Field=...}}}
- MaxDepth uint8
-}
-
-// Append will append formatted form of supplied values into 'buf'.
-func (f *Formatter) Append(buf *byteutil.Buffer, v ...interface{}) {
- fmt := format{Buffer: buf, Config: f}
- for i := 0; i < len(v); i++ {
- fmt.AppendInterfaceOrReflect(v[i])
- fmt.Buffer.B = append(fmt.Buffer.B, ' ')
- }
- if len(v) > 0 {
- fmt.Buffer.Truncate(1)
- }
-}
-
-// Appendf will append the formatted string with supplied values into 'buf'.
-// Supported format directives:
-// - '{}' => format supplied arg, in place
-// - '{0}' => format arg at index 0 of supplied, in place
-// - '{:?}' => format supplied arg verbosely, in place
-// - '{:k}' => format supplied arg as key, in place
-// - '{:v}' => format supplied arg as value, in place
-//
-// To escape either of '{}' simply append an additional brace e.g.
-// - '{{' => '{'
-// - '}}' => '}'
-// - '{{}}' => '{}'
-// - '{{:?}}' => '{:?}'
-//
-// More formatting directives might be included in the future.
-func (f *Formatter) Appendf(buf *byteutil.Buffer, s string, a ...interface{}) {
- const (
- // ground state
- modeNone = uint8(0)
-
- // prev reached '{'
- modeOpen = uint8(1)
-
- // prev reached '}'
- modeClose = uint8(2)
-
- // parsing directive index
- modeIdx = uint8(3)
-
- // parsing directive operands
- modeOp = uint8(4)
- )
-
- var (
- // mode is current parsing mode
- mode uint8
-
- // arg is the current arg index
- arg int
-
- // carg is current directive-set arg index
- carg int
-
- // last is the trailing cursor to see slice windows
- last int
-
- // idx is the current index in 's'
- idx int
-
- // fmt is the base argument formatter
- fmt = format{
- Config: f,
- Buffer: buf,
- }
-
- // NOTE: these functions are defined here as function
- // locals as it turned out to be better for performance
- // doing it this way, than encapsulating their logic in
- // some kind of parsing structure. Maybe if the parser
- // was pooled along with the buffers it might work out
- // better, but then it makes more internal functions i.e.
- // .Append() .Appendf() less accessible outside package.
- //
- // Currently, passing '-gcflags "-l=4"' causes a not
- // insignificant decrease in ns/op, which is likely due
- // to more aggressive function inlining, which this
- // function can obviously stand to benefit from :)
-
- // Str returns current string window slice, and updates
- // the trailing cursor 'last' to current 'idx'
- Str = func() string {
- str := s[last:idx]
- last = idx
- return str
- }
-
- // MoveUp moves the trailing cursor 'last' just past 'idx'
- MoveUp = func() {
- last = idx + 1
- }
-
- // MoveUpTo moves the trailing cursor 'last' either up to
- // closest '}', or current 'idx', whichever is furthest.
- // NOTE: by calling bytealg.IndexByteString() directly (and
- // not the strconv pass-through, we shave-off complexity
- // which allows this function to be inlined).
- MoveUpTo = func() {
- i := strings.IndexByte(s[idx:], '}')
- if i >= 0 {
- idx += i
- }
- MoveUp()
- }
-
- // ParseIndex parses an integer from the current string
- // window, updating 'last' to 'idx'. The string window
- // is ASSUMED to contain only valid ASCII numbers. This
- // only returns false if number exceeds platform int size
- ParseIndex = func() bool {
- var str string
-
- // Get current window
- if str = Str(); len(str) < 1 {
- return true
- }
-
- // Index HAS to fit within platform integer size
- if !(strconv.IntSize == 32 && (0 < len(s) && len(s) < 10)) ||
- !(strconv.IntSize == 64 && (0 < len(s) && len(s) < 19)) {
- return false
- }
-
- carg = 0
-
- // Build integer from string
- for i := 0; i < len(str); i++ {
- carg = carg*10 + int(str[i]-'0')
- }
-
- return true
- }
-
- // ValidOp checks that for current ending idx, that a valid
- // operand was achieved -- only 0, 1 are valid numbers.
- ValidOp = func() bool {
- diff := (idx - last)
- last = idx
- return diff < 2
- }
-
- // AppendArg will take either the directive-set, or
- // iterated arg index, check within bounds of 'a' and
- // append the that argument formatted to the buffer.
- // On failure, it will append an error string
- AppendArg = func() {
- // Look for idx
- if carg < 0 {
- carg = arg
- }
-
- // Incr idx
- arg++
-
- if carg < len(a) {
- // Append formatted argument value
- fmt.AppendInterfaceOrReflect(a[carg])
- } else {
- // No argument found for index
- fmt.Buffer.B = append(fmt.Buffer.B, `!{MISSING_ARG}`...)
- }
- }
-
- // Reset will reset the mode to ground, the flags
- // to empty and parsed 'carg' to empty
- Reset = func() {
- mode = modeNone
- fmt.CurDepth = 0
- fmt.Flags = 0
- fmt.VType = ""
- fmt.Derefs = 0
- carg = -1
- }
- )
-
- for idx = 0; idx < len(s); idx++ {
- // Get next char
- c := s[idx]
-
- switch mode {
- // Ground mode
- case modeNone:
- switch c {
- case '{':
- // Enter open mode
- fmt.Buffer.B = append(fmt.Buffer.B, Str()...)
- mode = modeOpen
- MoveUp()
- case '}':
- // Enter close mode
- fmt.Buffer.B = append(fmt.Buffer.B, Str()...)
- mode = modeClose
- MoveUp()
- }
-
- // Encountered open '{'
- case modeOpen:
- switch c {
- case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
- // Starting index
- mode = modeIdx
- MoveUp()
- case '{':
- // Escaped bracket
- fmt.Buffer.B = append(fmt.Buffer.B, '{')
- mode = modeNone
- MoveUp()
- case '}':
- // Format arg
- AppendArg()
- Reset()
- MoveUp()
- case ':':
- // Starting operands
- mode = modeOp
- MoveUp()
- default:
- // Bad char, missing a close
- fmt.Buffer.B = append(fmt.Buffer.B, `!{MISSING_CLOSE}`...)
- mode = modeNone
- MoveUpTo()
- }
-
- // Encountered close '}'
- case modeClose:
- switch c {
- case '}':
- // Escaped close bracket
- fmt.Buffer.B = append(fmt.Buffer.B, '}')
- mode = modeNone
- MoveUp()
- default:
- // Missing an open bracket
- fmt.Buffer.B = append(fmt.Buffer.B, `!{MISSING_OPEN}`...)
- mode = modeNone
- MoveUp()
- }
-
- // Preparing index
- case modeIdx:
- switch c {
- case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
- case ':':
- if !ParseIndex() {
- // Unable to parse an integer
- fmt.Buffer.B = append(fmt.Buffer.B, `!{BAD_INDEX}`...)
- mode = modeNone
- MoveUpTo()
- } else {
- // Starting operands
- mode = modeOp
- MoveUp()
- }
- case '}':
- if !ParseIndex() {
- // Unable to parse an integer
- fmt.Buffer.B = append(fmt.Buffer.B, `!{BAD_INDEX}`...)
- } else {
- // Format arg
- AppendArg()
- }
- Reset()
- MoveUp()
- default:
- // Not a valid index character
- fmt.Buffer.B = append(fmt.Buffer.B, `!{BAD_INDEX}`...)
- mode = modeNone
- MoveUpTo()
- }
-
- // Preparing operands
- case modeOp:
- switch c {
- case 'k':
- fmt.Flags |= IsKeyBit
- case 'v':
- fmt.Flags |= IsValBit
- case '?':
- fmt.Flags |= VboseBit
- case '}':
- if !ValidOp() {
- // Bad operands parsed
- fmt.Buffer.B = append(fmt.Buffer.B, `!{BAD_OPERAND}`...)
- } else {
- // Format arg
- AppendArg()
- }
- Reset()
- MoveUp()
- default:
- // Not a valid operand char
- fmt.Buffer.B = append(fmt.Buffer.B, `!{BAD_OPERAND}`...)
- Reset()
- MoveUpTo()
- }
- }
- }
-
- // Append any remaining
- fmt.Buffer.B = append(fmt.Buffer.B, s[last:]...)
-}
-
-// formatter is the default formatter instance.
-var formatter = Formatter{
- MaxDepth: 10,
-}
-
-// Append will append formatted form of supplied values into 'buf' using default formatter.
-// See Formatter.Append() for more documentation.
-func Append(buf *byteutil.Buffer, v ...interface{}) {
- formatter.Append(buf, v...)
-}
-
-// Appendf will append the formatted string with supplied values into 'buf' using default formatter.
-// See Formatter.Appendf() for more documentation.
-func Appendf(buf *byteutil.Buffer, s string, a ...interface{}) {
- formatter.Appendf(buf, s, a...)
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/format/util.go b/vendor/codeberg.org/gruf/go-kv/format/util.go
deleted file mode 100644
index c4c42329e..000000000
--- a/vendor/codeberg.org/gruf/go-kv/format/util.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package format
-
-import (
- "strings"
- "unsafe"
-)
-
-// ContainsSpaceOrTab checks if "s" contains space or tabs.
-func ContainsSpaceOrTab(s string) bool {
- if i := strings.IndexByte(s, ' '); i != -1 {
- return true // note using indexbyte as it is ASM.
- } else if i := strings.IndexByte(s, '\t'); i != -1 {
- return true
- }
- return false
-}
-
-// ContainsDoubleQuote checks if "s" contains a double quote.
-func ContainsDoubleQuote(s string) bool {
- return (strings.IndexByte(s, '"') != -1)
-}
-
-// AppendEscape will append 's' to 'dst' and escape any double quotes.
-func AppendEscape(dst []byte, str string) []byte {
- var delim bool
- for i := range str {
- if str[i] == '\\' && !delim {
- // Set delim flag
- delim = true
- continue
- } else if str[i] == '"' && !delim {
- // Append escaped double quote
- dst = append(dst, `\"`...)
- continue
- } else if delim {
- // Append skipped slash
- dst = append(dst, `\`...)
- delim = false
- }
-
- // Append char as-is
- dst = append(dst, str[i])
- }
- return dst
-}
-
-// isNil will safely check if 'v' is nil without dealing with weird Go interface nil bullshit.
-func isNil(i interface{}) bool {
- type eface struct{ _type, data unsafe.Pointer } //nolint
- return (*(*eface)(unsafe.Pointer(&i))).data == nil //nolint
-}
-
-// b2s converts a byteslice to string without allocation.
-func b2s(b []byte) string {
- return *(*string)(unsafe.Pointer(&b))
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/util.go b/vendor/codeberg.org/gruf/go-kv/util.go
deleted file mode 100644
index a9526bf3d..000000000
--- a/vendor/codeberg.org/gruf/go-kv/util.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package kv
-
-import (
- "strconv"
-
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-kv/format"
-)
-
-// appendQuoteKey will append and escape/quote a formatted key string.
-func appendQuoteKey(buf *byteutil.Buffer, str string) {
- switch {
- case !strconv.CanBackquote(str):
- // Append quoted and escaped string
- buf.B = strconv.AppendQuote(buf.B, str)
- case format.ContainsDoubleQuote(str):
- // Double quote and escape string
- buf.B = append(buf.B, '"')
- buf.B = format.AppendEscape(buf.B, str)
- buf.B = append(buf.B, '"')
- case len(str) < 1 || format.ContainsSpaceOrTab(str):
- // Double quote this string as-is
- buf.WriteString(`"` + str + `"`)
- default:
- // Append string as-is
- buf.WriteString(str)
- }
-}
-
-// appendQuoteValue will append and escape/quote a formatted value string.
-func appendQuoteValue(buf *byteutil.Buffer, str string) {
- switch {
- case !strconv.CanBackquote(str):
- // Append quoted and escaped string
- buf.B = strconv.AppendQuote(buf.B, str)
- return
- case !doubleQuoted(str):
- if format.ContainsDoubleQuote(str) {
- // Double quote and escape string
- buf.B = append(buf.B, '"')
- buf.B = format.AppendEscape(buf.B, str)
- buf.B = append(buf.B, '"')
- return
- } else if format.ContainsSpaceOrTab(str) {
- // Double quote this string as-is
- buf.WriteString(`"` + str + `"`)
- return
- }
- }
-
- // Append string as-is
- buf.WriteString(str)
-}
-
-// doubleQuoted will return whether 'str' is double quoted.
-func doubleQuoted(str string) bool {
- if len(str) < 2 ||
- str[0] != '"' || str[len(str)-1] != '"' {
- return false
- }
- var delim bool
- for i := len(str) - 2; i >= 0; i-- {
- switch str[i] {
- case '\\':
- delim = !delim
- default:
- return !delim
- }
- }
- return !delim
-}
diff --git a/vendor/codeberg.org/gruf/go-logger/v2/LICENSE b/vendor/codeberg.org/gruf/go-logger/v2/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-logger/v2/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-logger/v2/level/levels.go b/vendor/codeberg.org/gruf/go-logger/v2/level/levels.go
deleted file mode 100644
index 1804bdb23..000000000
--- a/vendor/codeberg.org/gruf/go-logger/v2/level/levels.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package level
-
-// LEVEL defines a level of logging.
-type LEVEL uint8
-
-// Default levels of logging.
-const (
- UNSET LEVEL = 0
- PANIC LEVEL = 1
- FATAL LEVEL = 50
- ERROR LEVEL = 100
- WARN LEVEL = 150
- INFO LEVEL = 200
- DEBUG LEVEL = 250
- TRACE LEVEL = 254
- ALL LEVEL = ^LEVEL(0)
-)
-
-// CanLog returns whether an incoming log of 'lvl' can be logged against receiving level.
-func (loglvl LEVEL) CanLog(lvl LEVEL) bool {
- return loglvl > lvl
-}
-
-// Levels defines a mapping of log LEVELs to formatted level strings.
-type Levels [int(ALL) + 1]string
-
-// Default returns the default set of log levels.
-func Default() Levels {
- return Levels{
- TRACE: "TRACE",
- DEBUG: "DEBUG",
- INFO: "INFO",
- WARN: "WARN",
- ERROR: "ERROR",
- FATAL: "FATAL",
- PANIC: "PANIC",
-
- // we set these just so that
- // it can be debugged when someone
- // attempts to log with ALL/UNSET
- ALL: "{all}",
- UNSET: "{unset}",
- }
-}
-
-// Get fetches the level string for the provided value.
-func (l Levels) Get(lvl LEVEL) string {
- return l[int(lvl)]
-}
diff --git a/vendor/codeberg.org/gruf/go-mutexes/LICENSE b/vendor/codeberg.org/gruf/go-mutexes/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-mutexes/README.md b/vendor/codeberg.org/gruf/go-mutexes/README.md
deleted file mode 100644
index f25ccad81..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Library that provides more complex mutex implementations than default libraries \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-mutexes/debug.go b/vendor/codeberg.org/gruf/go-mutexes/debug.go
deleted file mode 100644
index 1b7be60c7..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/debug.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package mutexes
-
-// func init() {
-// log.SetFlags(log.Flags() | log.Lshortfile)
-// }
-
-// type debugMutex sync.Mutex
-
-// func (mu *debugMutex) Lock() {
-// log.Output(2, "Lock()")
-// (*sync.Mutex)(mu).Lock()
-// }
-
-// func (mu *debugMutex) Unlock() {
-// log.Output(2, "Unlock()")
-// (*sync.Mutex)(mu).Unlock()
-// }
-
-// type debugRWMutex sync.RWMutex
-
-// func (mu *debugRWMutex) Lock() {
-// log.Output(2, "Lock()")
-// (*sync.RWMutex)(mu).Lock()
-// }
-
-// func (mu *debugRWMutex) Unlock() {
-// log.Output(2, "Unlock()")
-// (*sync.RWMutex)(mu).Unlock()
-// }
-
-// func (mu *debugRWMutex) RLock() {
-// log.Output(2, "RLock()")
-// (*sync.RWMutex)(mu).RLock()
-// }
-
-// func (mu *debugRWMutex) RUnlock() {
-// log.Output(2, "RUnlock()")
-// (*sync.RWMutex)(mu).RUnlock()
-// }
diff --git a/vendor/codeberg.org/gruf/go-mutexes/map.go b/vendor/codeberg.org/gruf/go-mutexes/map.go
deleted file mode 100644
index c0f740eec..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/map.go
+++ /dev/null
@@ -1,466 +0,0 @@
-package mutexes
-
-import (
- "runtime"
- "sync"
- "sync/atomic"
-)
-
-const (
- // possible lock types.
- lockTypeRead = uint8(1) << 0
- lockTypeWrite = uint8(1) << 1
- lockTypeMap = uint8(1) << 2
-
- // possible mutexmap states.
- stateUnlockd = uint8(0)
- stateRLocked = uint8(1)
- stateLocked = uint8(2)
- stateInUse = uint8(3)
-
- // default values.
- defaultWake = 1024
-)
-
-// acquireState attempts to acquire required map state for lockType.
-func acquireState(state uint8, lt uint8) (uint8, bool) {
- switch state {
- // Unlocked state
- // (all allowed)
- case stateUnlockd:
-
- // Keys locked, no state lock.
- // (don't allow map locks)
- case stateInUse:
- if lt&lockTypeMap != 0 {
- return 0, false
- }
-
- // Read locked
- // (only allow read locks)
- case stateRLocked:
- if lt&lockTypeRead == 0 {
- return 0, false
- }
-
- // Write locked
- // (none allowed)
- case stateLocked:
- return 0, false
-
- // shouldn't reach here
- default:
- panic("unexpected state")
- }
-
- switch {
- // If unlocked and not a map
- // lock request, set in use
- case lt&lockTypeMap == 0:
- if state == stateUnlockd {
- state = stateInUse
- }
-
- // Set read lock state
- case lt&lockTypeRead != 0:
- state = stateRLocked
-
- // Set write lock state
- case lt&lockTypeWrite != 0:
- state = stateLocked
-
- default:
- panic("unexpected lock type")
- }
-
- return state, true
-}
-
-// MutexMap is a structure that allows read / write locking key, performing
-// as you'd expect a map[string]*sync.RWMutex to perform. The differences
-// being that the entire map can itself be read / write locked, it uses memory
-// pooling for the mutex (not quite) structures, and it is self-evicting. The
-// core configurations of maximum no. open locks and wake modulus* are user
-// definable.
-//
-// * The wake modulus is the number that the current number of open locks is
-// modulused against to determine how often to notify sleeping goroutines.
-// These are goroutines that are attempting to lock a key / whole map and are
-// awaiting a permissible state (.e.g no key write locks allowed when the
-// map is read locked).
-type MutexMap struct {
- qpool pool
- queue []*sync.Mutex
-
- mumap map[string]*rwmutex
- mpool pool
- evict []*rwmutex
-
- count int32
- maxmu int32
- wake int32
-
- mapmu sync.Mutex
- state uint8
-}
-
-// NewMap returns a new MutexMap instance with provided max no. open mutexes.
-func NewMap(max, wake int32) MutexMap {
- // Determine wake mod.
- if wake < 1 {
- wake = defaultWake
- }
-
- // Determine max no. mutexes
- if max < 1 {
- procs := runtime.GOMAXPROCS(0)
- max = wake * int32(procs)
- }
-
- return MutexMap{
- qpool: pool{
- alloc: func() interface{} {
- return &sync.Mutex{}
- },
- },
- mumap: make(map[string]*rwmutex, max),
- mpool: pool{
- alloc: func() interface{} {
- return &rwmutex{}
- },
- },
- maxmu: max,
- wake: wake,
- }
-}
-
-// MAX sets the MutexMap max open locks and wake modulus, returns current values.
-// For values less than zero defaults are set, and zero is non-op.
-func (mm *MutexMap) SET(max, wake int32) (int32, int32) {
- mm.mapmu.Lock()
-
- switch {
- // Set default wake
- case wake < 0:
- mm.wake = defaultWake
-
- // Set supplied wake
- case wake > 0:
- mm.wake = wake
- }
-
- switch {
- // Set default max
- case max < 0:
- procs := runtime.GOMAXPROCS(0)
- mm.maxmu = wake * int32(procs)
-
- // Set supplied max
- case max > 0:
- mm.maxmu = max
- }
-
- // Fetch values
- max = mm.maxmu
- wake = mm.wake
-
- mm.mapmu.Unlock()
- return max, wake
-}
-
-// spinLock will wait (using a mutex to sleep thread) until conditional returns true.
-func (mm *MutexMap) spinLock(cond func() bool) {
- var mu *sync.Mutex
-
- for {
- // Acquire map lock
- mm.mapmu.Lock()
-
- if cond() {
- // Release mu if needed
- if mu != nil {
- mm.qpool.Release(mu)
- }
- return
- }
-
- // Alloc mu if needed
- if mu == nil {
- v := mm.qpool.Acquire()
- mu = v.(*sync.Mutex)
- }
-
- // Queue ourselves
- mm.queue = append(mm.queue, mu)
- mu.Lock()
-
- // Unlock map
- mm.mapmu.Unlock()
-
- // Wait on notify
- mu.Lock()
- mu.Unlock()
- }
-}
-
-// lock will acquire a lock of given type on the 'mutex' at key.
-func (mm *MutexMap) lock(key string, lt uint8) func() {
- var ok bool
- var mu *rwmutex
-
- // Spin lock until returns true
- mm.spinLock(func() bool {
- // Check not overloaded
- if !(mm.count < mm.maxmu) {
- return false
- }
-
- // Attempt to acquire usable map state
- state, ok := acquireState(mm.state, lt)
- if !ok {
- return false
- }
-
- // Update state
- mm.state = state
-
- // Ensure mutex at key
- // is in lockable state
- mu, ok = mm.mumap[key]
- return !ok || mu.CanLock(lt)
- })
-
- // Incr count
- mm.count++
-
- if !ok {
- // No mutex found for key
-
- // Alloc from pool
- v := mm.mpool.Acquire()
- mu = v.(*rwmutex)
- mm.mumap[key] = mu
-
- // Set our key
- mu.key = key
-
- // Queue for eviction
- mm.evict = append(mm.evict, mu)
- }
-
- // Lock mutex
- mu.Lock(lt)
-
- // Unlock map
- mm.mapmu.Unlock()
-
- return func() {
- mm.mapmu.Lock()
- mu.Unlock()
- go mm.cleanup()
- }
-}
-
-// lockMap will lock the whole map under given lock type.
-func (mm *MutexMap) lockMap(lt uint8) {
- // Spin lock until returns true
- mm.spinLock(func() bool {
- // Attempt to acquire usable map state
- state, ok := acquireState(mm.state, lt)
- if !ok {
- return false
- }
-
- // Update state
- mm.state = state
-
- return true
- })
-
- // Incr count
- mm.count++
-
- // State acquired, unlock
- mm.mapmu.Unlock()
-}
-
-// cleanup is performed as the final stage of unlocking a locked key / map state, finally unlocks map.
-func (mm *MutexMap) cleanup() {
- // Decr count
- mm.count--
-
- if mm.count%mm.wake == 0 {
- // Notify queued routines
- for _, mu := range mm.queue {
- mu.Unlock()
- }
-
- // Reset queue
- mm.queue = mm.queue[:0]
- }
-
- if mm.count < 1 {
- // Perform evictions
- for _, mu := range mm.evict {
- key := mu.key
- mu.key = ""
- delete(mm.mumap, key)
- mm.mpool.Release(mu)
- }
-
- // Reset map state
- mm.evict = mm.evict[:0]
- mm.state = stateUnlockd
- mm.mpool.GC()
- mm.qpool.GC()
- }
-
- // Unlock map
- mm.mapmu.Unlock()
-}
-
-// RLockMap acquires a read lock over the entire map, returning a lock state for acquiring key read locks.
-// Please note that the 'unlock()' function will block until all keys locked from this state are unlocked.
-func (mm *MutexMap) RLockMap() *LockState {
- mm.lockMap(lockTypeRead | lockTypeMap)
- return &LockState{
- mmap: mm,
- ltyp: lockTypeRead,
- }
-}
-
-// LockMap acquires a write lock over the entire map, returning a lock state for acquiring key read/write locks.
-// Please note that the 'unlock()' function will block until all keys locked from this state are unlocked.
-func (mm *MutexMap) LockMap() *LockState {
- mm.lockMap(lockTypeWrite | lockTypeMap)
- return &LockState{
- mmap: mm,
- ltyp: lockTypeWrite,
- }
-}
-
-// RLock acquires a mutex read lock for supplied key, returning an RUnlock function.
-func (mm *MutexMap) RLock(key string) (runlock func()) {
- return mm.lock(key, lockTypeRead)
-}
-
-// Lock acquires a mutex write lock for supplied key, returning an Unlock function.
-func (mm *MutexMap) Lock(key string) (unlock func()) {
- return mm.lock(key, lockTypeWrite)
-}
-
-// LockState represents a window to a locked MutexMap.
-type LockState struct {
- wait sync.WaitGroup
- mmap *MutexMap
- done uint32
- ltyp uint8
-}
-
-// Lock: see MutexMap.Lock() definition. Will panic if map only read locked.
-func (st *LockState) Lock(key string) (unlock func()) {
- return st.lock(key, lockTypeWrite)
-}
-
-// RLock: see MutexMap.RLock() definition.
-func (st *LockState) RLock(key string) (runlock func()) {
- return st.lock(key, lockTypeRead)
-}
-
-// lock: see MutexMap.lock() definition.
-func (st *LockState) lock(key string, lt uint8) func() {
- st.wait.Add(1) // track lock
-
- if atomic.LoadUint32(&st.done) == 1 {
- panic("called (r)lock on unlocked state")
- } else if lt&lockTypeWrite != 0 &&
- st.ltyp&lockTypeWrite == 0 {
- panic("called lock on rlocked map")
- }
-
- var ok bool
- var mu *rwmutex
-
- // Spin lock until returns true
- st.mmap.spinLock(func() bool {
- // Check not overloaded
- if !(st.mmap.count < st.mmap.maxmu) {
- return false
- }
-
- // Ensure mutex at key
- // is in lockable state
- mu, ok = st.mmap.mumap[key]
- return !ok || mu.CanLock(lt)
- })
-
- // Incr count
- st.mmap.count++
-
- if !ok {
- // No mutex found for key
-
- // Alloc from pool
- v := st.mmap.mpool.Acquire()
- mu = v.(*rwmutex)
- st.mmap.mumap[key] = mu
-
- // Set our key
- mu.key = key
-
- // Queue for eviction
- st.mmap.evict = append(st.mmap.evict, mu)
- }
-
- // Lock mutex
- mu.Lock(lt)
-
- // Unlock map
- st.mmap.mapmu.Unlock()
-
- return func() {
- st.mmap.mapmu.Lock()
- mu.Unlock()
- go st.mmap.cleanup()
- st.wait.Add(-1)
- }
-}
-
-// UnlockMap will close this state and release the currently locked map.
-func (st *LockState) UnlockMap() {
- if !atomic.CompareAndSwapUint32(&st.done, 0, 1) {
- panic("called unlockmap on expired state")
- }
- st.wait.Wait()
- st.mmap.mapmu.Lock()
- go st.mmap.cleanup()
-}
-
-// rwmutex is a very simple *representation* of a read-write
-// mutex, though not one in implementation. it works by
-// tracking the lock state for a given map key, which is
-// protected by the map's mutex.
-type rwmutex struct {
- rcnt uint32
- lock uint8
- key string
-}
-
-func (mu *rwmutex) CanLock(lt uint8) bool {
- return mu.lock == 0 ||
- (mu.lock&lockTypeRead != 0 && lt&lockTypeRead != 0)
-}
-
-func (mu *rwmutex) Lock(lt uint8) {
- mu.lock = lt
- if lt&lockTypeRead != 0 {
- mu.rcnt++
- }
-}
-
-func (mu *rwmutex) Unlock() {
- mu.rcnt--
- if mu.rcnt == 0 {
- mu.lock = 0
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mutexes/mutex.go b/vendor/codeberg.org/gruf/go-mutexes/mutex.go
deleted file mode 100644
index 3841c9423..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/mutex.go
+++ /dev/null
@@ -1,105 +0,0 @@
-package mutexes
-
-import (
- "sync"
-)
-
-// Mutex defines a wrappable mutex. By forcing unlocks
-// via returned function it makes wrapping much easier
-type Mutex interface {
- // Lock performs a mutex lock, returning an unlock function
- Lock() (unlock func())
-}
-
-// RWMutex defines a wrappable read-write mutex. By forcing
-// unlocks via returned functions it makes wrapping much easier
-type RWMutex interface {
- Mutex
-
- // RLock performs a mutex read lock, returning an unlock function
- RLock() (runlock func())
-}
-
-// New returns a new base Mutex implementation
-func New() Mutex {
- return &baseMutex{}
-}
-
-// NewRW returns a new base RWMutex implementation
-func NewRW() RWMutex {
- return &baseRWMutex{}
-}
-
-// WithFunc wraps the supplied Mutex to call the provided hooks on lock / unlock
-func WithFunc(mu Mutex, onLock, onUnlock func()) Mutex {
- return &fnMutex{mu: mu, lo: onLock, un: onUnlock}
-}
-
-// WithFuncRW wrapps the supplied RWMutex to call the provided hooks on lock / rlock / unlock/ runlock
-func WithFuncRW(mu RWMutex, onLock, onRLock, onUnlock, onRUnlock func()) RWMutex {
- return &fnRWMutex{mu: mu, lo: onLock, rlo: onRLock, un: onUnlock, run: onRUnlock}
-}
-
-// baseMutex simply wraps a sync.Mutex to implement our Mutex interface
-type baseMutex sync.Mutex
-
-func (mu *baseMutex) Lock() func() {
- (*sync.Mutex)(mu).Lock()
- return (*sync.Mutex)(mu).Unlock
-}
-
-// baseRWMutex simply wraps a sync.RWMutex to implement our RWMutex interface
-type baseRWMutex sync.RWMutex
-
-func (mu *baseRWMutex) Lock() func() {
- (*sync.RWMutex)(mu).Lock()
- return (*sync.RWMutex)(mu).Unlock
-}
-
-func (mu *baseRWMutex) RLock() func() {
- (*sync.RWMutex)(mu).RLock()
- return (*sync.RWMutex)(mu).RUnlock
-}
-
-// fnMutex wraps a Mutex to add hooks for Lock and Unlock
-type fnMutex struct {
- mu Mutex
- lo func()
- un func()
-}
-
-func (mu *fnMutex) Lock() func() {
- unlock := mu.mu.Lock()
- mu.lo()
- return func() {
- mu.un()
- unlock()
- }
-}
-
-// fnRWMutex wraps a RWMutex to add hooks for Lock, RLock, Unlock and RUnlock
-type fnRWMutex struct {
- mu RWMutex
- lo func()
- rlo func()
- un func()
- run func()
-}
-
-func (mu *fnRWMutex) Lock() func() {
- unlock := mu.mu.Lock()
- mu.lo()
- return func() {
- mu.un()
- unlock()
- }
-}
-
-func (mu *fnRWMutex) RLock() func() {
- unlock := mu.mu.RLock()
- mu.rlo()
- return func() {
- mu.run()
- unlock()
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mutexes/mutex_safe.go b/vendor/codeberg.org/gruf/go-mutexes/mutex_safe.go
deleted file mode 100644
index 5a0383dce..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/mutex_safe.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package mutexes
-
-import (
- "sync/atomic"
-)
-
-// WithSafety wrapps the supplied Mutex to protect unlock fns
-// from being called multiple times
-func WithSafety(mu Mutex) Mutex {
- return &safeMutex{mu: mu}
-}
-
-// WithSafetyRW wrapps the supplied RWMutex to protect unlock
-// fns from being called multiple times
-func WithSafetyRW(mu RWMutex) RWMutex {
- return &safeRWMutex{mu: mu}
-}
-
-// safeMutex simply wraps a Mutex to add multi-unlock safety
-type safeMutex struct{ mu Mutex }
-
-func (mu *safeMutex) Lock() func() {
- unlock := mu.mu.Lock()
- return once(unlock)
-}
-
-// safeRWMutex simply wraps a RWMutex to add multi-unlock safety
-type safeRWMutex struct{ mu RWMutex }
-
-func (mu *safeRWMutex) Lock() func() {
- unlock := mu.mu.Lock()
- return once(unlock)
-}
-
-func (mu *safeRWMutex) RLock() func() {
- unlock := mu.mu.RLock()
- return once(unlock)
-}
-
-// once will perform 'do' only once, this is safe for unlocks
-// as 2 functions calling 'unlock()' don't need absolute guarantees
-// that by the time it is completed the unlock was finished.
-func once(do func()) func() {
- var done uint32
- return func() {
- if atomic.CompareAndSwapUint32(&done, 0, 1) {
- do()
- }
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go b/vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go
deleted file mode 100644
index 03bf0e389..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go
+++ /dev/null
@@ -1,137 +0,0 @@
-package mutexes
-
-import (
- "sync"
- "time"
-)
-
-// TimeoutMutex defines a Mutex with timeouts on locks
-type TimeoutMutex interface {
- Mutex
-
- // LockFunc is functionally the same as Lock(), but allows setting a custom hook called on timeout
- LockFunc(func()) func()
-}
-
-// TimeoutRWMutex defines a RWMutex with timeouts on locks
-type TimeoutRWMutex interface {
- RWMutex
-
- // LockFunc is functionally the same as Lock(), but allows setting a custom hook called on timeout
- LockFunc(func()) func()
-
- // RLockFunc is functionally the same as RLock(), but allows setting a custom hook called on timeout
- RLockFunc(func()) func()
-}
-
-// WithTimeout wraps the supplied Mutex to add a timeout
-func WithTimeout(mu Mutex, d time.Duration) TimeoutMutex {
- return &timeoutMutex{mu: mu, d: d}
-}
-
-// WithTimeoutRW wraps the supplied RWMutex to add read/write timeouts
-func WithTimeoutRW(mu RWMutex, rd, wd time.Duration) TimeoutRWMutex {
- return &timeoutRWMutex{mu: mu, rd: rd, wd: wd}
-}
-
-// timeoutMutex wraps a Mutex with timeout
-type timeoutMutex struct {
- mu Mutex // mu is the wrapped mutex
- d time.Duration // d is the timeout duration
-}
-
-func (mu *timeoutMutex) Lock() func() {
- return mu.LockFunc(func() { panic("lock timed out") })
-}
-
-func (mu *timeoutMutex) LockFunc(fn func()) func() {
- return mutexTimeout(mu.d, mu.mu.Lock(), fn)
-}
-
-// TimeoutRWMutex wraps a RWMutex with timeouts
-type timeoutRWMutex struct {
- mu RWMutex // mu is the wrapped rwmutex
- rd time.Duration // rd is the rlock timeout duration
- wd time.Duration // wd is the lock timeout duration
-}
-
-func (mu *timeoutRWMutex) Lock() func() {
- return mu.LockFunc(func() { panic("lock timed out") })
-}
-
-func (mu *timeoutRWMutex) LockFunc(fn func()) func() {
- return mutexTimeout(mu.wd, mu.mu.Lock(), fn)
-}
-
-func (mu *timeoutRWMutex) RLock() func() {
- return mu.RLockFunc(func() { panic("rlock timed out") })
-}
-
-func (mu *timeoutRWMutex) RLockFunc(fn func()) func() {
- return mutexTimeout(mu.rd, mu.mu.RLock(), fn)
-}
-
-// mutexTimeout performs a timed unlock, calling supplied fn if timeout is reached
-func mutexTimeout(d time.Duration, unlock func(), fn func()) func() {
- if d < 1 {
- // No timeout, just unlock
- return unlock
- }
-
- // Acquire timer from pool
- t := timerPool.Get().(*timer)
-
- // Start the timer
- go t.Start(d, fn)
-
- // Return func cancelling timeout,
- // replacing Timeout in pool and
- // finally unlocking mutex
- return func() {
- defer timerPool.Put(t)
- t.Cancel()
- unlock()
- }
-}
-
-// timerPool is the global &timer{} pool.
-var timerPool = sync.Pool{
- New: func() interface{} {
- t := time.NewTimer(time.Minute)
- t.Stop()
- return &timer{t: t, c: make(chan struct{})}
- },
-}
-
-// timer represents a reusable cancellable timer.
-type timer struct {
- t *time.Timer
- c chan struct{}
-}
-
-// Start will start the timer with duration 'd', performing 'fn' on timeout.
-func (t *timer) Start(d time.Duration, fn func()) {
- t.t.Reset(d)
- select {
- // Timed out
- case <-t.t.C:
- fn()
-
- // Cancelled
- case <-t.c:
- }
-}
-
-// Cancel will attempt to cancel the running timer.
-func (t *timer) Cancel() {
- select {
- // cancel successful
- case t.c <- struct{}{}:
- if !t.t.Stop() {
- <-t.t.C
- } // stop timer
-
- // already stopped
- default:
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mutexes/pool.go b/vendor/codeberg.org/gruf/go-mutexes/pool.go
deleted file mode 100644
index 135e2c117..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/pool.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package mutexes
-
-// pool is a very simply memory pool.
-type pool struct {
- current []interface{}
- victim []interface{}
- alloc func() interface{}
-}
-
-// Acquire will returns a sync.RWMutex from pool (or alloc new).
-func (p *pool) Acquire() interface{} {
- // First try the current queue
- if l := len(p.current) - 1; l >= 0 {
- v := p.current[l]
- p.current = p.current[:l]
- return v
- }
-
- // Next try the victim queue.
- if l := len(p.victim) - 1; l >= 0 {
- v := p.victim[l]
- p.victim = p.victim[:l]
- return v
- }
-
- // Lastly, alloc new.
- return p.alloc()
-}
-
-// Release places a sync.RWMutex back in the pool.
-func (p *pool) Release(v interface{}) {
- p.current = append(p.current, v)
-}
-
-// GC will clear out unused entries from the pool.
-func (p *pool) GC() {
- current := p.current
- p.current = nil
- p.victim = current
-}
diff --git a/vendor/codeberg.org/gruf/go-pools/LICENSE b/vendor/codeberg.org/gruf/go-pools/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-pools/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-pools/README.md b/vendor/codeberg.org/gruf/go-pools/README.md
deleted file mode 100644
index 673324271..000000000
--- a/vendor/codeberg.org/gruf/go-pools/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-A selection of type-defined `sync.Pool` implementations with redefined "getter" and "putter"
-methods to handle their appropriate types. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-pools/bufio.go b/vendor/codeberg.org/gruf/go-pools/bufio.go
deleted file mode 100644
index e22fd6a1c..000000000
--- a/vendor/codeberg.org/gruf/go-pools/bufio.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package pools
-
-import (
- "bufio"
- "io"
- "sync"
-)
-
-// BufioReaderPool is a pooled allocator for bufio.Reader objects.
-type BufioReaderPool interface {
- // Get fetches a bufio.Reader from pool and resets to supplied reader
- Get(io.Reader) *bufio.Reader
-
- // Put places supplied bufio.Reader back in pool
- Put(*bufio.Reader)
-}
-
-// NewBufioReaderPool returns a newly instantiated bufio.Reader pool.
-func NewBufioReaderPool(size int) BufioReaderPool {
- return &bufioReaderPool{
- pool: sync.Pool{
- New: func() interface{} {
- return bufio.NewReaderSize(nil, size)
- },
- },
- size: size,
- }
-}
-
-// bufioReaderPool is our implementation of BufioReaderPool.
-type bufioReaderPool struct {
- pool sync.Pool
- size int
-}
-
-func (p *bufioReaderPool) Get(r io.Reader) *bufio.Reader {
- br := p.pool.Get().(*bufio.Reader)
- br.Reset(r)
- return br
-}
-
-func (p *bufioReaderPool) Put(br *bufio.Reader) {
- if br.Size() < p.size {
- return
- }
- br.Reset(nil)
- p.pool.Put(br)
-}
-
-// BufioWriterPool is a pooled allocator for bufio.Writer objects.
-type BufioWriterPool interface {
- // Get fetches a bufio.Writer from pool and resets to supplied writer
- Get(io.Writer) *bufio.Writer
-
- // Put places supplied bufio.Writer back in pool
- Put(*bufio.Writer)
-}
-
-// NewBufioWriterPool returns a newly instantiated bufio.Writer pool.
-func NewBufioWriterPool(size int) BufioWriterPool {
- return &bufioWriterPool{
- pool: sync.Pool{
- New: func() interface{} {
- return bufio.NewWriterSize(nil, size)
- },
- },
- size: size,
- }
-}
-
-// bufioWriterPool is our implementation of BufioWriterPool.
-type bufioWriterPool struct {
- pool sync.Pool
- size int
-}
-
-func (p *bufioWriterPool) Get(w io.Writer) *bufio.Writer {
- bw := p.pool.Get().(*bufio.Writer)
- bw.Reset(w)
- return bw
-}
-
-func (p *bufioWriterPool) Put(bw *bufio.Writer) {
- if bw.Size() < p.size {
- return
- }
- bw.Reset(nil)
- p.pool.Put(bw)
-}
diff --git a/vendor/codeberg.org/gruf/go-pools/bytes.go b/vendor/codeberg.org/gruf/go-pools/bytes.go
deleted file mode 100644
index 1aee77064..000000000
--- a/vendor/codeberg.org/gruf/go-pools/bytes.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package pools
-
-import (
- "sync"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-// BufferPool is a pooled allocator for bytes.Buffer objects
-type BufferPool interface {
- // Get fetches a bytes.Buffer from pool
- Get() *byteutil.Buffer
-
- // Put places supplied bytes.Buffer in pool
- Put(*byteutil.Buffer)
-}
-
-// NewBufferPool returns a newly instantiated bytes.Buffer pool
-func NewBufferPool(size int) BufferPool {
- return &bufferPool{
- pool: sync.Pool{
- New: func() interface{} {
- return &byteutil.Buffer{B: make([]byte, 0, size)}
- },
- },
- size: size,
- }
-}
-
-// bufferPool is our implementation of BufferPool
-type bufferPool struct {
- pool sync.Pool
- size int
-}
-
-func (p *bufferPool) Get() *byteutil.Buffer {
- return p.pool.Get().(*byteutil.Buffer)
-}
-
-func (p *bufferPool) Put(buf *byteutil.Buffer) {
- if buf.Cap() < p.size {
- return
- }
- buf.Reset()
- p.pool.Put(buf)
-}
diff --git a/vendor/codeberg.org/gruf/go-pools/fastpath.go b/vendor/codeberg.org/gruf/go-pools/fastpath.go
deleted file mode 100644
index eb76f03e4..000000000
--- a/vendor/codeberg.org/gruf/go-pools/fastpath.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package pools
-
-import (
- "sync"
-
- "codeberg.org/gruf/go-fastpath"
-)
-
-// PathBuilderPool is a pooled allocator for fastpath.Builder objects
-type PathBuilderPool interface {
- // Get fetches a fastpath.Builder from pool
- Get() *fastpath.Builder
-
- // Put places supplied fastpath.Builder back in pool
- Put(*fastpath.Builder)
-}
-
-// NewPathBuilderPool returns a newly instantiated fastpath.Builder pool
-func NewPathBuilderPool(size int) PathBuilderPool {
- return &pathBuilderPool{
- pool: sync.Pool{
- New: func() interface{} {
- return &fastpath.Builder{B: make([]byte, 0, size)}
- },
- },
- size: size,
- }
-}
-
-// pathBuilderPool is our implementation of PathBuilderPool
-type pathBuilderPool struct {
- pool sync.Pool
- size int
-}
-
-func (p *pathBuilderPool) Get() *fastpath.Builder {
- return p.pool.Get().(*fastpath.Builder)
-}
-
-func (p *pathBuilderPool) Put(pb *fastpath.Builder) {
- if pb.Cap() < p.size {
- return
- }
- pb.Reset()
- p.pool.Put(pb)
-}
diff --git a/vendor/codeberg.org/gruf/go-pools/henc.go b/vendor/codeberg.org/gruf/go-pools/henc.go
deleted file mode 100644
index cad905af4..000000000
--- a/vendor/codeberg.org/gruf/go-pools/henc.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package pools
-
-import (
- "hash"
- "sync"
-
- "codeberg.org/gruf/go-hashenc"
-)
-
-// HashEncoderPool is a pooled allocator for hashenc.HashEncoder objects.
-type HashEncoderPool interface {
- // Get fetches a hashenc.HashEncoder from pool
- Get() hashenc.HashEncoder
-
- // Put places supplied hashenc.HashEncoder back in pool
- Put(hashenc.HashEncoder)
-}
-
-// NewHashEncoderPool returns a newly instantiated hashenc.HashEncoder pool.
-func NewHashEncoderPool(hash func() hash.Hash, enc func() hashenc.Encoder) HashEncoderPool {
- return &hencPool{
- pool: sync.Pool{
- New: func() interface{} {
- return hashenc.New(hash(), enc())
- },
- },
- size: hashenc.New(hash(), enc()).Size(),
- }
-}
-
-// hencPool is our implementation of HashEncoderPool.
-type hencPool struct {
- pool sync.Pool
- size int
-}
-
-func (p *hencPool) Get() hashenc.HashEncoder {
- return p.pool.Get().(hashenc.HashEncoder)
-}
-
-func (p *hencPool) Put(henc hashenc.HashEncoder) {
- if henc.Size() < p.size {
- return
- }
- p.pool.Put(henc)
-}
diff --git a/vendor/codeberg.org/gruf/go-pools/pool.go b/vendor/codeberg.org/gruf/go-pools/pool.go
deleted file mode 100644
index 1e3db74b2..000000000
--- a/vendor/codeberg.org/gruf/go-pools/pool.go
+++ /dev/null
@@ -1,387 +0,0 @@
-package pools
-
-import (
- "runtime"
- "sync"
- "sync/atomic"
- "unsafe"
-)
-
-type Pool struct {
- // New is used to instantiate new items
- New func() interface{}
-
- // Evict is called on evicted items during pool .Clean()
- Evict func(interface{})
-
- local unsafe.Pointer // ptr to []_ppool
- localSz int64 // count of all elems in local
- victim unsafe.Pointer // ptr to []_ppool
- victimSz int64 // count of all elems in victim
- mutex sync.Mutex // mutex protects new cleanups, and new allocations of local
-}
-
-// Get attempts to fetch an item from the pool, failing that allocates with supplied .New() function
-func (p *Pool) Get() interface{} {
- // Get local pool for proc
- // (also pins proc)
- pool, pid := p.pin()
-
- if v := pool.getPrivate(); v != nil {
- // local _ppool private elem acquired
- runtime_procUnpin()
- atomic.AddInt64(&p.localSz, -1)
- return v
- }
-
- if v := pool.get(); v != nil {
- // local _ppool queue elem acquired
- runtime_procUnpin()
- atomic.AddInt64(&p.localSz, -1)
- return v
- }
-
- // Unpin before attempting slow
- runtime_procUnpin()
- if v := p.getSlow(pid); v != nil {
- // note size decrementing
- // is handled within p.getSlow()
- // as we don't know if it came
- // from the local or victim pools
- return v
- }
-
- // Alloc new
- return p.New()
-}
-
-// Put places supplied item in the proc local pool
-func (p *Pool) Put(v interface{}) {
- // Don't store nil
- if v == nil {
- return
- }
-
- // Get proc local pool
- // (also pins proc)
- pool, _ := p.pin()
-
- // first try private, then queue
- if !pool.setPrivate(v) {
- pool.put(v)
- }
- runtime_procUnpin()
-
- // Increment local pool size
- atomic.AddInt64(&p.localSz, 1)
-}
-
-// Clean will drop the current victim pools, move the current local pools to its
-// place and reset the local pools ptr in order to be regenerated
-func (p *Pool) Clean() {
- p.mutex.Lock()
-
- // victim becomes local, local becomes nil
- localPtr := atomic.SwapPointer(&p.local, nil)
- victimPtr := atomic.SwapPointer(&p.victim, localPtr)
- localSz := atomic.SwapInt64(&p.localSz, 0)
- atomic.StoreInt64(&p.victimSz, localSz)
-
- var victim []ppool
- if victimPtr != nil {
- victim = *(*[]ppool)(victimPtr)
- }
-
- // drain each of the vict _ppool items
- for i := 0; i < len(victim); i++ {
- ppool := &victim[i]
- ppool.evict(p.Evict)
- }
-
- p.mutex.Unlock()
-}
-
-// LocalSize returns the total number of elements in all the proc-local pools
-func (p *Pool) LocalSize() int64 {
- return atomic.LoadInt64(&p.localSz)
-}
-
-// VictimSize returns the total number of elements in all the victim (old proc-local) pools
-func (p *Pool) VictimSize() int64 {
- return atomic.LoadInt64(&p.victimSz)
-}
-
-// getSlow is the slow path for fetching an element, attempting to steal from other proc's
-// local pools, and failing that, from the aging-out victim pools. pid is still passed so
-// not all procs start iterating from the same index
-func (p *Pool) getSlow(pid int) interface{} {
- // get local pools
- local := p.localPools()
-
- // Try to steal from other proc locals
- for i := 0; i < len(local); i++ {
- pool := &local[(pid+i+1)%len(local)]
- if v := pool.get(); v != nil {
- atomic.AddInt64(&p.localSz, -1)
- return v
- }
- }
-
- // get victim pools
- victim := p.victimPools()
-
- // Attempt to steal from victim pools
- for i := 0; i < len(victim); i++ {
- pool := &victim[(pid+i+1)%len(victim)]
- if v := pool.get(); v != nil {
- atomic.AddInt64(&p.victimSz, -1)
- return v
- }
- }
-
- // Set victim pools to nil (none found)
- atomic.StorePointer(&p.victim, nil)
-
- return nil
-}
-
-// localPools safely loads slice of local _ppools
-func (p *Pool) localPools() []ppool {
- local := atomic.LoadPointer(&p.local)
- if local == nil {
- return nil
- }
- return *(*[]ppool)(local)
-}
-
-// victimPools safely loads slice of victim _ppools
-func (p *Pool) victimPools() []ppool {
- victim := atomic.LoadPointer(&p.victim)
- if victim == nil {
- return nil
- }
- return *(*[]ppool)(victim)
-}
-
-// pin will get fetch pin proc to PID, fetch proc-local _ppool and current PID we're pinned to
-func (p *Pool) pin() (*ppool, int) {
- for {
- // get local pools
- local := p.localPools()
-
- if len(local) > 0 {
- // local already initialized
-
- // pin to current proc
- pid := runtime_procPin()
-
- // check for pid local pool
- if pid < len(local) {
- return &local[pid], pid
- }
-
- // unpin from proc
- runtime_procUnpin()
- } else {
- // local not yet initialized
-
- // Check functions are set
- if p.New == nil {
- panic("new func must not be nil")
- }
- if p.Evict == nil {
- panic("evict func must not be nil")
- }
- }
-
- // allocate local
- p.allocLocal()
- }
-}
-
-// allocLocal allocates a new local pool slice, with the old length passed to check
-// if pool was previously nil, or whether a change in GOMAXPROCS occurred
-func (p *Pool) allocLocal() {
- // get pool lock
- p.mutex.Lock()
-
- // Calculate new size to use
- size := runtime.GOMAXPROCS(0)
-
- local := p.localPools()
- if len(local) != size {
- // GOMAXPROCS changed, reallocate
- pools := make([]ppool, size)
- atomic.StorePointer(&p.local, unsafe.Pointer(&pools))
-
- // Evict old local elements
- for i := 0; i < len(local); i++ {
- pool := &local[i]
- pool.evict(p.Evict)
- }
- }
-
- // Unlock pool
- p.mutex.Unlock()
-}
-
-// _ppool is a proc local pool
-type _ppool struct {
- // root is the root element of the _ppool queue,
- // and protects concurrent access to the queue
- root unsafe.Pointer
-
- // private is a proc private member accessible
- // only to the pid this _ppool is assigned to,
- // except during evict (hence the unsafe pointer)
- private unsafe.Pointer
-}
-
-// ppool wraps _ppool with pad.
-type ppool struct {
- _ppool
-
- // Prevents false sharing on widespread platforms with
- // 128 mod (cache line size) = 0 .
- pad [128 - unsafe.Sizeof(_ppool{})%128]byte
-}
-
-// getPrivate gets the proc private member
-func (pp *_ppool) getPrivate() interface{} {
- ptr := atomic.SwapPointer(&pp.private, nil)
- if ptr == nil {
- return nil
- }
- return *(*interface{})(ptr)
-}
-
-// setPrivate sets the proc private member (only if unset)
-func (pp *_ppool) setPrivate(v interface{}) bool {
- return atomic.CompareAndSwapPointer(&pp.private, nil, unsafe.Pointer(&v))
-}
-
-// get fetches an element from the queue
-func (pp *_ppool) get() interface{} {
- for {
- // Attempt to load root elem
- root := atomic.LoadPointer(&pp.root)
- if root == nil {
- return nil
- }
-
- // Attempt to consume root elem
- if root == inUsePtr ||
- !atomic.CompareAndSwapPointer(&pp.root, root, inUsePtr) {
- continue
- }
-
- // Root becomes next in chain
- e := (*elem)(root)
- v := e.value
-
- // Place new root back in the chain
- atomic.StorePointer(&pp.root, unsafe.Pointer(e.next))
- putElem(e)
-
- return v
- }
-}
-
-// put places an element in the queue
-func (pp *_ppool) put(v interface{}) {
- // Prepare next elem
- e := getElem()
- e.value = v
-
- for {
- // Attempt to load root elem
- root := atomic.LoadPointer(&pp.root)
- if root == inUsePtr {
- continue
- }
-
- // Set the next elem value (might be nil)
- e.next = (*elem)(root)
-
- // Attempt to store this new value at root
- if atomic.CompareAndSwapPointer(&pp.root, root, unsafe.Pointer(e)) {
- break
- }
- }
-}
-
-// hook evicts all entries from pool, calling hook on each
-func (pp *_ppool) evict(hook func(interface{})) {
- if v := pp.getPrivate(); v != nil {
- hook(v)
- }
- for {
- v := pp.get()
- if v == nil {
- break
- }
- hook(v)
- }
-}
-
-// inUsePtr is a ptr used to indicate _ppool is in use
-var inUsePtr = unsafe.Pointer(&elem{
- next: nil,
- value: "in_use",
-})
-
-// elem defines an element in the _ppool queue
-type elem struct {
- next *elem
- value interface{}
-}
-
-// elemPool is a simple pool of unused elements
-var elemPool = struct {
- root unsafe.Pointer
-}{}
-
-// getElem fetches a new elem from pool, or creates new
-func getElem() *elem {
- // Attempt to load root elem
- root := atomic.LoadPointer(&elemPool.root)
- if root == nil {
- return &elem{}
- }
-
- // Attempt to consume root elem
- if root == inUsePtr ||
- !atomic.CompareAndSwapPointer(&elemPool.root, root, inUsePtr) {
- return &elem{}
- }
-
- // Root becomes next in chain
- e := (*elem)(root)
- atomic.StorePointer(&elemPool.root, unsafe.Pointer(e.next))
- e.next = nil
-
- return e
-}
-
-// putElem will place element in the pool
-func putElem(e *elem) {
- e.value = nil
-
- // Attempt to load root elem
- root := atomic.LoadPointer(&elemPool.root)
- if root == inUsePtr {
- return // drop
- }
-
- // Set the next elem value (might be nil)
- e.next = (*elem)(root)
-
- // Attempt to store this new value at root
- atomic.CompareAndSwapPointer(&elemPool.root, root, unsafe.Pointer(e))
-}
-
-//go:linkname runtime_procPin sync.runtime_procPin
-func runtime_procPin() int
-
-//go:linkname runtime_procUnpin sync.runtime_procUnpin
-func runtime_procUnpin()
diff --git a/vendor/codeberg.org/gruf/go-runners/LICENSE b/vendor/codeberg.org/gruf/go-runners/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-runners/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-runners/README.md b/vendor/codeberg.org/gruf/go-runners/README.md
deleted file mode 100644
index 91cc1528d..000000000
--- a/vendor/codeberg.org/gruf/go-runners/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-runners
-
-Provides a means a simple means of managing long-running functions and services \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-runners/context.go b/vendor/codeberg.org/gruf/go-runners/context.go
deleted file mode 100644
index 6a0c509cb..000000000
--- a/vendor/codeberg.org/gruf/go-runners/context.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package runners
-
-import (
- "context"
- "time"
-)
-
-// closedctx is an always closed context.
-var closedctx = func() context.Context {
- ctx := make(cancelctx)
- close(ctx)
- return ctx
-}()
-
-// ContextWithCancel returns a new context.Context impl with cancel.
-func ContextWithCancel() (context.Context, context.CancelFunc) {
- ctx := make(cancelctx)
- return ctx, func() { close(ctx) }
-}
-
-// cancelctx is the simplest possible cancellable context.
-type cancelctx (chan struct{})
-
-func (cancelctx) Deadline() (time.Time, bool) {
- return time.Time{}, false
-}
-
-func (ctx cancelctx) Done() <-chan struct{} {
- return ctx
-}
-
-func (ctx cancelctx) Err() error {
- select {
- case <-ctx:
- return context.Canceled
- default:
- return nil
- }
-}
-
-func (cancelctx) Value(key interface{}) interface{} {
- return nil
-}
diff --git a/vendor/codeberg.org/gruf/go-runners/pool.go b/vendor/codeberg.org/gruf/go-runners/pool.go
deleted file mode 100644
index ca8849f30..000000000
--- a/vendor/codeberg.org/gruf/go-runners/pool.go
+++ /dev/null
@@ -1,174 +0,0 @@
-package runners
-
-import (
- "context"
- "runtime"
- "sync"
-)
-
-// WorkerFunc represents a function processable by a worker in WorkerPool. Note
-// that implementations absolutely MUST check whether passed context is Done()
-// otherwise stopping the pool may block for large periods of time.
-type WorkerFunc func(context.Context)
-
-// WorkerPool provides a means of enqueuing asynchronous work.
-type WorkerPool struct {
- queue chan WorkerFunc
- free chan struct{}
- wait sync.WaitGroup
- svc Service
-}
-
-// NewWorkerPool returns a new WorkerPool with provided worker count and WorkerFunc queue size.
-// The number of workers represents how many WorkerFuncs can be executed simultaneously, and the
-// queue size represents the max number of WorkerFuncs that can be queued at any one time.
-func NewWorkerPool(workers int, queue int) WorkerPool {
- if workers < 1 {
- workers = runtime.GOMAXPROCS(0)
- }
- if queue < 1 {
- queue = workers * 2
- }
- return WorkerPool{
- queue: make(chan WorkerFunc, queue),
- free: make(chan struct{}, workers),
- }
-}
-
-// Start will attempt to start the worker pool, asynchronously. Return is success state.
-func (pool *WorkerPool) Start() bool {
- ok := true
-
- done := make(chan struct{})
- go func() {
- ok = pool.svc.Run(func(ctx context.Context) {
- close(done)
- pool.process(ctx)
- })
- if !ok {
- close(done)
- }
- }()
- <-done
-
- return ok
-}
-
-// Stop will attempt to stop the worker pool, this will block until stopped. Return is success state.
-func (pool *WorkerPool) Stop() bool {
- return pool.svc.Stop()
-}
-
-// Running returns whether the worker pool is running.
-func (pool *WorkerPool) Running() bool {
- return pool.svc.Running()
-}
-
-// execute will take a queued function and pass it to a free worker when available.
-func (pool *WorkerPool) execute(ctx context.Context, fn WorkerFunc) {
- var acquired bool
-
- // Set as running
- pool.wait.Add(1)
-
- select {
- // Pool context cancelled
- // (we fall through and let
- // the function execute).
- case <-ctx.Done():
-
- // Free worker acquired.
- case pool.free <- struct{}{}:
- acquired = true
- }
-
- go func() {
- defer func() {
- // defer in case panic
- if acquired {
- <-pool.free
- }
- pool.wait.Done()
- }()
-
- // Run queued
- fn(ctx)
- }()
-}
-
-// process is the background processing routine that passes queued functions to workers.
-func (pool *WorkerPool) process(ctx context.Context) {
- for {
- select {
- // Pool context cancelled
- case <-ctx.Done():
- for {
- select {
- // Pop and execute queued
- case fn := <-pool.queue:
- fn(ctx) // ctx is closed
-
- // Empty, wait for workers
- default:
- pool.wait.Wait()
- return
- }
- }
-
- // Queued func received
- case fn := <-pool.queue:
- pool.execute(ctx, fn)
- }
- }
-}
-
-// Enqueue will add provided WorkerFunc to the queue to be performed when there is a free worker.
-// This will block until the function has been queued. 'fn' will ALWAYS be executed, even on pool
-// close, which can be determined via context <-ctx.Done(). WorkerFuncs MUST respect the passed context.
-func (pool *WorkerPool) Enqueue(fn WorkerFunc) {
- // Check valid fn
- if fn == nil {
- return
- }
-
- select {
- // Pool context cancelled
- case <-pool.svc.Done():
- fn(closedctx)
-
- // Placed fn in queue
- case pool.queue <- fn:
- }
-}
-
-// EnqueueNoBlock attempts Enqueue but returns false if not executed.
-func (pool *WorkerPool) EnqueueNoBlock(fn WorkerFunc) bool {
- // Check valid fn
- if fn == nil {
- return false
- }
-
- select {
- // Pool context cancelled
- case <-pool.svc.Done():
- return false
-
- // Placed fn in queue
- case pool.queue <- fn:
- return true
-
- // Queue is full
- default:
- return false
- }
-}
-
-// Queue returns the number of currently queued WorkerFuncs.
-func (pool *WorkerPool) Queue() int {
- return len(pool.queue)
-}
-
-// Workers returns the number of currently active workers.
-func (pool *WorkerPool) Workers() int {
- return len(pool.free)
-}
diff --git a/vendor/codeberg.org/gruf/go-runners/run.go b/vendor/codeberg.org/gruf/go-runners/run.go
deleted file mode 100644
index 67d19b40c..000000000
--- a/vendor/codeberg.org/gruf/go-runners/run.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package runners
-
-import (
- "context"
- "errors"
- "fmt"
- "time"
-
- "codeberg.org/gruf/go-atomics"
-)
-
-// FuncRunner provides a means of managing long-running functions e.g. main logic loops.
-type FuncRunner struct {
- // HandOff is the time after which a blocking function will be considered handed off
- HandOff time.Duration
-
- // ErrorHandler is the function that errors are passed to when encountered by the
- // provided function. This can be used both for logging, and for error filtering
- ErrorHandler func(err error) error
-
- svc Service // underlying service to manage start/stop
- err atomics.Error
-}
-
-// Go will attempt to run 'fn' asynchronously. The provided context is used to propagate requested
-// cancel if FuncRunner.Stop() is called. Any returned error will be passed to FuncRunner.ErrorHandler
-// for filtering/logging/etc. Any blocking functions will be waited on for FuncRunner.HandOff amount of
-// time before considering the function as handed off. Returned bool is success state, i.e. returns true
-// if function is successfully handed off or returns within hand off time with nil error.
-func (r *FuncRunner) Go(fn func(ctx context.Context) error) bool {
- var has bool
-
- done := make(chan struct{})
-
- go func() {
- var cancelled bool
-
- has = r.svc.Run(func(ctx context.Context) {
- // reset error
- r.err.Store(nil)
-
- // Run supplied func and set errror if returned
- if err := Run(func() error { return fn(ctx) }); err != nil {
- r.err.Store(err)
- }
-
- // signal done
- close(done)
-
- // Check if cancelled
- select {
- case <-ctx.Done():
- cancelled = true
- default:
- cancelled = false
- }
- })
-
- switch has {
- // returned after starting
- case true:
- // Load set error
- err := r.err.Load()
-
- // filter out errors due FuncRunner.Stop() being called
- if cancelled && errors.Is(err, context.Canceled) {
- // filter out errors from FuncRunner.Stop() being called
- r.err.Store(nil)
- } else if err != nil && r.ErrorHandler != nil {
- // pass any non-nil error to set handler
- r.err.Store(r.ErrorHandler(err))
- }
-
- // already running
- case false:
- close(done)
- }
- }()
-
- // get valid handoff to use
- handoff := r.HandOff
- if handoff < 1 {
- handoff = time.Second * 5
- }
-
- select {
- // handed off (long-run successful)
- case <-time.After(handoff):
- return true
-
- // 'fn' returned, check error
- case <-done:
- return has
- }
-}
-
-// Stop will cancel the context supplied to the running function.
-func (r *FuncRunner) Stop() bool {
- return r.svc.Stop()
-}
-
-// Err returns the last-set error value.
-func (r *FuncRunner) Err() error {
- return r.err.Load()
-}
-
-// Run will execute the supplied 'fn' catching any panics. Returns either function-returned error or formatted panic.
-func Run(fn func() error) (err error) {
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- // wrap and preserve existing error
- err = fmt.Errorf("caught panic: %w", e)
- } else {
- // simply create new error fromt iface
- err = fmt.Errorf("caught panic: %v", r)
- }
- }
- }()
-
- // run supplied func
- err = fn()
- return
-}
diff --git a/vendor/codeberg.org/gruf/go-runners/service.go b/vendor/codeberg.org/gruf/go-runners/service.go
deleted file mode 100644
index c0f878c45..000000000
--- a/vendor/codeberg.org/gruf/go-runners/service.go
+++ /dev/null
@@ -1,159 +0,0 @@
-package runners
-
-import (
- "context"
- "sync"
-)
-
-// Service provides a means of tracking a single long-running service, provided protected state
-// changes and preventing multiple instances running. Also providing service state information.
-type Service struct {
- state uint32 // 0=stopped, 1=running, 2=stopping
- wait sync.Mutex // wait is the mutex used as a single-entity wait-group, i.e. just a "wait" :p
- cncl context.CancelFunc // cncl is the cancel function set for the current context
- ctx context.Context // ctx is the current context for running function (or nil if not running)
- mu sync.Mutex // mu protects state changes
-}
-
-// Run will run the supplied function until completion, use given context to propagate cancel.
-// Immediately returns false if the Service is already running, and true after completed run.
-func (svc *Service) Run(fn func(context.Context)) bool {
- // Attempt to start the svc
- ctx, ok := svc.doStart()
- if !ok {
- return false
- }
-
- defer func() {
- // unlock single wait
- svc.wait.Unlock()
-
- // ensure stopped
- svc.Stop()
- }()
-
- // Run user func
- if fn != nil {
- fn(ctx)
- }
- return true
-}
-
-// Stop will attempt to stop the service, cancelling the running function's context. Immediately
-// returns false if not running, and true only after Service is fully stopped.
-func (svc *Service) Stop() bool {
- // Attempt to stop the svc
- cncl, ok := svc.doStop()
- if !ok {
- return false
- }
-
- defer func() {
- // Get svc lock
- svc.mu.Lock()
-
- // Wait until stopped
- svc.wait.Lock()
- svc.wait.Unlock()
-
- // Reset the svc
- svc.ctx = nil
- svc.cncl = nil
- svc.state = 0
- svc.mu.Unlock()
- }()
-
- cncl() // cancel ctx
- return true
-}
-
-// doStart will safely set Service state to started, returning a ptr to this context insance.
-func (svc *Service) doStart() (context.Context, bool) {
- // Protect startup
- svc.mu.Lock()
-
- if svc.state != 0 /* not stopped */ {
- svc.mu.Unlock()
- return nil, false
- }
-
- // state started
- svc.state = 1
-
- // Take our own ptr
- var ctx context.Context
-
- if svc.ctx == nil {
- // Context required allocating
- svc.ctx, svc.cncl = ContextWithCancel()
- }
-
- // Start the waiter
- svc.wait.Lock()
-
- // Set our ptr + unlock
- ctx = svc.ctx
- svc.mu.Unlock()
-
- return ctx, true
-}
-
-// doStop will safely set Service state to stopping, returning a ptr to this cancelfunc instance.
-func (svc *Service) doStop() (context.CancelFunc, bool) {
- // Protect stop
- svc.mu.Lock()
-
- if svc.state != 1 /* not started */ {
- svc.mu.Unlock()
- return nil, false
- }
-
- // state stopping
- svc.state = 2
-
- // Take our own ptr
- // and unlock state
- cncl := svc.cncl
- svc.mu.Unlock()
-
- return cncl, true
-}
-
-// Running returns if Service is running (i.e. state NOT stopped / stopping).
-func (svc *Service) Running() bool {
- svc.mu.Lock()
- state := svc.state
- svc.mu.Unlock()
- return (state == 1)
-}
-
-// Done returns a channel that's closed when Service.Stop() is called. It is
-// the same channel provided to the currently running service function.
-func (svc *Service) Done() <-chan struct{} {
- var done <-chan struct{}
-
- svc.mu.Lock()
- switch svc.state {
- // stopped
- // (here we create a new context so that the
- // returned 'done' channel here will still
- // be valid for when Service is next started)
- case 0:
- if svc.ctx == nil {
- // need to allocate new context
- svc.ctx, svc.cncl = ContextWithCancel()
- }
- done = svc.ctx.Done()
-
- // started
- case 1:
- done = svc.ctx.Done()
-
- // stopping
- case 2:
- done = svc.ctx.Done()
- }
- svc.mu.Unlock()
-
- return done
-}
diff --git a/vendor/codeberg.org/gruf/go-sched/LICENSE b/vendor/codeberg.org/gruf/go-sched/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-sched/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-sched/README.md b/vendor/codeberg.org/gruf/go-sched/README.md
deleted file mode 100644
index d32a961ae..000000000
--- a/vendor/codeberg.org/gruf/go-sched/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# go-sched
-
-A simple job (both run-once and recurring) queueing library with down-to millisecond precision.
-
-Precision estimates based on test output (running on i7-11800h): 1ms precision with 80% tolerance. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-sched/job.go b/vendor/codeberg.org/gruf/go-sched/job.go
deleted file mode 100644
index 7831a39bd..000000000
--- a/vendor/codeberg.org/gruf/go-sched/job.go
+++ /dev/null
@@ -1,118 +0,0 @@
-package sched
-
-import (
- "reflect"
- "strconv"
- "strings"
- "time"
-
- "codeberg.org/gruf/go-atomics"
-)
-
-// Job encapsulates logic for a scheduled job to be run according
-// to a set Timing, executing the job with a set panic handler, and
-// holding onto a next execution time safely in a concurrent environment.
-type Job struct {
- id uint64
- next atomics.Time
- timing Timing
- call func(time.Time)
- panic func(interface{})
-}
-
-// NewJob returns a new Job to run given function.
-func NewJob(fn func(now time.Time)) *Job {
- if fn == nil {
- // Ensure a function
- panic("nil func")
- }
-
- j := &Job{ // set defaults
- timing: emptytiming, // i.e. fire immediately
- call: fn,
- panic: func(i interface{}) { panic(i) },
- }
-
- // Init next time ptr
- j.next.Store(zerotime)
-
- return j
-}
-
-// At sets this Job to execute at time, by passing (*sched.Once)(&at) to .With(). See .With() for details.
-func (job *Job) At(at time.Time) *Job {
- return job.With((*Once)(&at))
-}
-
-// Every sets this Job to execute every period, by passing sched.Period(period) to .With(). See .With() for details.
-func (job *Job) Every(period time.Duration) *Job {
- return job.With(Periodic(period))
-}
-
-// EveryAt sets this Job to execute every period starting at time, by passing &PeriodicAt{once: Once(at), period: Periodic(period)} to .With(). See .With() for details.
-func (job *Job) EveryAt(at time.Time, period time.Duration) *Job {
- return job.With(&PeriodicAt{Once: Once(at), Period: Periodic(period)})
-}
-
-// With sets this Job's timing to given implementation, or if already set will wrap existing using sched.TimingWrap{}.
-func (job *Job) With(t Timing) *Job {
- if t == nil {
- // Ensure a timing
- panic("nil Timing")
- }
-
- if job.timing == emptytiming {
- // Set new timing
- job.timing = t
- } else {
- // Wrap old timing
- old := job.timing
- job.timing = &TimingWrap{
- Outer: t,
- Inner: old,
- }
- }
-
- return job
-}
-
-// Panic specifics how this job handles panics, default is an actual panic.
-func (job *Job) Panic(fn func(interface{})) *Job {
- if fn == nil {
- // Ensure a function
- panic("nil func")
- }
- job.panic = fn
- return job
-}
-
-// Next returns the next time this Job is expected to run.
-func (job *Job) Next() time.Time {
- return job.next.Load()
-}
-
-// Run will execute this Job and pass through given now time.
-func (job *Job) Run(now time.Time) {
- defer func() {
- if r := recover(); r != nil {
- job.panic(r)
- }
- }()
- job.call(now)
-}
-
-// String provides a debuggable string representation of Job including ID, next time and Timing type.
-func (job *Job) String() string {
- var buf strings.Builder
- buf.WriteByte('{')
- buf.WriteString("id=")
- buf.WriteString(strconv.FormatUint(job.id, 10))
- buf.WriteByte(' ')
- buf.WriteString("next=")
- buf.WriteString(job.next.Load().Format(time.StampMicro))
- buf.WriteByte(' ')
- buf.WriteString("timing=")
- buf.WriteString(reflect.TypeOf(job.timing).String())
- buf.WriteByte('}')
- return buf.String()
-}
diff --git a/vendor/codeberg.org/gruf/go-sched/scheduler.go b/vendor/codeberg.org/gruf/go-sched/scheduler.go
deleted file mode 100644
index 8d076fea0..000000000
--- a/vendor/codeberg.org/gruf/go-sched/scheduler.go
+++ /dev/null
@@ -1,250 +0,0 @@
-package sched
-
-import (
- "context"
- "sort"
- "time"
-
- "codeberg.org/gruf/go-atomics"
- "codeberg.org/gruf/go-runners"
-)
-
-var (
- // neverticks is a timer channel that never ticks (it's starved).
- neverticks = make(chan time.Time)
-
- // alwaysticks is a timer channel that always ticks (it's closed).
- alwaysticks = func() chan time.Time {
- ch := make(chan time.Time)
- close(ch)
- return ch
- }()
-)
-
-// Scheduler provides a means of running jobs at specific times and
-// regular intervals, all while sharing a single underlying timer.
-type Scheduler struct {
- jobs []*Job // jobs is a list of tracked Jobs to be executed
- jch chan interface{} // jch accepts either Jobs or job IDs to notify new/removed jobs
- svc runners.Service // svc manages the main scheduler routine
- jid atomics.Uint64 // jid is used to iteratively generate unique IDs for jobs
-}
-
-// New returns a new Scheduler instance with given job change queue size.
-func NewScheduler(queue int) Scheduler {
- if queue < 0 {
- queue = 10
- }
- return Scheduler{jch: make(chan interface{}, queue)}
-}
-
-// Start will attempt to start the Scheduler. Immediately returns false if the Service is already running, and true after completed run.
-func (sch *Scheduler) Start() bool {
- return sch.svc.Run(sch.run)
-}
-
-// Stop will attempt to stop the Scheduler. Immediately returns false if not running, and true only after Scheduler is fully stopped.
-func (sch *Scheduler) Stop() bool {
- return sch.svc.Stop()
-}
-
-// Running will return whether Scheduler is running.
-func (sch *Scheduler) Running() bool {
- return sch.svc.Running()
-}
-
-// Schedule will add provided Job to the Scheduler, returning a cancel function.
-func (sch *Scheduler) Schedule(job *Job) (cancel func()) {
- if job == nil {
- // Ensure there's a job!
- panic("nil job")
- }
-
- // Get last known job ID
- last := sch.jid.Load()
-
- // Give this job an ID and check overflow
- if job.id = sch.jid.Add(1); job.id < last {
- panic("scheduler job id overflow")
- }
-
- // Pass job to scheduler
- sch.jch <- job
-
- // Return cancel function for job ID
- return func() { sch.jch <- job.id }
-}
-
-// run is the main scheduler run routine, which runs for as long as ctx is valid.
-func (sch *Scheduler) run(ctx context.Context) {
- var (
- // timerset represents whether timer was running
- // for a particular run of the loop. false means
- // that tch == neverticks || tch == alwaysticks
- timerset bool
-
- // timer tick channel (or a never-tick channel)
- tch <-chan time.Time
-
- // timer notifies this main routine to wake when
- // the job queued needs to be checked for executions
- timer *time.Timer
-
- // stopdrain will stop and drain the timer
- // if it has been running (i.e. timerset == true)
- stopdrain = func() {
- if timerset && !timer.Stop() {
- <-timer.C
- }
- }
- )
-
- for {
- select {
- // Handle received job/id
- case v := <-sch.jch:
- sch.handle(v)
- continue
-
- // No more
- default:
- }
-
- // Done
- break
- }
-
- // Create a stopped timer
- timer = time.NewTimer(1)
- <-timer.C
-
- for {
- // Reset timer state
- timerset = false
-
- if len(sch.jobs) > 0 {
- // Sort jobs by next occurring
- sort.Sort(byNext(sch.jobs))
-
- // Get execution time
- now := time.Now()
-
- // Get next job time
- next := sch.jobs[0].Next()
-
- // If this job is _just_ about to be ready, we
- // don't bother sleeping. It's wasted cycles only
- // sleeping for some obscenely tiny amount of time
- // we can't guarantee precision for.
- const precision = time.Millisecond
-
- if until := next.Sub(now); until <= precision/1e3 {
- // This job is behind schedule,
- // set timer to always tick
- tch = alwaysticks
- } else {
- // Reset timer to period
- timer.Reset(until)
- tch = timer.C
- timerset = true
- }
- } else {
- // Unset timer
- tch = neverticks
- }
-
- select {
- // Scheduler stopped
- case <-ctx.Done():
- stopdrain()
- return
-
- // Timer ticked, run scheduled
- case now := <-tch:
- if !timerset {
- // alwaysticks returns zero times
- now = time.Now()
- }
- sch.schedule(now)
-
- // Received update, handle job/id
- case v := <-sch.jch:
- sch.handle(v)
- stopdrain()
- }
- }
-}
-
-// handle takes an interfaces received from Scheduler.jch and handles either:
-// - Job --> new job to add.
-// - uint64 --> job ID to remove.
-func (sch *Scheduler) handle(v interface{}) {
- switch v := v.(type) {
- // New job added
- case *Job:
- // Get current time
- now := time.Now()
-
- // Update the next call time
- next := v.timing.Next(now)
- v.next.Store(next)
-
- // Append this job to queued
- sch.jobs = append(sch.jobs, v)
-
- // Job removed
- case uint64:
- for i := 0; i < len(sch.jobs); i++ {
- if sch.jobs[i].id == v {
- // This is the job we're looking for! Drop this
- sch.jobs = append(sch.jobs[:i], sch.jobs[i+1:]...)
- return
- }
- }
- }
-}
-
-// schedule will iterate through the scheduler jobs and execute those necessary, updating their next call time.
-func (sch *Scheduler) schedule(now time.Time) {
- for i := 0; i < len(sch.jobs); {
- // Scope our own var
- job := sch.jobs[i]
-
- // We know these jobs are ordered by .Next(), so as soon
- // as we reach one with .Next() after now, we can return
- if job.Next().After(now) {
- return
- }
-
- // Update the next call time
- next := job.timing.Next(now)
- job.next.Store(next)
-
- // Run this job async!
- go job.Run(now)
-
- if next.IsZero() {
- // Zero time, this job is done and can be dropped
- sch.jobs = append(sch.jobs[:i], sch.jobs[i+1:]...)
- continue
- }
-
- // Iter
- i++
- }
-}
-
-// byNext is an implementation of sort.Interface to sort Jobs by their .Next() time.
-type byNext []*Job
-
-func (by byNext) Len() int {
- return len(by)
-}
-
-func (by byNext) Less(i int, j int) bool {
- return by[i].Next().Before(by[j].Next())
-}
-
-func (by byNext) Swap(i int, j int) {
- by[i], by[j] = by[j], by[i]
-}
diff --git a/vendor/codeberg.org/gruf/go-sched/timing.go b/vendor/codeberg.org/gruf/go-sched/timing.go
deleted file mode 100644
index 33c230fa5..000000000
--- a/vendor/codeberg.org/gruf/go-sched/timing.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package sched
-
-import (
- "time"
-)
-
-var (
- // zerotime is zero time.Time (unix epoch).
- zerotime = time.Time{}
-
- // emptytiming is a global timingempty to check against.
- emptytiming = timingempty{}
-)
-
-// Timing provides scheduling for a Job, determining the next time
-// for given current time that execution is required. Please note that
-// calls to .Next() may alter the results of the next call, and should
-// only be called by the Scheduler.
-type Timing interface {
- Next(time.Time) time.Time
-}
-
-// timingempty is a 'zero' Timing implementation that always returns zero time.
-type timingempty struct{}
-
-func (timingempty) Next(time.Time) time.Time {
- return zerotime
-}
-
-// Once implements Timing to provide a run-once Job execution.
-type Once time.Time
-
-func (o *Once) Next(time.Time) time.Time {
- ret := *(*time.Time)(o)
- *o = Once(zerotime) // reset
- return ret
-}
-
-// Periodic implements Timing to provide a recurring Job execution.
-type Periodic time.Duration
-
-func (p Periodic) Next(now time.Time) time.Time {
- return now.Add(time.Duration(p))
-}
-
-// PeriodicAt implements Timing to provide a recurring Job execution starting at 'Once' time.
-type PeriodicAt struct {
- Once Once
- Period Periodic
-}
-
-func (p *PeriodicAt) Next(now time.Time) time.Time {
- if next := p.Once.Next(now); !next.IsZero() {
- return next
- }
- return p.Period.Next(now)
-}
-
-// TimingWrap allows combining two different Timing implementations.
-type TimingWrap struct {
- Outer Timing
- Inner Timing
-
- // determined next times
- outerNext time.Time
- innerNext time.Time
-}
-
-func (t *TimingWrap) Next(now time.Time) time.Time {
- if t.outerNext.IsZero() {
- // Regenerate outermost next run time
- t.outerNext = t.Outer.Next(now)
- }
-
- if t.innerNext.IsZero() {
- // Regenerate innermost next run time
- t.innerNext = t.Inner.Next(now)
- }
-
- // If outer comes before inner, return outer
- if t.outerNext != zerotime &&
- t.outerNext.Before(t.innerNext) {
- next := t.outerNext
- t.outerNext = zerotime
- return next
- }
-
- // Else, return inner
- next := t.innerNext
- t.innerNext = zerotime
- return next
-}
diff --git a/vendor/codeberg.org/gruf/go-store/LICENSE b/vendor/codeberg.org/gruf/go-store/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-store/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-store/kv/iterator.go b/vendor/codeberg.org/gruf/go-store/kv/iterator.go
deleted file mode 100644
index 2fe5dd428..000000000
--- a/vendor/codeberg.org/gruf/go-store/kv/iterator.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package kv
-
-import (
- "errors"
-
- "codeberg.org/gruf/go-mutexes"
- "codeberg.org/gruf/go-store/storage"
-)
-
-var ErrIteratorClosed = errors.New("store/kv: iterator closed")
-
-// KVIterator provides a read-only iterator to all the key-value
-// pairs in a KVStore. While the iterator is open the store is read
-// locked, you MUST release the iterator when you are finished with
-// it.
-//
-// Please note:
-// - individual iterators are NOT concurrency safe, though it is safe to
-// have multiple iterators running concurrently
-type KVIterator struct {
- store *KVStore // store is the linked KVStore
- state *mutexes.LockState
- entries []storage.StorageEntry
- index int
- key string
-}
-
-// Next attempts to set the next key-value pair, the
-// return value is if there was another pair remaining
-func (i *KVIterator) Next() bool {
- next := i.index + 1
- if next >= len(i.entries) {
- i.key = ""
- return false
- }
- i.key = i.entries[next].Key()
- i.index = next
- return true
-}
-
-// Key returns the next key from the store
-func (i *KVIterator) Key() string {
- return i.key
-}
-
-// Release releases the KVIterator and KVStore's read lock
-func (i *KVIterator) Release() {
- i.state.UnlockMap()
- i.store = nil
- i.key = ""
- i.entries = nil
-}
-
-// Value returns the next value from the KVStore
-func (i *KVIterator) Value() ([]byte, error) {
- // Check store isn't closed
- if i.store == nil {
- return nil, ErrIteratorClosed
- }
-
- // Attempt to fetch from store
- return i.store.get(i.state.RLock, i.key)
-}
diff --git a/vendor/codeberg.org/gruf/go-store/kv/state.go b/vendor/codeberg.org/gruf/go-store/kv/state.go
deleted file mode 100644
index f9f789521..000000000
--- a/vendor/codeberg.org/gruf/go-store/kv/state.go
+++ /dev/null
@@ -1,130 +0,0 @@
-package kv
-
-import (
- "errors"
- "io"
-
- "codeberg.org/gruf/go-mutexes"
-)
-
-var ErrStateClosed = errors.New("store/kv: state closed")
-
-// StateRO provides a read-only window to the store. While this
-// state is active during the Read() function window, the entire
-// store will be read-locked. The state is thread-safe for concurrent
-// use UNTIL the moment that your supplied function to Read() returns,
-// then the state has zero guarantees
-type StateRO struct {
- store *KVStore
- state *mutexes.LockState
-}
-
-func (st *StateRO) Get(key string) ([]byte, error) {
- // Check not closed
- if st.store == nil {
- return nil, ErrStateClosed
- }
-
- // Pass request to store
- return st.store.get(st.state.RLock, key)
-}
-
-func (st *StateRO) GetStream(key string) (io.ReadCloser, error) {
- // Check not closed
- if st.store == nil {
- return nil, ErrStateClosed
- }
-
- // Pass request to store
- return st.store.getStream(st.state.RLock, key)
-}
-
-func (st *StateRO) Has(key string) (bool, error) {
- // Check not closed
- if st.store == nil {
- return false, ErrStateClosed
- }
-
- // Pass request to store
- return st.store.has(st.state.RLock, key)
-}
-
-func (st *StateRO) Release() {
- st.state.UnlockMap()
- st.store = nil
-}
-
-// StateRW provides a read-write window to the store. While this
-// state is active during the Update() function window, the entire
-// store will be locked. The state is thread-safe for concurrent
-// use UNTIL the moment that your supplied function to Update() returns,
-// then the state has zero guarantees
-type StateRW struct {
- store *KVStore
- state *mutexes.LockState
-}
-
-func (st *StateRW) Get(key string) ([]byte, error) {
- // Check not closed
- if st.store == nil {
- return nil, ErrStateClosed
- }
-
- // Pass request to store
- return st.store.get(st.state.RLock, key)
-}
-
-func (st *StateRW) GetStream(key string) (io.ReadCloser, error) {
- // Check not closed
- if st.store == nil {
- return nil, ErrStateClosed
- }
-
- // Pass request to store
- return st.store.getStream(st.state.RLock, key)
-}
-
-func (st *StateRW) Put(key string, value []byte) error {
- // Check not closed
- if st.store == nil {
- return ErrStateClosed
- }
-
- // Pass request to store
- return st.store.put(st.state.Lock, key, value)
-}
-
-func (st *StateRW) PutStream(key string, r io.Reader) error {
- // Check not closed
- if st.store == nil {
- return ErrStateClosed
- }
-
- // Pass request to store
- return st.store.putStream(st.state.Lock, key, r)
-}
-
-func (st *StateRW) Has(key string) (bool, error) {
- // Check not closed
- if st.store == nil {
- return false, ErrStateClosed
- }
-
- // Pass request to store
- return st.store.has(st.state.RLock, key)
-}
-
-func (st *StateRW) Delete(key string) error {
- // Check not closed
- if st.store == nil {
- return ErrStateClosed
- }
-
- // Pass request to store
- return st.store.delete(st.state.Lock, key)
-}
-
-func (st *StateRW) Release() {
- st.state.UnlockMap()
- st.store = nil
-}
diff --git a/vendor/codeberg.org/gruf/go-store/kv/store.go b/vendor/codeberg.org/gruf/go-store/kv/store.go
deleted file mode 100644
index fd9935f25..000000000
--- a/vendor/codeberg.org/gruf/go-store/kv/store.go
+++ /dev/null
@@ -1,227 +0,0 @@
-package kv
-
-import (
- "io"
-
- "codeberg.org/gruf/go-mutexes"
- "codeberg.org/gruf/go-store/storage"
- "codeberg.org/gruf/go-store/util"
-)
-
-// KVStore is a very simple, yet performant key-value store
-type KVStore struct {
- mutex mutexes.MutexMap // mutex is a map of keys to mutexes to protect file access
- storage storage.Storage // storage is the underlying storage
-}
-
-func OpenFile(path string, cfg *storage.DiskConfig) (*KVStore, error) {
- // Attempt to open disk storage
- storage, err := storage.OpenFile(path, cfg)
- if err != nil {
- return nil, err
- }
-
- // Return new KVStore
- return OpenStorage(storage)
-}
-
-func OpenBlock(path string, cfg *storage.BlockConfig) (*KVStore, error) {
- // Attempt to open block storage
- storage, err := storage.OpenBlock(path, cfg)
- if err != nil {
- return nil, err
- }
-
- // Return new KVStore
- return OpenStorage(storage)
-}
-
-func OpenStorage(storage storage.Storage) (*KVStore, error) {
- // Perform initial storage clean
- err := storage.Clean()
- if err != nil {
- return nil, err
- }
-
- // Return new KVStore
- return &KVStore{
- mutex: mutexes.NewMap(-1, -1),
- storage: storage,
- }, nil
-}
-
-// RLock acquires a read-lock on supplied key, returning unlock function.
-func (st *KVStore) RLock(key string) (runlock func()) {
- return st.mutex.RLock(key)
-}
-
-// Lock acquires a write-lock on supplied key, returning unlock function.
-func (st *KVStore) Lock(key string) (unlock func()) {
- return st.mutex.Lock(key)
-}
-
-// Get fetches the bytes for supplied key in the store
-func (st *KVStore) Get(key string) ([]byte, error) {
- return st.get(st.RLock, key)
-}
-
-func (st *KVStore) get(rlock func(string) func(), key string) ([]byte, error) {
- // Acquire read lock for key
- runlock := rlock(key)
- defer runlock()
-
- // Read file bytes
- return st.storage.ReadBytes(key)
-}
-
-// GetStream fetches a ReadCloser for the bytes at the supplied key location in the store
-func (st *KVStore) GetStream(key string) (io.ReadCloser, error) {
- return st.getStream(st.RLock, key)
-}
-
-func (st *KVStore) getStream(rlock func(string) func(), key string) (io.ReadCloser, error) {
- // Acquire read lock for key
- runlock := rlock(key)
-
- // Attempt to open stream for read
- rd, err := st.storage.ReadStream(key)
- if err != nil {
- runlock()
- return nil, err
- }
-
- // Wrap readcloser in our own callback closer
- return util.ReadCloserWithCallback(rd, runlock), nil
-}
-
-// Put places the bytes at the supplied key location in the store
-func (st *KVStore) Put(key string, value []byte) error {
- return st.put(st.Lock, key, value)
-}
-
-func (st *KVStore) put(lock func(string) func(), key string, value []byte) error {
- // Acquire write lock for key
- unlock := lock(key)
- defer unlock()
-
- // Write file bytes
- return st.storage.WriteBytes(key, value)
-}
-
-// PutStream writes the bytes from the supplied Reader at the supplied key location in the store
-func (st *KVStore) PutStream(key string, r io.Reader) error {
- return st.putStream(st.Lock, key, r)
-}
-
-func (st *KVStore) putStream(lock func(string) func(), key string, r io.Reader) error {
- // Acquire write lock for key
- unlock := lock(key)
- defer unlock()
-
- // Write file stream
- return st.storage.WriteStream(key, r)
-}
-
-// Has checks whether the supplied key exists in the store
-func (st *KVStore) Has(key string) (bool, error) {
- return st.has(st.RLock, key)
-}
-
-func (st *KVStore) has(rlock func(string) func(), key string) (bool, error) {
- // Acquire read lock for key
- runlock := rlock(key)
- defer runlock()
-
- // Stat file on disk
- return st.storage.Stat(key)
-}
-
-// Delete removes the supplied key-value pair from the store
-func (st *KVStore) Delete(key string) error {
- return st.delete(st.Lock, key)
-}
-
-func (st *KVStore) delete(lock func(string) func(), key string) error {
- // Acquire write lock for key
- unlock := lock(key)
- defer unlock()
-
- // Remove file from disk
- return st.storage.Remove(key)
-}
-
-// Iterator returns an Iterator for key-value pairs in the store, using supplied match function
-func (st *KVStore) Iterator(matchFn func(string) bool) (*KVIterator, error) {
- // If no function, match all
- if matchFn == nil {
- matchFn = func(string) bool { return true }
- }
-
- // Get store read lock
- state := st.mutex.RLockMap()
-
- // Setup the walk keys function
- entries := []storage.StorageEntry{}
- walkFn := func(entry storage.StorageEntry) {
- // Ignore unmatched entries
- if !matchFn(entry.Key()) {
- return
- }
-
- // Add to entries
- entries = append(entries, entry)
- }
-
- // Walk keys in the storage
- err := st.storage.WalkKeys(storage.WalkKeysOptions{WalkFn: walkFn})
- if err != nil {
- state.UnlockMap()
- return nil, err
- }
-
- // Return new iterator
- return &KVIterator{
- store: st,
- state: state,
- entries: entries,
- index: -1,
- key: "",
- }, nil
-}
-
-// Read provides a read-only window to the store, holding it in a read-locked state until release
-func (st *KVStore) Read() *StateRO {
- state := st.mutex.RLockMap()
- return &StateRO{store: st, state: state}
-}
-
-// ReadFn provides a read-only window to the store, holding it in a read-locked state until fn return.
-func (st *KVStore) ReadFn(fn func(*StateRO)) {
- // Acquire read-only state
- state := st.Read()
- defer state.Release()
-
- // Pass to fn
- fn(state)
-}
-
-// Update provides a read-write window to the store, holding it in a write-locked state until release
-func (st *KVStore) Update() *StateRW {
- state := st.mutex.LockMap()
- return &StateRW{store: st, state: state}
-}
-
-// UpdateFn provides a read-write window to the store, holding it in a write-locked state until fn return.
-func (st *KVStore) UpdateFn(fn func(*StateRW)) {
- // Acquire read-write state
- state := st.Update()
- defer state.Release()
-
- // Pass to fn
- fn(state)
-}
-
-// Close will close the underlying storage, the mutex map locking (e.g. RLock(), Lock() will still work).
-func (st *KVStore) Close() error {
- return st.storage.Close()
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/block.go b/vendor/codeberg.org/gruf/go-store/storage/block.go
deleted file mode 100644
index c0bb6b383..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/block.go
+++ /dev/null
@@ -1,895 +0,0 @@
-package storage
-
-import (
- "bytes"
- "crypto/sha256"
- "fmt"
- "io"
- "io/fs"
- "os"
- "strings"
- "sync"
- "syscall"
-
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-errors/v2"
- "codeberg.org/gruf/go-fastcopy"
- "codeberg.org/gruf/go-hashenc"
- "codeberg.org/gruf/go-pools"
- "codeberg.org/gruf/go-store/util"
-)
-
-var (
- nodePathPrefix = "node/"
- blockPathPrefix = "block/"
-)
-
-// DefaultBlockConfig is the default BlockStorage configuration
-var DefaultBlockConfig = &BlockConfig{
- BlockSize: 1024 * 16,
- WriteBufSize: 4096,
- Overwrite: false,
- Compression: NoCompression(),
-}
-
-// BlockConfig defines options to be used when opening a BlockStorage
-type BlockConfig struct {
- // BlockSize is the chunking size to use when splitting and storing blocks of data
- BlockSize int
-
- // ReadBufSize is the buffer size to use when reading node files
- ReadBufSize int
-
- // WriteBufSize is the buffer size to use when writing file streams (PutStream)
- WriteBufSize int
-
- // Overwrite allows overwriting values of stored keys in the storage
- Overwrite bool
-
- // Compression is the Compressor to use when reading / writing files, default is no compression
- Compression Compressor
-}
-
-// getBlockConfig returns a valid BlockConfig for supplied ptr
-func getBlockConfig(cfg *BlockConfig) BlockConfig {
- // If nil, use default
- if cfg == nil {
- cfg = DefaultBlockConfig
- }
-
- // Assume nil compress == none
- if cfg.Compression == nil {
- cfg.Compression = NoCompression()
- }
-
- // Assume 0 chunk size == use default
- if cfg.BlockSize < 1 {
- cfg.BlockSize = DefaultBlockConfig.BlockSize
- }
-
- // Assume 0 buf size == use default
- if cfg.WriteBufSize < 1 {
- cfg.WriteBufSize = DefaultDiskConfig.WriteBufSize
- }
-
- // Return owned config copy
- return BlockConfig{
- BlockSize: cfg.BlockSize,
- WriteBufSize: cfg.WriteBufSize,
- Overwrite: cfg.Overwrite,
- Compression: cfg.Compression,
- }
-}
-
-// BlockStorage is a Storage implementation that stores input data as chunks on
-// a filesystem. Each value is chunked into blocks of configured size and these
-// blocks are stored with name equal to their base64-encoded SHA256 hash-sum. A
-// "node" file is finally created containing an array of hashes contained within
-// this value
-type BlockStorage struct {
- path string // path is the root path of this store
- blockPath string // blockPath is the joined root path + block path prefix
- nodePath string // nodePath is the joined root path + node path prefix
- config BlockConfig // cfg is the supplied configuration for this store
- hashPool sync.Pool // hashPool is this store's hashEncoder pool
- bufpool pools.BufferPool // bufpool is this store's bytes.Buffer pool
- cppool fastcopy.CopyPool // cppool is the prepared io copier with buffer pool
- lock *Lock // lock is the opened lockfile for this storage instance
-
- // NOTE:
- // BlockStorage does not need to lock each of the underlying block files
- // as the filename itself directly relates to the contents. If there happens
- // to be an overwrite, it will just be of the same data since the filename is
- // the hash of the data.
-}
-
-// OpenBlock opens a BlockStorage instance for given folder path and configuration
-func OpenBlock(path string, cfg *BlockConfig) (*BlockStorage, error) {
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- // Clean provided path, ensure ends in '/' (should
- // be dir, this helps with file path trimming later)
- path = pb.Clean(path) + "/"
-
- // Get checked config
- config := getBlockConfig(cfg)
-
- // Attempt to open path
- file, err := os.OpenFile(path, defaultFileROFlags, defaultDirPerms)
- if err != nil {
- // If not a not-exist error, return
- if !os.IsNotExist(err) {
- return nil, err
- }
-
- // Attempt to make store path dirs
- err = os.MkdirAll(path, defaultDirPerms)
- if err != nil {
- return nil, err
- }
-
- // Reopen dir now it's been created
- file, err = os.OpenFile(path, defaultFileROFlags, defaultDirPerms)
- if err != nil {
- return nil, err
- }
- }
- defer file.Close()
-
- // Double check this is a dir (NOT a file!)
- stat, err := file.Stat()
- if err != nil {
- return nil, err
- } else if !stat.IsDir() {
- return nil, errPathIsFile
- }
-
- // Open and acquire storage lock for path
- lock, err := OpenLock(pb.Join(path, LockFile))
- if err != nil {
- return nil, err
- }
-
- // Figure out the largest size for bufpool slices
- bufSz := encodedHashLen
- if bufSz < config.BlockSize {
- bufSz = config.BlockSize
- }
- if bufSz < config.WriteBufSize {
- bufSz = config.WriteBufSize
- }
-
- // Prepare BlockStorage
- st := &BlockStorage{
- path: path,
- blockPath: pb.Join(path, blockPathPrefix),
- nodePath: pb.Join(path, nodePathPrefix),
- config: config,
- hashPool: sync.Pool{
- New: func() interface{} {
- return newHashEncoder()
- },
- },
- bufpool: pools.NewBufferPool(bufSz),
- lock: lock,
- }
-
- // Set copypool buffer size
- st.cppool.Buffer(config.ReadBufSize)
-
- return st, nil
-}
-
-// Clean implements storage.Clean()
-func (st *BlockStorage) Clean() error {
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- nodes := map[string]*node{}
- onceErr := errors.OnceError{}
-
- // Walk nodes dir for entries
- err := util.WalkDir(pb, st.nodePath, func(npath string, fsentry fs.DirEntry) {
- // Only deal with regular files
- if !fsentry.Type().IsRegular() {
- return
- }
-
- // Stop if we hit error previously
- if onceErr.IsSet() {
- return
- }
-
- // Get joined node path name
- npath = pb.Join(npath, fsentry.Name())
-
- // Attempt to open RO file
- file, err := open(npath, defaultFileROFlags)
- if err != nil {
- onceErr.Store(err)
- return
- }
- defer file.Close()
-
- // Alloc new Node + acquire hash buffer for writes
- hbuf := st.bufpool.Get()
- defer st.bufpool.Put(hbuf)
- hbuf.Guarantee(encodedHashLen)
- node := node{}
-
- // Write file contents to node
- _, err = io.CopyBuffer(
- &nodeWriter{
- node: &node,
- buf: hbuf,
- },
- file,
- nil,
- )
- if err != nil {
- onceErr.Store(err)
- return
- }
-
- // Append to nodes slice
- nodes[fsentry.Name()] = &node
- })
-
- // Handle errors (though nodePath may not have been created yet)
- if err != nil && !os.IsNotExist(err) {
- return err
- } else if onceErr.IsSet() {
- return onceErr.Load()
- }
-
- // Walk blocks dir for entries
- onceErr.Reset()
- err = util.WalkDir(pb, st.blockPath, func(bpath string, fsentry fs.DirEntry) {
- // Only deal with regular files
- if !fsentry.Type().IsRegular() {
- return
- }
-
- // Stop if we hit error previously
- if onceErr.IsSet() {
- return
- }
-
- inUse := false
- for key, node := range nodes {
- if node.removeHash(fsentry.Name()) {
- if len(node.hashes) < 1 {
- // This node contained hash, and after removal is now empty.
- // Remove this node from our tracked nodes slice
- delete(nodes, key)
- }
- inUse = true
- }
- }
-
- // Block hash is used by node
- if inUse {
- return
- }
-
- // Get joined block path name
- bpath = pb.Join(bpath, fsentry.Name())
-
- // Remove this unused block path
- err := os.Remove(bpath)
- if err != nil {
- onceErr.Store(err)
- return
- }
- })
-
- // Handle errors (though blockPath may not have been created yet)
- if err != nil && !os.IsNotExist(err) {
- return err
- } else if onceErr.IsSet() {
- return onceErr.Load()
- }
-
- // If there are nodes left at this point, they are corrupt
- // (i.e. they're referencing block hashes that don't exist)
- if len(nodes) > 0 {
- nodeKeys := []string{}
- for key := range nodes {
- nodeKeys = append(nodeKeys, key)
- }
- return fmt.Errorf("store/storage: corrupted nodes: %v", nodeKeys)
- }
-
- return nil
-}
-
-// ReadBytes implements Storage.ReadBytes()
-func (st *BlockStorage) ReadBytes(key string) ([]byte, error) {
- // Get stream reader for key
- rc, err := st.ReadStream(key)
- if err != nil {
- return nil, err
- }
- defer rc.Close()
-
- // Read all bytes and return
- return io.ReadAll(rc)
-}
-
-// ReadStream implements Storage.ReadStream()
-func (st *BlockStorage) ReadStream(key string) (io.ReadCloser, error) {
- // Get node file path for key
- npath, err := st.nodePathForKey(key)
- if err != nil {
- return nil, err
- }
-
- // Track open
- st.lock.Add()
-
- // Check if open
- if st.lock.Closed() {
- st.lock.Done()
- return nil, ErrClosed
- }
-
- // Attempt to open RO file
- file, err := open(npath, defaultFileROFlags)
- if err != nil {
- st.lock.Done()
- return nil, errSwapNotFound(err)
- }
- defer file.Close()
-
- // Acquire hash buffer for writes
- hbuf := st.bufpool.Get()
- defer st.bufpool.Put(hbuf)
-
- // Write file contents to node
- node := node{}
- _, err = st.cppool.Copy(
- &nodeWriter{
- node: &node,
- buf: hbuf,
- },
- file,
- )
- if err != nil {
- st.lock.Done()
- return nil, err
- }
-
- // Prepare block reader and return
- rc := util.NopReadCloser(&blockReader{
- storage: st,
- node: &node,
- }) // we wrap the blockreader to decr lockfile waitgroup
- return util.ReadCloserWithCallback(rc, st.lock.Done), nil
-}
-
-func (st *BlockStorage) readBlock(key string) ([]byte, error) {
- // Get block file path for key
- bpath := st.blockPathForKey(key)
-
- // Attempt to open RO file
- file, err := open(bpath, defaultFileROFlags)
- if err != nil {
- return nil, wrap(errCorruptNode, err)
- }
- defer file.Close()
-
- // Wrap the file in a compressor
- cFile, err := st.config.Compression.Reader(file)
- if err != nil {
- return nil, wrap(errCorruptNode, err)
- }
- defer cFile.Close()
-
- // Read the entire file
- return io.ReadAll(cFile)
-}
-
-// WriteBytes implements Storage.WriteBytes()
-func (st *BlockStorage) WriteBytes(key string, value []byte) error {
- return st.WriteStream(key, bytes.NewReader(value))
-}
-
-// WriteStream implements Storage.WriteStream()
-func (st *BlockStorage) WriteStream(key string, r io.Reader) error {
- // Get node file path for key
- npath, err := st.nodePathForKey(key)
- if err != nil {
- return err
- }
-
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Check if this exists
- ok, err := stat(key)
- if err != nil {
- return err
- }
-
- // Check if we allow overwrites
- if ok && !st.config.Overwrite {
- return ErrAlreadyExists
- }
-
- // Ensure nodes dir (and any leading up to) exists
- err = os.MkdirAll(st.nodePath, defaultDirPerms)
- if err != nil {
- return err
- }
-
- // Ensure blocks dir (and any leading up to) exists
- err = os.MkdirAll(st.blockPath, defaultDirPerms)
- if err != nil {
- return err
- }
-
- // Alloc new node
- node := node{}
-
- // Acquire HashEncoder
- hc := st.hashPool.Get().(*hashEncoder)
- defer st.hashPool.Put(hc)
-
- // Create new waitgroup and OnceError for
- // goroutine error tracking and propagating
- wg := sync.WaitGroup{}
- onceErr := errors.OnceError{}
-
-loop:
- for !onceErr.IsSet() {
- // Fetch new buffer for this loop
- buf := st.bufpool.Get()
- buf.Grow(st.config.BlockSize)
-
- // Read next chunk
- n, err := io.ReadFull(r, buf.B)
- switch err {
- case nil, io.ErrUnexpectedEOF:
- // do nothing
- case io.EOF:
- st.bufpool.Put(buf)
- break loop
- default:
- st.bufpool.Put(buf)
- return err
- }
-
- // Hash the encoded data
- sum := hc.EncodeSum(buf.B)
-
- // Append to the node's hashes
- node.hashes = append(node.hashes, sum)
-
- // If already on disk, skip
- has, err := st.statBlock(sum)
- if err != nil {
- st.bufpool.Put(buf)
- return err
- } else if has {
- st.bufpool.Put(buf)
- continue loop
- }
-
- // Check if reached EOF
- atEOF := (n < buf.Len())
-
- wg.Add(1)
- go func() {
- // Perform writes in goroutine
-
- defer func() {
- // Defer release +
- // signal we're done
- st.bufpool.Put(buf)
- wg.Done()
- }()
-
- // Write block to store at hash
- err = st.writeBlock(sum, buf.B[:n])
- if err != nil {
- onceErr.Store(err)
- return
- }
- }()
-
- // Break at end
- if atEOF {
- break loop
- }
- }
-
- // Wait, check errors
- wg.Wait()
- if onceErr.IsSet() {
- return onceErr.Load()
- }
-
- // If no hashes created, return
- if len(node.hashes) < 1 {
- return errNoHashesWritten
- }
-
- // Prepare to swap error if need-be
- errSwap := errSwapNoop
-
- // Build file RW flags
- // NOTE: we performed an initial check for
- // this before writing blocks, but if
- // the utilizer of this storage didn't
- // correctly mutex protect this key then
- // someone may have beaten us to the
- // punch at writing the node file.
- flags := defaultFileRWFlags
- if !st.config.Overwrite {
- flags |= syscall.O_EXCL
-
- // Catch + replace err exist
- errSwap = errSwapExist
- }
-
- // Attempt to open RW file
- file, err := open(npath, flags)
- if err != nil {
- return errSwap(err)
- }
- defer file.Close()
-
- // Acquire write buffer
- buf := st.bufpool.Get()
- defer st.bufpool.Put(buf)
- buf.Grow(st.config.WriteBufSize)
-
- // Finally, write data to file
- _, err = io.CopyBuffer(file, &nodeReader{node: &node}, nil)
- return err
-}
-
-// writeBlock writes the block with hash and supplied value to the filesystem
-func (st *BlockStorage) writeBlock(hash string, value []byte) error {
- // Get block file path for key
- bpath := st.blockPathForKey(hash)
-
- // Attempt to open RW file
- file, err := open(bpath, defaultFileRWFlags)
- if err != nil {
- if err == syscall.EEXIST {
- err = nil /* race issue describe in struct NOTE */
- }
- return err
- }
- defer file.Close()
-
- // Wrap the file in a compressor
- cFile, err := st.config.Compression.Writer(file)
- if err != nil {
- return err
- }
- defer cFile.Close()
-
- // Write value to file
- _, err = cFile.Write(value)
- return err
-}
-
-// statBlock checks for existence of supplied block hash
-func (st *BlockStorage) statBlock(hash string) (bool, error) {
- return stat(st.blockPathForKey(hash))
-}
-
-// Stat implements Storage.Stat()
-func (st *BlockStorage) Stat(key string) (bool, error) {
- // Get node file path for key
- kpath, err := st.nodePathForKey(key)
- if err != nil {
- return false, err
- }
-
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return false, ErrClosed
- }
-
- // Check for file on disk
- return stat(kpath)
-}
-
-// Remove implements Storage.Remove()
-func (st *BlockStorage) Remove(key string) error {
- // Get node file path for key
- kpath, err := st.nodePathForKey(key)
- if err != nil {
- return err
- }
-
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Remove at path (we know this is file)
- if err := unlink(kpath); err != nil {
- return errSwapNotFound(err)
- }
-
- return nil
-}
-
-// Close implements Storage.Close()
-func (st *BlockStorage) Close() error {
- return st.lock.Close()
-}
-
-// WalkKeys implements Storage.WalkKeys()
-func (st *BlockStorage) WalkKeys(opts WalkKeysOptions) error {
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- // Walk dir for entries
- return util.WalkDir(pb, st.nodePath, func(npath string, fsentry fs.DirEntry) {
- // Only deal with regular files
- if fsentry.Type().IsRegular() {
- opts.WalkFn(entry(fsentry.Name()))
- }
- })
-}
-
-// nodePathForKey calculates the node file path for supplied key
-func (st *BlockStorage) nodePathForKey(key string) (string, error) {
- // Path separators are illegal, as directory paths
- if strings.Contains(key, "/") || key == "." || key == ".." {
- return "", ErrInvalidKey
- }
-
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- // Append the nodepath to key
- pb.AppendString(st.nodePath)
- pb.AppendString(key)
-
- // Return joined + cleaned node-path
- return pb.Join(st.nodePath, key), nil
-}
-
-// blockPathForKey calculates the block file path for supplied hash
-func (st *BlockStorage) blockPathForKey(hash string) string {
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
- return pb.Join(st.blockPath, hash)
-}
-
-// hashSeparator is the separating byte between block hashes
-const hashSeparator = byte('\n')
-
-// node represents the contents of a node file in storage
-type node struct {
- hashes []string
-}
-
-// removeHash attempts to remove supplied block hash from the node's hash array
-func (n *node) removeHash(hash string) bool {
- haveDropped := false
- for i := 0; i < len(n.hashes); {
- if n.hashes[i] == hash {
- // Drop this hash from slice
- n.hashes = append(n.hashes[:i], n.hashes[i+1:]...)
- haveDropped = true
- } else {
- // Continue iter
- i++
- }
- }
- return haveDropped
-}
-
-// nodeReader is an io.Reader implementation for the node file representation,
-// which is useful when calculated node file is being written to the store
-type nodeReader struct {
- node *node
- idx int
- last int
-}
-
-func (r *nodeReader) Read(b []byte) (int, error) {
- n := 0
-
- // '-1' means we missed writing
- // hash separator on last iteration
- if r.last == -1 {
- b[n] = hashSeparator
- n++
- r.last = 0
- }
-
- for r.idx < len(r.node.hashes) {
- hash := r.node.hashes[r.idx]
-
- // Copy into buffer + update read count
- m := copy(b[n:], hash[r.last:])
- n += m
-
- // If incomplete copy, return here
- if m < len(hash)-r.last {
- r.last = m
- return n, nil
- }
-
- // Check we can write last separator
- if n == len(b) {
- r.last = -1
- return n, nil
- }
-
- // Write separator, iter, reset
- b[n] = hashSeparator
- n++
- r.idx++
- r.last = 0
- }
-
- // We reached end of hashes
- return n, io.EOF
-}
-
-// nodeWriter is an io.Writer implementation for the node file representation,
-// which is useful when calculated node file is being read from the store
-type nodeWriter struct {
- node *node
- buf *byteutil.Buffer
-}
-
-func (w *nodeWriter) Write(b []byte) (int, error) {
- n := 0
-
- for {
- // Find next hash separator position
- idx := bytes.IndexByte(b[n:], hashSeparator)
- if idx == -1 {
- // Check we shouldn't be expecting it
- if w.buf.Len() > encodedHashLen {
- return n, errInvalidNode
- }
-
- // Write all contents to buffer
- w.buf.Write(b[n:])
- return len(b), nil
- }
-
- // Found hash separator, write
- // current buf contents to Node hashes
- w.buf.Write(b[n : n+idx])
- n += idx + 1
- if w.buf.Len() != encodedHashLen {
- return n, errInvalidNode
- }
-
- // Append to hashes & reset
- w.node.hashes = append(w.node.hashes, w.buf.String())
- w.buf.Reset()
- }
-}
-
-// blockReader is an io.Reader implementation for the combined, linked block
-// data contained with a node file. Basically, this allows reading value data
-// from the store for a given node file
-type blockReader struct {
- storage *BlockStorage
- node *node
- buf []byte
- prev int
-}
-
-func (r *blockReader) Read(b []byte) (int, error) {
- n := 0
-
- // Data left in buf, copy as much as we
- // can into supplied read buffer
- if r.prev < len(r.buf)-1 {
- n += copy(b, r.buf[r.prev:])
- r.prev += n
- if n >= len(b) {
- return n, nil
- }
- }
-
- for {
- // Check we have any hashes left
- if len(r.node.hashes) < 1 {
- return n, io.EOF
- }
-
- // Get next key from slice
- key := r.node.hashes[0]
- r.node.hashes = r.node.hashes[1:]
-
- // Attempt to fetch next batch of data
- var err error
- r.buf, err = r.storage.readBlock(key)
- if err != nil {
- return n, err
- }
- r.prev = 0
-
- // Copy as much as can from new buffer
- m := copy(b[n:], r.buf)
- r.prev += m
- n += m
-
- // If we hit end of supplied buf, return
- if n >= len(b) {
- return n, nil
- }
- }
-}
-
-var (
- // base64Encoding is our base64 encoding object.
- base64Encoding = hashenc.Base64()
-
- // encodedHashLen is the once-calculated encoded hash-sum length
- encodedHashLen = base64Encoding.EncodedLen(
- sha256.New().Size(),
- )
-)
-
-// hashEncoder is a HashEncoder with built-in encode buffer
-type hashEncoder struct {
- henc hashenc.HashEncoder
- ebuf []byte
-}
-
-// newHashEncoder returns a new hashEncoder instance
-func newHashEncoder() *hashEncoder {
- return &hashEncoder{
- henc: hashenc.New(sha256.New(), base64Encoding),
- ebuf: make([]byte, encodedHashLen),
- }
-}
-
-// EncodeSum encodes the src data and returns resulting bytes, only valid until next call to EncodeSum()
-func (henc *hashEncoder) EncodeSum(src []byte) string {
- henc.henc.EncodeSum(henc.ebuf, src)
- return string(henc.ebuf)
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/compressor.go b/vendor/codeberg.org/gruf/go-store/storage/compressor.go
deleted file mode 100644
index d6b975db0..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/compressor.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package storage
-
-import (
- "compress/gzip"
- "compress/zlib"
- "io"
-
- "codeberg.org/gruf/go-store/util"
- "github.com/golang/snappy"
-)
-
-// Compressor defines a means of compressing/decompressing values going into a key-value store
-type Compressor interface {
- // Reader returns a new decompressing io.ReadCloser based on supplied (compressed) io.Reader
- Reader(io.Reader) (io.ReadCloser, error)
-
- // Writer returns a new compressing io.WriteCloser based on supplied (uncompressed) io.Writer
- Writer(io.Writer) (io.WriteCloser, error)
-}
-
-type gzipCompressor struct {
- level int
-}
-
-// GZipCompressor returns a new Compressor that implements GZip at default compression level
-func GZipCompressor() Compressor {
- return GZipCompressorLevel(gzip.DefaultCompression)
-}
-
-// GZipCompressorLevel returns a new Compressor that implements GZip at supplied compression level
-func GZipCompressorLevel(level int) Compressor {
- return &gzipCompressor{
- level: level,
- }
-}
-
-func (c *gzipCompressor) Reader(r io.Reader) (io.ReadCloser, error) {
- return gzip.NewReader(r)
-}
-
-func (c *gzipCompressor) Writer(w io.Writer) (io.WriteCloser, error) {
- return gzip.NewWriterLevel(w, c.level)
-}
-
-type zlibCompressor struct {
- level int
- dict []byte
-}
-
-// ZLibCompressor returns a new Compressor that implements ZLib at default compression level
-func ZLibCompressor() Compressor {
- return ZLibCompressorLevelDict(zlib.DefaultCompression, nil)
-}
-
-// ZLibCompressorLevel returns a new Compressor that implements ZLib at supplied compression level
-func ZLibCompressorLevel(level int) Compressor {
- return ZLibCompressorLevelDict(level, nil)
-}
-
-// ZLibCompressorLevelDict returns a new Compressor that implements ZLib at supplied compression level with supplied dict
-func ZLibCompressorLevelDict(level int, dict []byte) Compressor {
- return &zlibCompressor{
- level: level,
- dict: dict,
- }
-}
-
-func (c *zlibCompressor) Reader(r io.Reader) (io.ReadCloser, error) {
- return zlib.NewReaderDict(r, c.dict)
-}
-
-func (c *zlibCompressor) Writer(w io.Writer) (io.WriteCloser, error) {
- return zlib.NewWriterLevelDict(w, c.level, c.dict)
-}
-
-type snappyCompressor struct{}
-
-// SnappyCompressor returns a new Compressor that implements Snappy
-func SnappyCompressor() Compressor {
- return &snappyCompressor{}
-}
-
-func (c *snappyCompressor) Reader(r io.Reader) (io.ReadCloser, error) {
- return util.NopReadCloser(snappy.NewReader(r)), nil
-}
-
-func (c *snappyCompressor) Writer(w io.Writer) (io.WriteCloser, error) {
- return snappy.NewBufferedWriter(w), nil
-}
-
-type nopCompressor struct{}
-
-// NoCompression is a Compressor that simply does nothing
-func NoCompression() Compressor {
- return &nopCompressor{}
-}
-
-func (c *nopCompressor) Reader(r io.Reader) (io.ReadCloser, error) {
- return util.NopReadCloser(r), nil
-}
-
-func (c *nopCompressor) Writer(w io.Writer) (io.WriteCloser, error) {
- return util.NopWriteCloser(w), nil
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/disk.go b/vendor/codeberg.org/gruf/go-store/storage/disk.go
deleted file mode 100644
index 457cc6364..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/disk.go
+++ /dev/null
@@ -1,400 +0,0 @@
-package storage
-
-import (
- "io"
- "io/fs"
- "os"
- "path"
- _path "path"
- "strings"
- "syscall"
-
- "codeberg.org/gruf/go-bytes"
- "codeberg.org/gruf/go-fastcopy"
- "codeberg.org/gruf/go-store/util"
-)
-
-// DefaultDiskConfig is the default DiskStorage configuration
-var DefaultDiskConfig = &DiskConfig{
- Overwrite: true,
- WriteBufSize: 4096,
- Transform: NopTransform(),
- Compression: NoCompression(),
-}
-
-// DiskConfig defines options to be used when opening a DiskStorage
-type DiskConfig struct {
- // Transform is the supplied key<-->path KeyTransform
- Transform KeyTransform
-
- // WriteBufSize is the buffer size to use when writing file streams (PutStream)
- WriteBufSize int
-
- // Overwrite allows overwriting values of stored keys in the storage
- Overwrite bool
-
- // LockFile allows specifying the filesystem path to use for the lockfile,
- // providing only a filename it will store the lockfile within provided store
- // path and nest the store under `path/store` to prevent access to lockfile
- LockFile string
-
- // Compression is the Compressor to use when reading / writing files, default is no compression
- Compression Compressor
-}
-
-// getDiskConfig returns a valid DiskConfig for supplied ptr
-func getDiskConfig(cfg *DiskConfig) DiskConfig {
- // If nil, use default
- if cfg == nil {
- cfg = DefaultDiskConfig
- }
-
- // Assume nil transform == none
- if cfg.Transform == nil {
- cfg.Transform = NopTransform()
- }
-
- // Assume nil compress == none
- if cfg.Compression == nil {
- cfg.Compression = NoCompression()
- }
-
- // Assume 0 buf size == use default
- if cfg.WriteBufSize < 1 {
- cfg.WriteBufSize = DefaultDiskConfig.WriteBufSize
- }
-
- // Assume empty lockfile path == use default
- if len(cfg.LockFile) < 1 {
- cfg.LockFile = LockFile
- }
-
- // Return owned config copy
- return DiskConfig{
- Transform: cfg.Transform,
- WriteBufSize: cfg.WriteBufSize,
- Overwrite: cfg.Overwrite,
- LockFile: cfg.LockFile,
- Compression: cfg.Compression,
- }
-}
-
-// DiskStorage is a Storage implementation that stores directly to a filesystem
-type DiskStorage struct {
- path string // path is the root path of this store
- cppool fastcopy.CopyPool // cppool is the prepared io copier with buffer pool
- config DiskConfig // cfg is the supplied configuration for this store
- lock *Lock // lock is the opened lockfile for this storage instance
-}
-
-// OpenFile opens a DiskStorage instance for given folder path and configuration
-func OpenFile(path string, cfg *DiskConfig) (*DiskStorage, error) {
- // Get checked config
- config := getDiskConfig(cfg)
-
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- // Clean provided store path, ensure
- // ends in '/' to help later path trimming
- storePath := pb.Clean(path) + "/"
-
- // Clean provided lockfile path
- lockfile := pb.Clean(config.LockFile)
-
- // Check if lockfile is an *actual* path or just filename
- if lockDir, _ := _path.Split(lockfile); len(lockDir) < 1 {
- // Lockfile is a filename, store must be nested under
- // $storePath/store to prevent access to the lockfile
- storePath += "store/"
- lockfile = pb.Join(path, lockfile)
- }
-
- // Attempt to open dir path
- file, err := os.OpenFile(storePath, defaultFileROFlags, defaultDirPerms)
- if err != nil {
- // If not a not-exist error, return
- if !os.IsNotExist(err) {
- return nil, err
- }
-
- // Attempt to make store path dirs
- err = os.MkdirAll(storePath, defaultDirPerms)
- if err != nil {
- return nil, err
- }
-
- // Reopen dir now it's been created
- file, err = os.OpenFile(storePath, defaultFileROFlags, defaultDirPerms)
- if err != nil {
- return nil, err
- }
- }
- defer file.Close()
-
- // Double check this is a dir (NOT a file!)
- stat, err := file.Stat()
- if err != nil {
- return nil, err
- } else if !stat.IsDir() {
- return nil, errPathIsFile
- }
-
- // Open and acquire storage lock for path
- lock, err := OpenLock(lockfile)
- if err != nil {
- return nil, err
- }
-
- // Prepare DiskStorage
- st := &DiskStorage{
- path: storePath,
- config: config,
- lock: lock,
- }
-
- // Set copypool buffer size
- st.cppool.Buffer(config.WriteBufSize)
-
- return st, nil
-}
-
-// Clean implements Storage.Clean()
-func (st *DiskStorage) Clean() error {
- st.lock.Add()
- defer st.lock.Done()
- if st.lock.Closed() {
- return ErrClosed
- }
- return util.CleanDirs(st.path)
-}
-
-// ReadBytes implements Storage.ReadBytes()
-func (st *DiskStorage) ReadBytes(key string) ([]byte, error) {
- // Get stream reader for key
- rc, err := st.ReadStream(key)
- if err != nil {
- return nil, err
- }
- defer rc.Close()
-
- // Read all bytes and return
- return io.ReadAll(rc)
-}
-
-// ReadStream implements Storage.ReadStream()
-func (st *DiskStorage) ReadStream(key string) (io.ReadCloser, error) {
- // Get file path for key
- kpath, err := st.filepath(key)
- if err != nil {
- return nil, err
- }
-
- // Track open
- st.lock.Add()
-
- // Check if open
- if st.lock.Closed() {
- return nil, ErrClosed
- }
-
- // Attempt to open file (replace ENOENT with our own)
- file, err := open(kpath, defaultFileROFlags)
- if err != nil {
- st.lock.Done()
- return nil, errSwapNotFound(err)
- }
-
- // Wrap the file in a compressor
- cFile, err := st.config.Compression.Reader(file)
- if err != nil {
- file.Close() // close this here, ignore error
- st.lock.Done()
- return nil, err
- }
-
- // Wrap compressor to ensure file close
- return util.ReadCloserWithCallback(cFile, func() {
- file.Close()
- st.lock.Done()
- }), nil
-}
-
-// WriteBytes implements Storage.WriteBytes()
-func (st *DiskStorage) WriteBytes(key string, value []byte) error {
- return st.WriteStream(key, bytes.NewReader(value))
-}
-
-// WriteStream implements Storage.WriteStream()
-func (st *DiskStorage) WriteStream(key string, r io.Reader) error {
- // Get file path for key
- kpath, err := st.filepath(key)
- if err != nil {
- return err
- }
-
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Ensure dirs leading up to file exist
- err = os.MkdirAll(path.Dir(kpath), defaultDirPerms)
- if err != nil {
- return err
- }
-
- // Prepare to swap error if need-be
- errSwap := errSwapNoop
-
- // Build file RW flags
- flags := defaultFileRWFlags
- if !st.config.Overwrite {
- flags |= syscall.O_EXCL
-
- // Catch + replace err exist
- errSwap = errSwapExist
- }
-
- // Attempt to open file
- file, err := open(kpath, flags)
- if err != nil {
- return errSwap(err)
- }
- defer file.Close()
-
- // Wrap the file in a compressor
- cFile, err := st.config.Compression.Writer(file)
- if err != nil {
- return err
- }
- defer cFile.Close()
-
- // Copy provided reader to file
- _, err = st.cppool.Copy(cFile, r)
- return err
-}
-
-// Stat implements Storage.Stat()
-func (st *DiskStorage) Stat(key string) (bool, error) {
- // Get file path for key
- kpath, err := st.filepath(key)
- if err != nil {
- return false, err
- }
-
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return false, ErrClosed
- }
-
- // Check for file on disk
- return stat(kpath)
-}
-
-// Remove implements Storage.Remove()
-func (st *DiskStorage) Remove(key string) error {
- // Get file path for key
- kpath, err := st.filepath(key)
- if err != nil {
- return err
- }
-
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Remove at path (we know this is file)
- if err := unlink(kpath); err != nil {
- return errSwapNotFound(err)
- }
-
- return nil
-}
-
-// Close implements Storage.Close()
-func (st *DiskStorage) Close() error {
- return st.lock.Close()
-}
-
-// WalkKeys implements Storage.WalkKeys()
-func (st *DiskStorage) WalkKeys(opts WalkKeysOptions) error {
- // Track open
- st.lock.Add()
- defer st.lock.Done()
-
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- // Walk dir for entries
- return util.WalkDir(pb, st.path, func(kpath string, fsentry fs.DirEntry) {
- if fsentry.Type().IsRegular() {
- // Only deal with regular files
-
- // Get full item path (without root)
- kpath = pb.Join(kpath, fsentry.Name())[len(st.path):]
-
- // Perform provided walk function
- opts.WalkFn(entry(st.config.Transform.PathToKey(kpath)))
- }
- })
-}
-
-// filepath checks and returns a formatted filepath for given key
-func (st *DiskStorage) filepath(key string) (string, error) {
- // Calculate transformed key path
- key = st.config.Transform.KeyToPath(key)
-
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- // Generated joined root path
- pb.AppendString(st.path)
- pb.AppendString(key)
-
- // Check for dir traversal outside of root
- if isDirTraversal(st.path, pb.StringPtr()) {
- return "", ErrInvalidKey
- }
-
- return pb.String(), nil
-}
-
-// isDirTraversal will check if rootPlusPath is a dir traversal outside of root,
-// assuming that both are cleaned and that rootPlusPath is path.Join(root, somePath)
-func isDirTraversal(root, rootPlusPath string) bool {
- switch {
- // Root is $PWD, check for traversal out of
- case root == ".":
- return strings.HasPrefix(rootPlusPath, "../")
-
- // The path MUST be prefixed by root
- case !strings.HasPrefix(rootPlusPath, root):
- return true
-
- // In all other cases, check not equal
- default:
- return len(root) == len(rootPlusPath)
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/errors.go b/vendor/codeberg.org/gruf/go-store/storage/errors.go
deleted file mode 100644
index 6953e11fe..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/errors.go
+++ /dev/null
@@ -1,90 +0,0 @@
-package storage
-
-import (
- "errors"
- "syscall"
-)
-
-var (
- // ErrClosed is returned on operations on a closed storage
- ErrClosed = errors.New("store/storage: closed")
-
- // ErrNotFound is the error returned when a key cannot be found in storage
- ErrNotFound = errors.New("store/storage: key not found")
-
- // ErrAlreadyExist is the error returned when a key already exists in storage
- ErrAlreadyExists = errors.New("store/storage: key already exists")
-
- // ErrInvalidkey is the error returned when an invalid key is passed to storage
- ErrInvalidKey = errors.New("store/storage: invalid key")
-
- // ErrAlreadyLocked is returned on fail opening a storage lockfile
- ErrAlreadyLocked = errors.New("store/storage: storage lock already open")
-
- // errPathIsFile is returned when a path for a disk config is actually a file
- errPathIsFile = errors.New("store/storage: path is file")
-
- // errNoHashesWritten is returned when no blocks are written for given input value
- errNoHashesWritten = errors.New("storage/storage: no hashes written")
-
- // errInvalidNode is returned when read on an invalid node in the store is attempted
- errInvalidNode = errors.New("store/storage: invalid node")
-
- // errCorruptNode is returned when a block fails to be opened / read during read of a node.
- errCorruptNode = errors.New("store/storage: corrupted node")
-)
-
-// wrappedError allows wrapping together an inner with outer error.
-type wrappedError struct {
- inner error
- outer error
-}
-
-// wrap will return a new wrapped error from given inner and outer errors.
-func wrap(outer, inner error) *wrappedError {
- return &wrappedError{
- inner: inner,
- outer: outer,
- }
-}
-
-func (e *wrappedError) Is(target error) bool {
- return e.outer == target || e.inner == target
-}
-
-func (e *wrappedError) Error() string {
- return e.outer.Error() + ": " + e.inner.Error()
-}
-
-func (e *wrappedError) Unwrap() error {
- return e.inner
-}
-
-// errSwapNoop performs no error swaps
-func errSwapNoop(err error) error {
- return err
-}
-
-// ErrSwapNotFound swaps syscall.ENOENT for ErrNotFound
-func errSwapNotFound(err error) error {
- if err == syscall.ENOENT {
- return ErrNotFound
- }
- return err
-}
-
-// errSwapExist swaps syscall.EEXIST for ErrAlreadyExists
-func errSwapExist(err error) error {
- if err == syscall.EEXIST {
- return ErrAlreadyExists
- }
- return err
-}
-
-// errSwapUnavailable swaps syscall.EAGAIN for ErrAlreadyLocked
-func errSwapUnavailable(err error) error {
- if err == syscall.EAGAIN {
- return ErrAlreadyLocked
- }
- return err
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/fs.go b/vendor/codeberg.org/gruf/go-store/storage/fs.go
deleted file mode 100644
index b4729b041..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/fs.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package storage
-
-import (
- "os"
- "syscall"
-
- "codeberg.org/gruf/go-store/util"
-)
-
-const (
- // default file permission bits
- defaultDirPerms = 0o755
- defaultFilePerms = 0o644
-
- // default file open flags
- defaultFileROFlags = syscall.O_RDONLY
- defaultFileRWFlags = syscall.O_CREAT | syscall.O_RDWR
- defaultFileLockFlags = syscall.O_RDONLY | syscall.O_CREAT
-)
-
-// NOTE:
-// These functions are for opening storage files,
-// not necessarily for e.g. initial setup (OpenFile)
-
-// open should not be called directly.
-func open(path string, flags int) (*os.File, error) {
- var fd int
- err := util.RetryOnEINTR(func() (err error) {
- fd, err = syscall.Open(path, flags, defaultFilePerms)
- return
- })
- if err != nil {
- return nil, err
- }
- return os.NewFile(uintptr(fd), path), nil
-}
-
-// stat checks for a file on disk.
-func stat(path string) (bool, error) {
- var stat syscall.Stat_t
- err := util.RetryOnEINTR(func() error {
- return syscall.Stat(path, &stat)
- })
- if err != nil {
- if err == syscall.ENOENT { //nolint
- err = nil
- }
- return false, err
- }
- return true, nil
-}
-
-// unlink removes a file (not dir!) on disk.
-func unlink(path string) error {
- return util.RetryOnEINTR(func() error {
- return syscall.Unlink(path)
- })
-}
-
-// rmdir removes a dir (not file!) on disk.
-func rmdir(path string) error {
- return util.RetryOnEINTR(func() error {
- return syscall.Rmdir(path)
- })
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/lock.go b/vendor/codeberg.org/gruf/go-store/storage/lock.go
deleted file mode 100644
index 8a6c4c5e8..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/lock.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package storage
-
-import (
- "sync"
- "sync/atomic"
- "syscall"
-
- "codeberg.org/gruf/go-store/util"
-)
-
-// LockFile is our standard lockfile name.
-const LockFile = "store.lock"
-
-// Lock represents a filesystem lock to ensure only one storage instance open per path.
-type Lock struct {
- fd int
- wg sync.WaitGroup
- st uint32
-}
-
-// OpenLock opens a lockfile at path.
-func OpenLock(path string) (*Lock, error) {
- var fd int
-
- // Open the file descriptor at path
- err := util.RetryOnEINTR(func() (err error) {
- fd, err = syscall.Open(path, defaultFileLockFlags, defaultFilePerms)
- return
- })
- if err != nil {
- return nil, err
- }
-
- // Get a flock on the file descriptor
- err = util.RetryOnEINTR(func() error {
- return syscall.Flock(fd, syscall.LOCK_EX|syscall.LOCK_NB)
- })
- if err != nil {
- return nil, errSwapUnavailable(err)
- }
-
- return &Lock{fd: fd}, nil
-}
-
-// Add will add '1' to the underlying sync.WaitGroup.
-func (f *Lock) Add() {
- f.wg.Add(1)
-}
-
-// Done will decrememnt '1' from the underlying sync.WaitGroup.
-func (f *Lock) Done() {
- f.wg.Done()
-}
-
-// Close will attempt to close the lockfile and file descriptor.
-func (f *Lock) Close() error {
- var err error
- if atomic.CompareAndSwapUint32(&f.st, 0, 1) {
- // Wait until done
- f.wg.Wait()
-
- // Ensure gets closed
- defer syscall.Close(f.fd)
-
- // Call funlock on the file descriptor
- err = util.RetryOnEINTR(func() error {
- return syscall.Flock(f.fd, syscall.LOCK_UN|syscall.LOCK_NB)
- })
- }
- return err
-}
-
-// Closed will return whether this lockfile has been closed (and unlocked).
-func (f *Lock) Closed() bool {
- return (atomic.LoadUint32(&f.st) == 1)
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/memory.go b/vendor/codeberg.org/gruf/go-store/storage/memory.go
deleted file mode 100644
index 2dab562d6..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/memory.go
+++ /dev/null
@@ -1,188 +0,0 @@
-package storage
-
-import (
- "io"
- "sync"
-
- "codeberg.org/gruf/go-bytes"
- "codeberg.org/gruf/go-store/util"
-)
-
-// MemoryStorage is a storage implementation that simply stores key-value
-// pairs in a Go map in-memory. The map is protected by a mutex.
-type MemoryStorage struct {
- ow bool // overwrites
- fs map[string][]byte
- mu sync.Mutex
- st uint32
-}
-
-// OpenMemory opens a new MemoryStorage instance with internal map of 'size'.
-func OpenMemory(size int, overwrites bool) *MemoryStorage {
- return &MemoryStorage{
- fs: make(map[string][]byte, size),
- mu: sync.Mutex{},
- ow: overwrites,
- }
-}
-
-// Clean implements Storage.Clean().
-func (st *MemoryStorage) Clean() error {
- st.mu.Lock()
- defer st.mu.Unlock()
- if st.st == 1 {
- return ErrClosed
- }
- return nil
-}
-
-// ReadBytes implements Storage.ReadBytes().
-func (st *MemoryStorage) ReadBytes(key string) ([]byte, error) {
- // Lock storage
- st.mu.Lock()
-
- // Check store open
- if st.st == 1 {
- st.mu.Unlock()
- return nil, ErrClosed
- }
-
- // Check for key
- b, ok := st.fs[key]
- st.mu.Unlock()
-
- // Return early if not exist
- if !ok {
- return nil, ErrNotFound
- }
-
- // Create return copy
- return bytes.Copy(b), nil
-}
-
-// ReadStream implements Storage.ReadStream().
-func (st *MemoryStorage) ReadStream(key string) (io.ReadCloser, error) {
- // Lock storage
- st.mu.Lock()
-
- // Check store open
- if st.st == 1 {
- st.mu.Unlock()
- return nil, ErrClosed
- }
-
- // Check for key
- b, ok := st.fs[key]
- st.mu.Unlock()
-
- // Return early if not exist
- if !ok {
- return nil, ErrNotFound
- }
-
- // Create io.ReadCloser from 'b' copy
- b = bytes.Copy(b)
- r := bytes.NewReader(b)
- return util.NopReadCloser(r), nil
-}
-
-// WriteBytes implements Storage.WriteBytes().
-func (st *MemoryStorage) WriteBytes(key string, b []byte) error {
- // Lock storage
- st.mu.Lock()
- defer st.mu.Unlock()
-
- // Check store open
- if st.st == 1 {
- return ErrClosed
- }
-
- _, ok := st.fs[key]
-
- // Check for already exist
- if ok && !st.ow {
- return ErrAlreadyExists
- }
-
- // Write + unlock
- st.fs[key] = bytes.Copy(b)
- return nil
-}
-
-// WriteStream implements Storage.WriteStream().
-func (st *MemoryStorage) WriteStream(key string, r io.Reader) error {
- // Read all from reader
- b, err := io.ReadAll(r)
- if err != nil {
- return err
- }
-
- // Write to storage
- return st.WriteBytes(key, b)
-}
-
-// Stat implements Storage.Stat().
-func (st *MemoryStorage) Stat(key string) (bool, error) {
- // Lock storage
- st.mu.Lock()
- defer st.mu.Unlock()
-
- // Check store open
- if st.st == 1 {
- return false, ErrClosed
- }
-
- // Check for key
- _, ok := st.fs[key]
- return ok, nil
-}
-
-// Remove implements Storage.Remove().
-func (st *MemoryStorage) Remove(key string) error {
- // Lock storage
- st.mu.Lock()
- defer st.mu.Unlock()
-
- // Check store open
- if st.st == 1 {
- return ErrClosed
- }
-
- // Check for key
- _, ok := st.fs[key]
- if !ok {
- return ErrNotFound
- }
-
- // Remove from store
- delete(st.fs, key)
-
- return nil
-}
-
-// Close implements Storage.Close().
-func (st *MemoryStorage) Close() error {
- st.mu.Lock()
- st.st = 1
- st.mu.Unlock()
- return nil
-}
-
-// WalkKeys implements Storage.WalkKeys().
-func (st *MemoryStorage) WalkKeys(opts WalkKeysOptions) error {
- // Lock storage
- st.mu.Lock()
- defer st.mu.Unlock()
-
- // Check store open
- if st.st == 1 {
- return ErrClosed
- }
-
- // Walk store keys
- for key := range st.fs {
- opts.WalkFn(entry(key))
- }
-
- return nil
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/storage.go b/vendor/codeberg.org/gruf/go-store/storage/storage.go
deleted file mode 100644
index 346aff097..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/storage.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package storage
-
-import (
- "io"
-)
-
-// StorageEntry defines a key in Storage
-type StorageEntry interface {
- // Key returns the storage entry's key
- Key() string
-}
-
-// entry is the simplest possible StorageEntry
-type entry string
-
-func (e entry) Key() string {
- return string(e)
-}
-
-// Storage defines a means of storing and accessing key value pairs
-type Storage interface {
- // ReadBytes returns the byte value for key in storage
- ReadBytes(key string) ([]byte, error)
-
- // ReadStream returns an io.ReadCloser for the value bytes at key in the storage
- ReadStream(key string) (io.ReadCloser, error)
-
- // WriteBytes writes the supplied value bytes at key in the storage
- WriteBytes(key string, value []byte) error
-
- // WriteStream writes the bytes from supplied reader at key in the storage
- WriteStream(key string, r io.Reader) error
-
- // Stat checks if the supplied key is in the storage
- Stat(key string) (bool, error)
-
- // Remove attempts to remove the supplied key-value pair from storage
- Remove(key string) error
-
- // Close will close the storage, releasing any file locks
- Close() error
-
- // Clean removes unused values and unclutters the storage (e.g. removing empty folders)
- Clean() error
-
- // WalkKeys walks the keys in the storage
- WalkKeys(opts WalkKeysOptions) error
-}
-
-// WalkKeysOptions defines how to walk the keys in a storage implementation
-type WalkKeysOptions struct {
- // WalkFn is the function to apply on each StorageEntry
- WalkFn func(StorageEntry)
-}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/transform.go b/vendor/codeberg.org/gruf/go-store/storage/transform.go
deleted file mode 100644
index 3863dd774..000000000
--- a/vendor/codeberg.org/gruf/go-store/storage/transform.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package storage
-
-// KeyTransform defines a method of converting store keys to storage paths (and vice-versa)
-type KeyTransform interface {
- // KeyToPath converts a supplied key to storage path
- KeyToPath(string) string
-
- // PathToKey converts a supplied storage path to key
- PathToKey(string) string
-}
-
-type nopKeyTransform struct{}
-
-// NopTransform returns a nop key transform (i.e. key = path)
-func NopTransform() KeyTransform {
- return &nopKeyTransform{}
-}
-
-func (t *nopKeyTransform) KeyToPath(key string) string {
- return key
-}
-
-func (t *nopKeyTransform) PathToKey(path string) string {
- return path
-}
diff --git a/vendor/codeberg.org/gruf/go-store/util/fs.go b/vendor/codeberg.org/gruf/go-store/util/fs.go
deleted file mode 100644
index 53fef7750..000000000
--- a/vendor/codeberg.org/gruf/go-store/util/fs.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package util
-
-import (
- "io/fs"
- "os"
-
- "codeberg.org/gruf/go-fastpath"
-)
-
-// WalkDir traverses the dir tree of the supplied path, performing the supplied walkFn on each entry
-func WalkDir(pb *fastpath.Builder, path string, walkFn func(string, fs.DirEntry)) error {
- // Read supplied dir path
- dirEntries, err := os.ReadDir(path)
- if err != nil {
- return err
- }
-
- // Iter entries
- for _, entry := range dirEntries {
- // Pass to walk fn
- walkFn(path, entry)
-
- // Recurse dir entries
- if entry.IsDir() {
- err = WalkDir(pb, pb.Join(path, entry.Name()), walkFn)
- if err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-// CleanDirs traverses the dir tree of the supplied path, removing any folders with zero children
-func CleanDirs(path string) error {
- // Acquire builder
- pb := GetPathBuilder()
- defer PutPathBuilder(pb)
-
- // Get dir entries
- entries, err := os.ReadDir(path)
- if err != nil {
- return err
- }
-
- // Recurse dirs
- for _, entry := range entries {
- if entry.IsDir() {
- err := cleanDirs(pb, pb.Join(path, entry.Name()))
- if err != nil {
- return err
- }
- }
- }
- return nil
-}
-
-// cleanDirs performs the actual dir cleaning logic for the exported version
-func cleanDirs(pb *fastpath.Builder, path string) error {
- // Get dir entries
- entries, err := os.ReadDir(path)
- if err != nil {
- return err
- }
-
- // If no entries, delete
- if len(entries) < 1 {
- return os.Remove(path)
- }
-
- // Recurse dirs
- for _, entry := range entries {
- if entry.IsDir() {
- err := cleanDirs(pb, pb.Join(path, entry.Name()))
- if err != nil {
- return err
- }
- }
- }
- return nil
-}
diff --git a/vendor/codeberg.org/gruf/go-store/util/io.go b/vendor/codeberg.org/gruf/go-store/util/io.go
deleted file mode 100644
index d034cf62b..000000000
--- a/vendor/codeberg.org/gruf/go-store/util/io.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package util
-
-import "io"
-
-// NopReadCloser turns a supplied io.Reader into io.ReadCloser with a nop Close() implementation
-func NopReadCloser(r io.Reader) io.ReadCloser {
- return &nopReadCloser{r}
-}
-
-// NopWriteCloser turns a supplied io.Writer into io.WriteCloser with a nop Close() implementation
-func NopWriteCloser(w io.Writer) io.WriteCloser {
- return &nopWriteCloser{w}
-}
-
-// ReadCloserWithCallback adds a customizable callback to be called upon Close() of a supplied io.ReadCloser
-func ReadCloserWithCallback(rc io.ReadCloser, cb func()) io.ReadCloser {
- return &callbackReadCloser{
- ReadCloser: rc,
- callback: cb,
- }
-}
-
-// nopReadCloser turns an io.Reader -> io.ReadCloser with a nop Close()
-type nopReadCloser struct{ io.Reader }
-
-func (r *nopReadCloser) Close() error { return nil }
-
-// nopWriteCloser turns an io.Writer -> io.WriteCloser with a nop Close()
-type nopWriteCloser struct{ io.Writer }
-
-func (w nopWriteCloser) Close() error { return nil }
-
-// callbackReadCloser allows adding our own custom callback to an io.ReadCloser
-type callbackReadCloser struct {
- io.ReadCloser
- callback func()
-}
-
-func (c *callbackReadCloser) Close() error {
- defer c.callback()
- return c.ReadCloser.Close()
-}
diff --git a/vendor/codeberg.org/gruf/go-store/util/pool.go b/vendor/codeberg.org/gruf/go-store/util/pool.go
deleted file mode 100644
index 8400cb5b7..000000000
--- a/vendor/codeberg.org/gruf/go-store/util/pool.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package util
-
-import (
- "codeberg.org/gruf/go-fastpath"
- "codeberg.org/gruf/go-pools"
-)
-
-// pathBuilderPool is the global fastpath.Builder pool
-var pathBuilderPool = pools.NewPathBuilderPool(512)
-
-// GetPathBuilder fetches a fastpath.Builder object from the pool
-func GetPathBuilder() *fastpath.Builder {
- return pathBuilderPool.Get()
-}
-
-// PutPathBuilder places supplied fastpath.Builder back in the pool
-func PutPathBuilder(pb *fastpath.Builder) {
- pb.Reset()
- pathBuilderPool.Put(pb)
-}
diff --git a/vendor/codeberg.org/gruf/go-store/util/sys.go b/vendor/codeberg.org/gruf/go-store/util/sys.go
deleted file mode 100644
index 6661029e5..000000000
--- a/vendor/codeberg.org/gruf/go-store/util/sys.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package util
-
-import "syscall"
-
-// RetryOnEINTR is a low-level filesystem function for retrying syscalls on O_EINTR received
-func RetryOnEINTR(do func() error) error {
- for {
- err := do()
- if err == syscall.EINTR {
- continue
- }
- return err
- }
-}