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-bytesize/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/README.md1
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/bytesize.go381
-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.go174
-rw-r--r--vendor/codeberg.org/gruf/go-byteutil/bytes.go27
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v3/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v3/README.md11
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v3/cache.go75
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v3/simple/cache.go454
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v3/simple/pool.go23
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go20
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v3/ttl/ttl.go636
-rw-r--r--vendor/codeberg.org/gruf/go-caller/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-caller/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-caller/caller.go136
-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.go53
-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.md8
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/build_caller.go26
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/build_nocaller.go18
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/build_notrace.go20
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/build_trace.go27
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/errors.go248
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/once.go31
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/runtime.go97
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/standard.go82
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/value.go50
-rw-r--r--vendor/codeberg.org/gruf/go-fastcopy/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-fastcopy/copy.go135
-rw-r--r--vendor/codeberg.org/gruf/go-fastpath/v2/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-fastpath/v2/README.md1
-rw-r--r--vendor/codeberg.org/gruf/go-fastpath/v2/path.go328
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/LICENSE674
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpreg.wasm.gzbin8217614 -> 0 bytes
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/embed/lib.go46
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/wasm/funcs.go139
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/wasm/run.go88
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/wasm/runtime.go70
-rw-r--r--vendor/codeberg.org/gruf/go-iotools/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-iotools/close.go52
-rw-r--r--vendor/codeberg.org/gruf/go-iotools/helpers.go85
-rw-r--r--vendor/codeberg.org/gruf/go-iotools/read.go41
-rw-r--r--vendor/codeberg.org/gruf/go-iotools/size.go25
-rw-r--r--vendor/codeberg.org/gruf/go-iotools/write.go37
-rw-r--r--vendor/codeberg.org/gruf/go-kv/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-kv/README.md36
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field.go105
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field_fmt.go63
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field_format.go35
-rw-r--r--vendor/codeberg.org/gruf/go-kv/format/README.md4
-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.go896
-rw-r--r--vendor/codeberg.org/gruf/go-kv/format/formatter.go349
-rw-r--r--vendor/codeberg.org/gruf/go-kv/format/util.go100
-rw-r--r--vendor/codeberg.org/gruf/go-kv/util.go151
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/README.md5
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/field.go103
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/field_fmt.go63
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/field_format.go44
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/README.md32
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/abi.go25
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/args.go247
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/array.go235
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/cache.go60
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/format.go687
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/formatting.go161
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/map.go134
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/methods.go242
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go130
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/slice.go160
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/struct.go175
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/type.go109
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/util.go147
-rw-r--r--vendor/codeberg.org/gruf/go-list/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-list/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-list/list.go204
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/README.md31
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/array.go55
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/cache.go62
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/helpers.go43
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/load.go150
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/mangle.go93
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/manglers.go113
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/map.go80
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/method.go105
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/pointer.go81
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/slice.go95
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/struct.go75
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/v2/type.go20
-rw-r--r--vendor/codeberg.org/gruf/go-maps/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-maps/README.md7
-rw-r--r--vendor/codeberg.org/gruf/go-maps/common.go293
-rw-r--r--vendor/codeberg.org/gruf/go-maps/list.go154
-rw-r--r--vendor/codeberg.org/gruf/go-maps/lru.go153
-rw-r--r--vendor/codeberg.org/gruf/go-maps/ordered.go159
-rw-r--r--vendor/codeberg.org/gruf/go-mempool/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-mempool/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-mempool/pool.go139
-rw-r--r--vendor/codeberg.org/gruf/go-mempool/simple.go111
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/copy_fill_stat.sh14
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/fs.go79
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/mmap.go142
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/open.go62
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/stat_darwin.go49
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go49
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/stat_linux.go49
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/stat_netbsd.go49
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/stat_openbsd.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/cond.go67
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/debug.go39
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/hash_map.go56
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/map.go210
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/map_unsafe.go41
-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.go85
-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.go69
-rw-r--r--vendor/codeberg.org/gruf/go-runners/pointer.go22
-rw-r--r--vendor/codeberg.org/gruf/go-runners/process.go73
-rw-r--r--vendor/codeberg.org/gruf/go-runners/service.go222
-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.go119
-rw-r--r--vendor/codeberg.org/gruf/go-sched/scheduler.go343
-rw-r--r--vendor/codeberg.org/gruf/go-sched/timing.go99
-rw-r--r--vendor/codeberg.org/gruf/go-split/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-split/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-split/join.go112
-rw-r--r--vendor/codeberg.org/gruf/go-split/join_util.go71
-rw-r--r--vendor/codeberg.org/gruf/go-split/split.go187
-rw-r--r--vendor/codeberg.org/gruf/go-split/splitter.go204
-rw-r--r--vendor/codeberg.org/gruf/go-storage/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-storage/README.md5
-rw-r--r--vendor/codeberg.org/gruf/go-storage/block.archived887
-rw-r--r--vendor/codeberg.org/gruf/go-storage/block_test.archived38
-rw-r--r--vendor/codeberg.org/gruf/go-storage/disk/disk.go467
-rw-r--r--vendor/codeberg.org/gruf/go-storage/disk/fs.go206
-rw-r--r--vendor/codeberg.org/gruf/go-storage/errors.go16
-rw-r--r--vendor/codeberg.org/gruf/go-storage/internal/errors.go56
-rw-r--r--vendor/codeberg.org/gruf/go-storage/internal/path.go24
-rw-r--r--vendor/codeberg.org/gruf/go-storage/memory/memory.go252
-rw-r--r--vendor/codeberg.org/gruf/go-storage/s3/cache.go94
-rw-r--r--vendor/codeberg.org/gruf/go-storage/s3/cache/cache.go44
-rw-r--r--vendor/codeberg.org/gruf/go-storage/s3/errors.go52
-rw-r--r--vendor/codeberg.org/gruf/go-storage/s3/s3.go597
-rw-r--r--vendor/codeberg.org/gruf/go-storage/storage.go73
-rw-r--r--vendor/codeberg.org/gruf/go-storage/test.sh28
-rw-r--r--vendor/codeberg.org/gruf/go-structr/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-structr/README.md11
-rw-r--r--vendor/codeberg.org/gruf/go-structr/cache.go724
-rw-r--r--vendor/codeberg.org/gruf/go-structr/index.go419
-rw-r--r--vendor/codeberg.org/gruf/go-structr/item.go65
-rw-r--r--vendor/codeberg.org/gruf/go-structr/key.go85
-rw-r--r--vendor/codeberg.org/gruf/go-structr/list.go185
-rw-r--r--vendor/codeberg.org/gruf/go-structr/map.go62
-rw-r--r--vendor/codeberg.org/gruf/go-structr/queue.go346
-rw-r--r--vendor/codeberg.org/gruf/go-structr/queue_ctx.go152
-rw-r--r--vendor/codeberg.org/gruf/go-structr/runtime.go294
-rw-r--r--vendor/codeberg.org/gruf/go-structr/timeline.go1197
-rw-r--r--vendor/codeberg.org/gruf/go-xunsafe/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-xunsafe/README.md3
-rw-r--r--vendor/codeberg.org/gruf/go-xunsafe/abi.go109
-rw-r--r--vendor/codeberg.org/gruf/go-xunsafe/reflect.go157
-rw-r--r--vendor/codeberg.org/gruf/go-xunsafe/types.go49
182 files changed, 0 insertions, 20837 deletions
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 00ef52550..000000000
--- a/vendor/codeberg.org/gruf/go-bytesize/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Byte size formatting and parsing.
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 25283d8b6..000000000
--- a/vendor/codeberg.org/gruf/go-bytesize/bytesize.go
+++ /dev/null
@@ -1,381 +0,0 @@
-package bytesize
-
-import (
- "errors"
- "math/bits"
- "strconv"
- "unsafe"
-)
-
-const (
- // SI units
- KB Size = 1e3
- MB Size = 1e6
- GB Size = 1e9
- TB Size = 1e12
- PB Size = 1e15
- EB Size = 1e18
-
- // IEC units
- KiB Size = 1024
- MiB Size = KiB * 1024
- GiB Size = MiB * 1024
- TiB Size = GiB * 1024
- PiB Size = TiB * 1024
- EiB Size = PiB * 1024
-)
-
-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")
-
- // iecpows is a precomputed table of 1024^n.
- iecpows = [...]float64{
- float64(KiB),
- float64(MiB),
- float64(GiB),
- float64(TiB),
- float64(PiB),
- float64(EiB),
- }
-
- // sipows is a precomputed table of 1000^n.
- sipows = [...]float64{
- float64(KB),
- float64(MB),
- float64(GB),
- float64(TB),
- float64(PB),
- float64(EB),
- }
-
- // bvals is a precomputed table of IEC unit values.
- iecvals = [...]float64{
- 'k': float64(KiB),
- 'K': float64(KiB),
- 'M': float64(MiB),
- 'G': float64(GiB),
- 'T': float64(TiB),
- 'P': float64(PiB),
- 'E': float64(EiB),
- }
-
- // sivals is a precomputed table of SI unit values.
- sivals = [...]float64{
- // 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': float64(KB),
- 'K': float64(KB),
- 'M': float64(MB),
- 'G': float64(GB),
- 'T': float64(TB),
- 'P': float64(PB),
- 'E': float64(EB),
- }
-)
-
-// 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 64bit float
- f, err := strconv.ParseFloat(s[:l], 64)
- if err != nil {
- return 0, errctx(ErrInvalidFormat, err.Error())
- }
-
- return Size(f * unit), nil
-}
-
-// Set implements flag.Value{}.
-func (sz *Size) Set(in string) error {
- s, err := ParseSize(in)
- if err != nil {
- return err
- }
- *sz = s
- return nil
-}
-
-// AppendText implements encoding.TextAppender{}.
-func (sz Size) AppendText(b []byte) ([]byte, error) {
- return sz.AppendFormatIEC(b), nil
-}
-
-// MarshalText implements encoding.TextMarshaler{}.
-func (sz Size) MarshalText() ([]byte, error) {
- const maxLen = 7 // max IEC string length
- return sz.AppendText(make([]byte, 0, maxLen))
-}
-
-// UnmarshalText implements encoding.TextUnmarshaler{}.
-func (sz *Size) UnmarshalText(text []byte) error {
- return sz.Set(*(*string)(unsafe.Pointer(&text)))
-}
-
-// 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
- }
- f, u := sztof(sz, 1000, sipows)
- dst = ftoa(dst, f)
- dst = append(dst, u)
- dst = append(dst, 'B')
- return dst
-}
-
-// 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
- }
- f, u := sztof(sz, 1024, iecpows)
- dst = ftoa(dst, f)
- dst = append(dst, u)
- dst = append(dst, 'i', 'B')
- return dst
-}
-
-// StringSI returns an SI unit string format of Size.
-func (sz Size) StringSI() string {
- const maxLen = 6 // max SI string length
- b := sz.AppendFormatSI(make([]byte, 0, maxLen))
- return *(*string)(unsafe.Pointer(&b))
-}
-
-// StringIEC returns an IEC unit string format of Size.
-func (sz Size) StringIEC() string {
- const maxLen = 7 // max IEC string length
- b := sz.AppendFormatIEC(make([]byte, 0, maxLen))
- 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) (float64, int, error) {
- // 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]
-
- if len(s) < 1 {
- // No remaining str before unit suffix
- return 0, 0, ErrInvalidFormat
- }
- }
-
- // Strip IEC binary unit suffix
- if l := len(s) - 1; s[l] == 'i' {
- s = s[:l]
-
- if len(s) < 1 {
- // No remaining str before unit suffix
- return 0, 0, ErrInvalidFormat
- }
-
- // Location of unit char.
- l := len(s) - 1
- c := int(s[l])
-
- // Check valid unit char was provided
- if len(iecvals) < c || iecvals[c] == 0 {
- return 0, 0, errctx(ErrInvalidUnit, s[l:])
- }
-
- // Return parsed IEC unit size
- return iecvals[c], l, nil
- }
-
- // Location of unit char.
- l := len(s) - 1
- c := int(s[l])
-
- switch {
- // Check valid unit char provided
- case len(sivals) < c || sivals[c] == 0:
- return 0, 0, errctx(ErrInvalidUnit, s[l:])
-
- // No unit char (only ascii number)
- case sivals[c] == 1:
- l++
- }
-
- // Return parsed SI unit size
- return sivals[c], l, nil
-}
-
-// sztof divides a Size with base and power units to a float value with power.
-func sztof(sz Size, base float64, pows [6]float64) (float64, byte) {
- const (
- // min "small"
- // unit threshold.
- min = 0.75
-
- // binary unit chars.
- units = `kMGTPE`
- )
-
- // 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 *= base
- n--
- }
-
- return f, units[n-1]
-}
-
-// 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 uint 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:]...)
-}
-
-// errwithctx wraps an error
-// with extra context info.
-type errwithctx struct {
- err error
- ctx string
-}
-
-func errctx(err error, ctx string) error {
- return &errwithctx{err: err, ctx: ctx}
-}
-
-func (err *errwithctx) Unwrap() error {
- return err.err
-}
-
-func (err *errwithctx) Error() string {
- return err.err.Error() + ": " + err.ctx
-}
diff --git a/vendor/codeberg.org/gruf/go-byteutil/LICENSE b/vendor/codeberg.org/gruf/go-byteutil/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-byteutil/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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 8259429d6..000000000
--- a/vendor/codeberg.org/gruf/go-byteutil/buffer.go
+++ /dev/null
@@ -1,174 +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)
- io.ReaderFrom
- io.WriterTo
- } = (*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
-}
-
-// ReadFrom will read bytes from reader into buffer, fulfilling io.ReaderFrom.
-func (buf *Buffer) ReadFrom(r io.Reader) (int64, error) {
- var nn int64
-
- // Ensure there's cap
- // for a first read.
- buf.Guarantee(512)
-
- for {
- // Read into next chunk of buffer.
- n, err := r.Read(buf.B[len(buf.B):cap(buf.B)])
-
- // Reslice buf + update count.
- buf.B = buf.B[:len(buf.B)+n]
- nn += int64(n)
-
- if err != nil {
- if err == io.EOF {
- // mask EOF.
- err = nil
- }
- return nn, err
- }
-
- if len(buf.B) == cap(buf.B) {
- // Add capacity (let append pick).
- buf.B = append(buf.B, 0)[:len(buf.B)]
- }
- }
-}
-
-// WriteTo will write bytes from buffer into writer, fulfilling io.WriterTo.
-func (buf *Buffer) WriteTo(w io.Writer) (int64, error) {
- n, err := w.Write(buf.B)
- return int64(n), err
-}
-
-// 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 880cb4b6d..000000000
--- a/vendor/codeberg.org/gruf/go-byteutil/bytes.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package byteutil
-
-import (
- "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.
-// Since Go strings are immutable, the bytes passed to String must
-// not be modified as long as the returned string value exists.
-func B2S(b []byte) string {
- return unsafe.String(unsafe.SliceData(b), len(b))
-}
-
-// S2B returns a []byte representation of string without allocation.
-func S2B(s string) []byte {
- return unsafe.Slice(unsafe.StringData(s), len(s))
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v3/LICENSE b/vendor/codeberg.org/gruf/go-cache/v3/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v3/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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/v3/README.md b/vendor/codeberg.org/gruf/go-cache/v3/README.md
deleted file mode 100644
index ffc516a70..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v3/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# go-cache
-
-Provides access to simple, yet flexible, and performant caches (with TTL if required) via the `cache.Cache{}` and `cache.TTLCache{}` interfaces.
-
-## simple
-
-A `cache.Cache{}` implementation with much more of the inner workings exposed. Designed to be used as a base for your own customizations, or used as-is.
-
-## ttl
-
-A `cache.TTLCache{}` implementation with much more of the inner workings exposed. Designed to be used as a base for your own customizations, or used as-is.
diff --git a/vendor/codeberg.org/gruf/go-cache/v3/cache.go b/vendor/codeberg.org/gruf/go-cache/v3/cache.go
deleted file mode 100644
index d96971702..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v3/cache.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package cache
-
-import (
- "time"
-
- "codeberg.org/gruf/go-cache/v3/simple"
- "codeberg.org/gruf/go-cache/v3/ttl"
-)
-
-// TTLCache 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 ttl.Cache{}.
-type TTLCache[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
-
- // 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)
-
- // implements base cache.
- Cache[Key, Value]
-}
-
-// Cache represents a 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 simple.Cache{}.
-type Cache[Key comparable, Value any] interface {
- // SetEvictionCallback sets the eviction callback to the provided hook.
- SetEvictionCallback(hook func(Key, Value))
-
- // SetInvalidateCallback sets the invalidate callback to the provided hook.
- SetInvalidateCallback(hook func(Key, Value))
-
- // Get fetches the value with key from the cache, extending its TTL.
- Get(key Key) (value Value, ok bool)
-
- // Add 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. Calls invalidate callback on success.
- Add(key Key, value Value) bool
-
- // Set places the value at key in the cache. This will overwrite any existing value. Existing values will have their TTL extended upon update. Always calls invalidate callback.
- Set(key Key, value Value)
-
- // CAS will attempt to perform a CAS operation on 'key', using provided old and new values, and comparator function. Returned bool is success.
- CAS(key Key, old, new Value, cmp func(Value, Value) bool) 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
-
- // InvalidateAll is equivalent to multiple Invalidate calls.
- InvalidateAll(keys ...Key) bool
-
- // Clear empties the cache, calling the invalidate callback on each entry.
- Clear()
-
- // Len returns the current length of the cache.
- Len() int
-
- // Cap returns the maximum capacity of the cache.
- Cap() int
-}
-
-// New returns a new initialized Cache with given initial length, maximum capacity.
-func New[K comparable, V any](len, cap int) Cache[K, V] {
- return simple.New[K, V](len, cap)
-}
-
-// NewTTL returns a new initialized TTLCache with given initial length, maximum capacity and TTL duration.
-func NewTTL[K comparable, V any](len, cap int, _ttl time.Duration) TTLCache[K, V] {
- return ttl.New[K, V](len, cap, _ttl)
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v3/simple/cache.go b/vendor/codeberg.org/gruf/go-cache/v3/simple/cache.go
deleted file mode 100644
index 1452a0648..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v3/simple/cache.go
+++ /dev/null
@@ -1,454 +0,0 @@
-package simple
-
-import (
- "sync"
-
- "codeberg.org/gruf/go-maps"
-)
-
-// Entry represents an item in the cache.
-type Entry struct {
- Key any
- Value any
-}
-
-// Cache is the underlying Cache implementation, providing both the base Cache interface and unsafe access to underlying map to allow flexibility in building your own.
-type Cache[Key comparable, Value any] struct {
- // Evict is the hook that is called when an item is evicted from the cache.
- Evict func(Key, Value)
-
- // Invalid is the hook that is called when an item's data in the cache is invalidated, includes Add/Set.
- Invalid func(Key, Value)
-
- // Cache is the underlying hashmap used for this cache.
- Cache maps.LRUMap[Key, *Entry]
-
- // Embedded mutex.
- sync.Mutex
-}
-
-// New returns a new initialized Cache with given initial length, maximum capacity and item TTL.
-func New[K comparable, V any](len, cap int) *Cache[K, V] {
- c := new(Cache[K, V])
- c.Init(len, cap)
- return c
-}
-
-// Init will initialize this cache with given initial length, maximum capacity and item TTL.
-func (c *Cache[K, V]) Init(len, cap int) {
- c.SetEvictionCallback(nil)
- c.SetInvalidateCallback(nil)
- c.Cache.Init(len, cap)
-}
-
-// SetEvictionCallback: implements cache.Cache's SetEvictionCallback().
-func (c *Cache[K, V]) SetEvictionCallback(hook func(K, V)) {
- c.locked(func() { c.Evict = hook })
-}
-
-// SetInvalidateCallback: implements cache.Cache's SetInvalidateCallback().
-func (c *Cache[K, V]) SetInvalidateCallback(hook func(K, V)) {
- c.locked(func() { c.Invalid = hook })
-}
-
-// Get: implements cache.Cache's Get().
-func (c *Cache[K, V]) Get(key K) (V, bool) {
- var (
- // did exist in cache?
- ok bool
-
- // cached value.
- v V
- )
-
- c.locked(func() {
- var item *Entry
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
- if !ok {
- return
- }
-
- // Set item value.
- v = item.Value.(V)
- })
-
- return v, ok
-}
-
-// Add: implements cache.Cache's Add().
-func (c *Cache[K, V]) Add(key K, value V) bool {
- var (
- // did exist in cache?
- ok bool
-
- // was entry evicted?
- ev bool
-
- // evicted key values.
- evcK K
- evcV V
-
- // hook func ptrs.
- evict func(K, V)
- )
-
- c.locked(func() {
- // Check if in cache.
- ok = c.Cache.Has(key)
- if ok {
- return
- }
-
- // Alloc new entry.
- new := GetEntry()
- new.Key = key
- new.Value = value
-
- // Add new entry to cache and catched any evicted item.
- c.Cache.SetWithHook(key, new, func(_ K, item *Entry) {
- evcK = item.Key.(K)
- evcV = item.Value.(V)
- ev = true
- PutEntry(item)
- })
-
- // Set hook func ptr.
- evict = c.Evict
- })
-
- if ev && evict != nil {
- // Pass to eviction hook.
- evict(evcK, evcV)
- }
-
- return !ok
-}
-
-// Set: implements cache.Cache's Set().
-func (c *Cache[K, V]) Set(key K, value V) {
- var (
- // did exist in cache?
- ok bool
-
- // was entry evicted?
- ev bool
-
- // old value.
- oldV V
-
- // evicted key values.
- evcK K
- evcV V
-
- // hook func ptrs.
- invalid func(K, V)
- evict func(K, V)
- )
-
- c.locked(func() {
- var item *Entry
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
-
- if ok {
- // Set old value.
- oldV = item.Value.(V)
-
- // Update the existing item.
- item.Value = value
- } else {
- // Alloc new entry.
- new := GetEntry()
- new.Key = key
- new.Value = value
-
- // Add new entry to cache and catched any evicted item.
- c.Cache.SetWithHook(key, new, func(_ K, item *Entry) {
- evcK = item.Key.(K)
- evcV = item.Value.(V)
- ev = true
- PutEntry(item)
- })
- }
-
- // Set hook func ptrs.
- invalid = c.Invalid
- evict = c.Evict
- })
-
- if ok && invalid != nil {
- // Pass to invalidate hook.
- invalid(key, oldV)
- }
-
- if ev && evict != nil {
- // Pass to eviction hook.
- evict(evcK, evcV)
- }
-}
-
-// CAS: implements cache.Cache's CAS().
-func (c *Cache[K, V]) CAS(key K, old V, new V, cmp func(V, V) bool) bool {
- var (
- // did exist in cache?
- ok bool
-
- // swapped value.
- oldV V
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- c.locked(func() {
- var item *Entry
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
- if !ok {
- return
- }
-
- // Set old value.
- oldV = item.Value.(V)
-
- // Perform the comparison
- if !cmp(old, oldV) {
- var zero V
- oldV = zero
- return
- }
-
- // Update value.
- item.Value = new
-
- // Set hook func ptr.
- invalid = c.Invalid
- })
-
- if ok && invalid != nil {
- // Pass to invalidate hook.
- invalid(key, oldV)
- }
-
- return ok
-}
-
-// Swap: implements cache.Cache's Swap().
-func (c *Cache[K, V]) Swap(key K, swp V) V {
- var (
- // did exist in cache?
- ok bool
-
- // swapped value.
- oldV V
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- c.locked(func() {
- var item *Entry
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
- if !ok {
- return
- }
-
- // Set old value.
- oldV = item.Value.(V)
-
- // Update value.
- item.Value = swp
-
- // Set hook func ptr.
- invalid = c.Invalid
- })
-
- if ok && invalid != nil {
- // Pass to invalidate hook.
- invalid(key, oldV)
- }
-
- return oldV
-}
-
-// Has: implements cache.Cache's Has().
-func (c *Cache[K, V]) Has(key K) (ok bool) {
- c.locked(func() {
- ok = c.Cache.Has(key)
- })
- return
-}
-
-// Invalidate: implements cache.Cache's Invalidate().
-func (c *Cache[K, V]) Invalidate(key K) (ok bool) {
- var (
- // old value.
- oldV V
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- c.locked(func() {
- var item *Entry
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
- if !ok {
- return
- }
-
- // Set old value.
- oldV = item.Value.(V)
-
- // Remove from cache map
- _ = c.Cache.Delete(key)
-
- // Free entry
- PutEntry(item)
-
- // Set hook func ptrs.
- invalid = c.Invalid
- })
-
- if ok && invalid != nil {
- // Pass to invalidate hook.
- invalid(key, oldV)
- }
-
- return
-}
-
-// InvalidateAll: implements cache.Cache's InvalidateAll().
-func (c *Cache[K, V]) InvalidateAll(keys ...K) (ok bool) {
- var (
- // deleted items.
- items []*Entry
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- // Allocate a slice for invalidated.
- items = make([]*Entry, 0, len(keys))
-
- c.locked(func() {
- for x := range keys {
- var item *Entry
-
- // Check for item in cache
- item, ok = c.Cache.Get(keys[x])
- if !ok {
- continue
- }
-
- // Append this old value.
- items = append(items, item)
-
- // Remove from cache map
- _ = c.Cache.Delete(keys[x])
- }
-
- // Set hook func ptrs.
- invalid = c.Invalid
- })
-
- if invalid != nil {
- for x := range items {
- // Pass to invalidate hook.
- k := items[x].Key.(K)
- v := items[x].Value.(V)
- invalid(k, v)
-
- // Free this entry.
- PutEntry(items[x])
- }
- }
-
- return
-}
-
-// Clear: implements cache.Cache's Clear().
-func (c *Cache[K, V]) Clear() { c.Trim(100) }
-
-// Trim will truncate the cache to ensure it stays within given percentage of total capacity.
-func (c *Cache[K, V]) Trim(perc float64) {
- var (
- // deleted items
- items []*Entry
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- c.locked(func() {
- // Calculate number of cache items to truncate.
- max := (perc / 100) * float64(c.Cache.Cap())
- diff := c.Cache.Len() - int(max)
- if diff <= 0 {
- return
- }
-
- // Set hook func ptr.
- invalid = c.Invalid
-
- // Truncate by calculated length.
- items = c.truncate(diff, invalid)
- })
-
- if invalid != nil {
- for x := range items {
- // Pass to invalidate hook.
- k := items[x].Key.(K)
- v := items[x].Value.(V)
- invalid(k, v)
-
- // Free this entry.
- PutEntry(items[x])
- }
- }
-}
-
-// Len: implements cache.Cache's Len().
-func (c *Cache[K, V]) Len() (l int) {
- c.locked(func() { l = c.Cache.Len() })
- return
-}
-
-// Cap: implements cache.Cache's Cap().
-func (c *Cache[K, V]) Cap() (l int) {
- c.locked(func() { l = c.Cache.Cap() })
- return
-}
-
-// locked performs given function within mutex lock (NOTE: UNLOCK IS NOT DEFERRED).
-func (c *Cache[K, V]) locked(fn func()) {
- c.Lock()
- fn()
- c.Unlock()
-}
-
-// truncate will truncate the cache by given size, returning deleted items.
-func (c *Cache[K, V]) truncate(sz int, hook func(K, V)) []*Entry {
- if hook == nil {
- // No hook to execute, simply release all truncated entries.
- c.Cache.Truncate(sz, func(_ K, item *Entry) { PutEntry(item) })
- return nil
- }
-
- // Allocate a slice for deleted.
- deleted := make([]*Entry, 0, sz)
-
- // Truncate and catch all deleted k-v pairs.
- c.Cache.Truncate(sz, func(_ K, item *Entry) {
- deleted = append(deleted, item)
- })
-
- return deleted
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v3/simple/pool.go b/vendor/codeberg.org/gruf/go-cache/v3/simple/pool.go
deleted file mode 100644
index 34ae17546..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v3/simple/pool.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package simple
-
-import "sync"
-
-// entryPool is a global pool for Entry
-// objects, regardless of cache type.
-var entryPool sync.Pool
-
-// GetEntry fetches an Entry from pool, or allocates new.
-func GetEntry() *Entry {
- v := entryPool.Get()
- if v == nil {
- return new(Entry)
- }
- return v.(*Entry)
-}
-
-// PutEntry replaces an Entry in the pool.
-func PutEntry(e *Entry) {
- e.Key = nil
- e.Value = nil
- entryPool.Put(e)
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go b/vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go
deleted file mode 100644
index 12faa86b2..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package ttl
-
-import (
- "time"
-
- "codeberg.org/gruf/go-sched"
-)
-
-// scheduler is the global cache runtime
-// scheduler for handling cache evictions.
-var scheduler sched.Scheduler
-
-// schedule will given sweep routine to the global scheduler, and start global scheduler.
-func schedule(sweep func(time.Time), freq time.Duration) func() {
- if !scheduler.Running() {
- // ensure sched running
- _ = scheduler.Start()
- }
- return scheduler.Schedule(sched.NewJob(sweep).Every(freq))
-}
diff --git a/vendor/codeberg.org/gruf/go-cache/v3/ttl/ttl.go b/vendor/codeberg.org/gruf/go-cache/v3/ttl/ttl.go
deleted file mode 100644
index 106d675c8..000000000
--- a/vendor/codeberg.org/gruf/go-cache/v3/ttl/ttl.go
+++ /dev/null
@@ -1,636 +0,0 @@
-package ttl
-
-import (
- "sync"
- "time"
- _ "unsafe"
-
- "codeberg.org/gruf/go-maps"
-)
-
-// Entry represents an item in the cache, with it's currently calculated Expiry time.
-type Entry[Key comparable, Value any] struct {
- Key Key
- Value Value
- Expiry uint64
-}
-
-// Cache is the underlying TTLCache implementation, providing both the base Cache interface and unsafe access to underlying map to allow flexibility in building your own.
-type Cache[Key comparable, Value any] struct {
- // TTL is the cache item TTL.
- TTL time.Duration
-
- // Evict is the hook that is called when an item is evicted from the cache.
- Evict func(Key, Value)
-
- // Invalid is the hook that is called when an item's data in the cache is invalidated, includes Add/Set.
- Invalid func(Key, Value)
-
- // Cache is the underlying hashmap used for this cache.
- Cache maps.LRUMap[Key, *Entry[Key, Value]]
-
- // stop is the eviction routine cancel func.
- stop func()
-
- // pool is a memory pool of entry objects.
- pool []*Entry[Key, Value]
-
- // Embedded mutex.
- sync.Mutex
-}
-
-// New returns a new initialized Cache with given initial length, maximum capacity and item TTL.
-func New[K comparable, V any](len, cap int, ttl time.Duration) *Cache[K, V] {
- c := new(Cache[K, V])
- c.Init(len, cap, ttl)
- return c
-}
-
-// Init will initialize this cache with given initial length, maximum capacity and item TTL.
-func (c *Cache[K, V]) Init(len, cap int, ttl time.Duration) {
- if ttl <= 0 {
- // Default duration
- ttl = time.Second * 5
- }
- c.TTL = ttl
- c.SetEvictionCallback(nil)
- c.SetInvalidateCallback(nil)
- c.Cache.Init(len, cap)
-}
-
-// Start: implements cache.Cache's Start().
-func (c *Cache[K, V]) Start(freq time.Duration) (ok bool) {
- // Nothing to start
- if freq <= 0 {
- return false
- }
-
- // Safely start
- c.Lock()
-
- if ok = (c.stop == nil); ok {
- // Not yet running, schedule us
- c.stop = schedule(c.Sweep, freq)
- }
-
- // Done with lock
- c.Unlock()
-
- return
-}
-
-// Stop: implements cache.Cache's Stop().
-func (c *Cache[K, V]) Stop() (ok bool) {
- // Safely stop
- c.Lock()
-
- if ok = (c.stop != nil); ok {
- // We're running, cancel evicts
- c.stop()
- c.stop = nil
- }
-
- // Done with lock
- c.Unlock()
-
- return
-}
-
-// Sweep attempts to evict expired items (with callback!) from cache.
-func (c *Cache[K, V]) Sweep(_ time.Time) {
- var (
- // evicted key-values.
- kvs []kv[K, V]
-
- // hook func ptrs.
- evict func(K, V)
-
- // get current nanoseconds.
- now = runtime_nanotime()
- )
-
- c.locked(func() {
- if c.TTL <= 0 {
- // sweep is
- // disabled
- return
- }
-
- // Sentinel value
- after := -1
-
- // The cache will be ordered by expiry date, we iterate until we reach the index of
- // the youngest item that hsa expired, as all succeeding items will also be expired.
- c.Cache.RangeIf(0, c.Cache.Len(), func(i int, _ K, item *Entry[K, V]) bool {
- if now > item.Expiry {
- after = i
-
- // evict all older items
- // than this (inclusive)
- return false
- }
-
- // cont. loop.
- return true
- })
-
- if after == -1 {
- // No Truncation needed
- return
- }
-
- // Set hook func ptr.
- evict = c.Evict
-
- // Truncate determined size.
- sz := c.Cache.Len() - after
- kvs = c.truncate(sz, evict)
- })
-
- if evict != nil {
- for x := range kvs {
- // Pass to eviction hook.
- evict(kvs[x].K, kvs[x].V)
- }
- }
-}
-
-// SetEvictionCallback: implements cache.Cache's SetEvictionCallback().
-func (c *Cache[K, V]) SetEvictionCallback(hook func(K, V)) {
- c.locked(func() {
- c.Evict = hook
- })
-}
-
-// SetInvalidateCallback: implements cache.Cache's SetInvalidateCallback().
-func (c *Cache[K, V]) SetInvalidateCallback(hook func(K, V)) {
- c.locked(func() {
- c.Invalid = hook
- })
-}
-
-// SetTTL: implements cache.Cache's SetTTL().
-func (c *Cache[K, V]) SetTTL(ttl time.Duration, update bool) {
- c.locked(func() {
- // Set updated TTL
- diff := ttl - c.TTL
- c.TTL = ttl
-
- if update {
- // Update existing cache entries with new expiry time
- c.Cache.Range(0, c.Cache.Len(), func(i int, _ K, item *Entry[K, V]) {
- item.Expiry += uint64(diff)
- })
- }
- })
-}
-
-// Get: implements cache.Cache's Get().
-func (c *Cache[K, V]) Get(key K) (V, bool) {
- var (
- // did exist in cache?
- ok bool
-
- // cached value.
- v V
- )
-
- c.locked(func() {
- var item *Entry[K, V]
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
- if !ok {
- return
- }
-
- // Update fetched's expiry
- item.Expiry = c.expiry()
-
- // Set value.
- v = item.Value
- })
-
- return v, ok
-}
-
-// Add: implements cache.Cache's Add().
-func (c *Cache[K, V]) Add(key K, value V) bool {
- var (
- // did exist in cache?
- ok bool
-
- // was entry evicted?
- ev bool
-
- // evicted key values.
- evcK K
- evcV V
-
- // hook func ptrs.
- evict func(K, V)
- )
-
- c.locked(func() {
- // Check if in cache.
- ok = c.Cache.Has(key)
- if ok {
- return
- }
-
- // Alloc new entry.
- new := c.alloc()
- new.Expiry = c.expiry()
- new.Key = key
- new.Value = value
-
- // Add new entry to cache and catched any evicted item.
- c.Cache.SetWithHook(key, new, func(_ K, item *Entry[K, V]) {
- evcK = item.Key
- evcV = item.Value
- ev = true
- c.free(item)
- })
-
- // Set hook func ptr.
- evict = c.Evict
- })
-
- if ev && evict != nil {
- // Pass to eviction hook.
- evict(evcK, evcV)
- }
-
- return !ok
-}
-
-// Set: implements cache.Cache's Set().
-func (c *Cache[K, V]) Set(key K, value V) {
- var (
- // did exist in cache?
- ok bool
-
- // was entry evicted?
- ev bool
-
- // old value.
- oldV V
-
- // evicted key values.
- evcK K
- evcV V
-
- // hook func ptrs.
- invalid func(K, V)
- evict func(K, V)
- )
-
- c.locked(func() {
- var item *Entry[K, V]
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
-
- if ok {
- // Set old value.
- oldV = item.Value
-
- // Update the existing item.
- item.Expiry = c.expiry()
- item.Value = value
- } else {
- // Alloc new entry.
- new := c.alloc()
- new.Expiry = c.expiry()
- new.Key = key
- new.Value = value
-
- // Add new entry to cache and catched any evicted item.
- c.Cache.SetWithHook(key, new, func(_ K, item *Entry[K, V]) {
- evcK = item.Key
- evcV = item.Value
- ev = true
- c.free(item)
- })
- }
-
- // Set hook func ptrs.
- invalid = c.Invalid
- evict = c.Evict
- })
-
- if ok && invalid != nil {
- // Pass to invalidate hook.
- invalid(key, oldV)
- }
-
- if ev && evict != nil {
- // Pass to eviction hook.
- evict(evcK, evcV)
- }
-}
-
-// CAS: implements cache.Cache's CAS().
-func (c *Cache[K, V]) CAS(key K, old V, new V, cmp func(V, V) bool) bool {
- var (
- // did exist in cache?
- ok bool
-
- // swapped value.
- oldV V
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- c.locked(func() {
- var item *Entry[K, V]
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
- if !ok {
- return
- }
-
- // Perform the comparison
- if !cmp(old, item.Value) {
- return
- }
-
- // Set old value.
- oldV = item.Value
-
- // Update value + expiry.
- item.Expiry = c.expiry()
- item.Value = new
-
- // Set hook func ptr.
- invalid = c.Invalid
- })
-
- if ok && invalid != nil {
- // Pass to invalidate hook.
- invalid(key, oldV)
- }
-
- return ok
-}
-
-// Swap: implements cache.Cache's Swap().
-func (c *Cache[K, V]) Swap(key K, swp V) V {
- var (
- // did exist in cache?
- ok bool
-
- // swapped value.
- oldV V
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- c.locked(func() {
- var item *Entry[K, V]
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
- if !ok {
- return
- }
-
- // Set old value.
- oldV = item.Value
-
- // Update value + expiry.
- item.Expiry = c.expiry()
- item.Value = swp
-
- // Set hook func ptr.
- invalid = c.Invalid
- })
-
- if ok && invalid != nil {
- // Pass to invalidate hook.
- invalid(key, oldV)
- }
-
- return oldV
-}
-
-// Has: implements cache.Cache's Has().
-func (c *Cache[K, V]) Has(key K) (ok bool) {
- c.locked(func() {
- ok = c.Cache.Has(key)
- })
- return
-}
-
-// Invalidate: implements cache.Cache's Invalidate().
-func (c *Cache[K, V]) Invalidate(key K) (ok bool) {
- var (
- // old value.
- oldV V
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- c.locked(func() {
- var item *Entry[K, V]
-
- // Check for item in cache
- item, ok = c.Cache.Get(key)
- if !ok {
- return
- }
-
- // Set old value.
- oldV = item.Value
-
- // Remove from cache map
- _ = c.Cache.Delete(key)
-
- // Free entry
- c.free(item)
-
- // Set hook func ptrs.
- invalid = c.Invalid
- })
-
- if ok && invalid != nil {
- // Pass to invalidate hook.
- invalid(key, oldV)
- }
-
- return
-}
-
-// InvalidateAll: implements cache.Cache's InvalidateAll().
-func (c *Cache[K, V]) InvalidateAll(keys ...K) (ok bool) {
- var (
- // invalidated kvs.
- kvs []kv[K, V]
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- // Allocate a slice for invalidated.
- kvs = make([]kv[K, V], 0, len(keys))
-
- c.locked(func() {
- for x := range keys {
- var item *Entry[K, V]
-
- // Check for item in cache
- item, ok = c.Cache.Get(keys[x])
- if !ok {
- continue
- }
-
- // Append this old value to slice
- kvs = append(kvs, kv[K, V]{
- K: keys[x],
- V: item.Value,
- })
-
- // Remove from cache map
- _ = c.Cache.Delete(keys[x])
-
- // Free entry
- c.free(item)
- }
-
- // Set hook func ptrs.
- invalid = c.Invalid
- })
-
- if invalid != nil {
- for x := range kvs {
- // Pass to invalidate hook.
- invalid(kvs[x].K, kvs[x].V)
- }
- }
-
- return
-}
-
-// Clear: implements cache.Cache's Clear().
-func (c *Cache[K, V]) Clear() {
- var (
- // deleted key-values.
- kvs []kv[K, V]
-
- // hook func ptrs.
- invalid func(K, V)
- )
-
- c.locked(func() {
- // Set hook func ptr.
- invalid = c.Invalid
-
- // Truncate the entire cache length.
- kvs = c.truncate(c.Cache.Len(), invalid)
- })
-
- if invalid != nil {
- for x := range kvs {
- // Pass to invalidate hook.
- invalid(kvs[x].K, kvs[x].V)
- }
- }
-}
-
-// Len: implements cache.Cache's Len().
-func (c *Cache[K, V]) Len() (l int) {
- c.locked(func() { l = c.Cache.Len() })
- return
-}
-
-// Cap: implements cache.Cache's Cap().
-func (c *Cache[K, V]) Cap() (l int) {
- c.locked(func() { l = c.Cache.Cap() })
- return
-}
-
-// locked performs given function within mutex lock (NOTE: UNLOCK IS NOT DEFERRED).
-func (c *Cache[K, V]) locked(fn func()) {
- c.Lock()
- fn()
- c.Unlock()
-}
-
-// truncate will truncate the cache by given size, returning deleted items.
-func (c *Cache[K, V]) truncate(sz int, hook func(K, V)) []kv[K, V] {
- if hook == nil {
- // No hook to execute, simply free all truncated entries.
- c.Cache.Truncate(sz, func(_ K, e *Entry[K, V]) { c.free(e) })
- return nil
- }
-
- // Allocate a slice for deleted k-v pairs.
- deleted := make([]kv[K, V], 0, sz)
-
- c.Cache.Truncate(sz, func(_ K, item *Entry[K, V]) {
- // Store key-value pair for later access.
- deleted = append(deleted, kv[K, V]{
- K: item.Key,
- V: item.Value,
- })
-
- // Free entry.
- c.free(item)
- })
-
- return deleted
-}
-
-// alloc will acquire cache entry from pool, or allocate new.
-func (c *Cache[K, V]) alloc() *Entry[K, V] {
- if len(c.pool) == 0 {
- return &Entry[K, V]{}
- }
- idx := len(c.pool) - 1
- e := c.pool[idx]
- c.pool = c.pool[:idx]
- return e
-}
-
-// clone allocates a new Entry and copies all info from passed Entry.
-func (c *Cache[K, V]) clone(e *Entry[K, V]) *Entry[K, V] {
- e2 := c.alloc()
- e2.Key = e.Key
- e2.Value = e.Value
- e2.Expiry = e.Expiry
- return e2
-}
-
-// free will reset entry fields and place back in pool.
-func (c *Cache[K, V]) free(e *Entry[K, V]) {
- var (
- zk K
- zv V
- )
- e.Expiry = 0
- e.Key = zk
- e.Value = zv
- c.pool = append(c.pool, e)
-}
-
-//go:linkname runtime_nanotime runtime.nanotime
-func runtime_nanotime() uint64
-
-// expiry returns an the next expiry time to use for an entry,
-// which is equivalent to time.Now().Add(ttl), or zero if disabled.
-func (c *Cache[K, V]) expiry() uint64 {
- if ttl := c.TTL; ttl > 0 {
- return runtime_nanotime() +
- uint64(c.TTL)
- }
- return 0
-}
-
-type kv[K comparable, V any] struct {
- K K
- V V
-}
diff --git a/vendor/codeberg.org/gruf/go-caller/LICENSE b/vendor/codeberg.org/gruf/go-caller/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-caller/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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-caller/README.md b/vendor/codeberg.org/gruf/go-caller/README.md
deleted file mode 100644
index faae29e18..000000000
--- a/vendor/codeberg.org/gruf/go-caller/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-caller
-
-runtime-cached Go calling function names per PC, useful in shaving time from outputting log entries. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-caller/caller.go b/vendor/codeberg.org/gruf/go-caller/caller.go
deleted file mode 100644
index b07e05169..000000000
--- a/vendor/codeberg.org/gruf/go-caller/caller.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package caller
-
-import (
- "runtime"
- "strings"
- "sync/atomic"
-)
-
-var (
- // callerCache caches PC values to string names.
- // note this may be a little slower than Caller()
- // calls on startup, but after all PCs are cached
- // this should be ~3x faster + less GC overhead.
- //
- // see the following benchmark:
- // goos: linux
- // goarch: amd64
- // pkg: codeberg.org/gruf/go-caller
- // cpu: AMD Ryzen 7 7840U w/ Radeon 780M Graphics
- // BenchmarkCallerCache
- // BenchmarkCallerCache-16 16796982 66.19 ns/op 24 B/op 3 allocs/op
- // BenchmarkNoCallerCache
- // BenchmarkNoCallerCache-16 5486168 219.9 ns/op 744 B/op 6 allocs/op
- callerCache atomic.Pointer[map[uintptr]string]
-
- // stringCache caches strings to minimise string memory use
- // by ensuring only 1 instance of the same func name string.
- stringCache atomic.Pointer[map[string]string]
-)
-
-// Clear will empty the global caller PC -> func names cache.
-func Clear() { callerCache.Store(nil); stringCache.Store(nil) }
-
-// Name returns the calling function name for given
-// program counter, formatted to be useful for logging.
-func Name(pc uintptr) string {
-
- // Get frame iterator for program counter.
- frames := runtime.CallersFrames([]uintptr{pc})
- if frames == nil {
- return "???"
- }
-
- // Get func name from frame.
- frame, _ := frames.Next()
- name := frame.Function
- if name == "" {
- return "???"
- }
-
- // Drop all but package and function name, no path.
- if idx := strings.LastIndex(name, "/"); idx >= 0 {
- name = name[idx+1:]
- }
-
- const params = `[...]`
-
- // Drop any function generic type parameter markers.
- if idx := strings.Index(name, params); idx >= 0 {
- name = name[:idx] + name[idx+len(params):]
- }
-
- return name
-}
-
-// Get will return calling func information for given PC value,
-// caching func names by their PC values to reduce calls to Caller().
-func Get(pc uintptr) string {
- var cache map[uintptr]string
- for {
- // Load caller cache map.
- ptr := callerCache.Load()
-
- if ptr != nil {
- // Look for stored name.
- name, ok := (*ptr)[pc]
- if ok {
- return name
- }
-
- // Make a clone of existing caller cache map.
- cache = make(map[uintptr]string, len(*ptr)+1)
- for key, value := range *ptr {
- cache[key] = value
- }
- } else {
- // Allocate new caller cache map.
- cache = make(map[uintptr]string, 1)
- }
-
- // Calculate caller
- // name for PC value.
- name := Name(pc)
- name = getString(name)
-
- // Store in map.
- cache[pc] = name
-
- // Attempt to update caller cache map pointer.
- if callerCache.CompareAndSwap(ptr, &cache) {
- return name
- }
- }
-}
-
-func getString(key string) string {
- var cache map[string]string
- for {
- // Load string cache map.
- ptr := stringCache.Load()
-
- if ptr != nil {
- // Check for existing string.
- if str, ok := (*ptr)[key]; ok {
- return str
- }
-
- // Make a clone of existing string cache map.
- cache = make(map[string]string, len(*ptr)+1)
- for key, value := range *ptr {
- cache[key] = value
- }
- } else {
- // Allocate new string cache map.
- cache = make(map[string]string, 1)
- }
-
- // Store this str.
- cache[key] = key
-
- // Attempt to update string cache map pointer.
- if stringCache.CompareAndSwap(ptr, &cache) {
- return key
- }
- }
-}
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 e7121390d..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package debug
-
-import (
- _debug "runtime/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 4401b9725..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"
-
-// DEBUG returns whether debugging is enabled.
-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 82ef7263e..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 returns whether debugging is enabled.
-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 91edd5fe5..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 returns whether debugging is enabled.
-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 4f91aa092..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 21f7cb767..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# go-errors
-
-powerful errors library with a simple API that allows:
-- accessing all the standard library errors functions
-- wrapping of errors
-- adding values to errors, in a similar manner to contexts
-- including calling function prefix when tag=errcaller is set
-- including stacktrace with error when tag=errtrace is set
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/build_caller.go b/vendor/codeberg.org/gruf/go-errors/v2/build_caller.go
deleted file mode 100644
index ad5067574..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/build_caller.go
+++ /dev/null
@@ -1,26 +0,0 @@
-//go:build errcaller
-// +build errcaller
-
-package errors
-
-import (
- _ "unsafe"
-)
-
-// IncludesCaller is a compile-time flag used to indicate whether
-// to include calling function prefix on error wrap / creation.
-const IncludesCaller = true
-
-type caller string
-
-// set will set the actual caller value
-// only when correct build flag is set.
-func (c *caller) set(v string) {
- *c = caller(v)
-}
-
-// value returns the actual caller value
-// only when correct build flag is set
-func (c caller) value() string {
- return string(c)
-}
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/build_nocaller.go b/vendor/codeberg.org/gruf/go-errors/v2/build_nocaller.go
deleted file mode 100644
index 935283bf5..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/build_nocaller.go
+++ /dev/null
@@ -1,18 +0,0 @@
-//go:build !errcaller
-// +build !errcaller
-
-package errors
-
-// IncludesCaller is a compile-time flag used to indicate whether
-// to include calling function prefix on error wrap / creation.
-const IncludesCaller = false
-
-type caller struct{}
-
-// set will set the actual caller value
-// only when correct build flag is set.
-func (caller) set(string) {}
-
-// value returns the actual caller value
-// only when correct build flag is set.
-func (caller) value() string { return "" }
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/build_notrace.go b/vendor/codeberg.org/gruf/go-errors/v2/build_notrace.go
deleted file mode 100644
index acee2e698..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/build_notrace.go
+++ /dev/null
@@ -1,20 +0,0 @@
-//go:build !errtrace
-// +build !errtrace
-
-package errors
-
-import "runtime"
-
-// IncludesStacktrace is a compile-time flag used to indicate
-// whether to include stacktraces on error wrap / creation.
-const IncludesStacktrace = false
-
-type trace struct{}
-
-// set will set the actual trace value
-// only when correct build flag is set.
-func (trace) set([]runtime.Frame) {}
-
-// value returns the actual trace value
-// only when correct build flag is set.
-func (trace) value() Callers { return nil }
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/build_trace.go b/vendor/codeberg.org/gruf/go-errors/v2/build_trace.go
deleted file mode 100644
index e7b652699..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/build_trace.go
+++ /dev/null
@@ -1,27 +0,0 @@
-//go:build errtrace
-// +build errtrace
-
-package errors
-
-import (
- "runtime"
- _ "unsafe"
-)
-
-// IncludesStacktrace is a compile-time flag used to indicate
-// whether to include stacktraces on error wrap / creation.
-const IncludesStacktrace = true
-
-type trace []runtime.Frame
-
-// set will set the actual trace value
-// only when correct build flag is set.
-func (t *trace) set(v []runtime.Frame) {
- *t = trace(v)
-}
-
-// value returns the actual trace value
-// only when correct build flag is set.
-func (t trace) value() Callers {
- return Callers(t)
-}
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 d5f1a7ab1..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/errors.go
+++ /dev/null
@@ -1,248 +0,0 @@
-package errors
-
-import (
- "fmt"
- "runtime"
-)
-
-// New returns a new error created from message.
-//
-// Note this function cannot be inlined, to ensure expected
-// and consistent behaviour in setting trace / caller info.
-//
-//go:noinline
-func New(msg string) error {
- var c caller
- var t trace
- if IncludesCaller {
- pcs := make([]uintptr, 1)
- _ = runtime.Callers(2, pcs)
- fn := runtime.FuncForPC(pcs[0])
- c.set(funcName(fn))
- }
- if IncludesStacktrace {
- pcs := make([]uintptr, 10)
- n := runtime.Callers(2, pcs)
- iter := runtime.CallersFrames(pcs[:n])
- t.set(gatherFrames(iter, n))
- }
- return &_errormsg{
- cfn: c,
- msg: msg,
- trc: t,
- }
-}
-
-// Newf returns a new error created from message format and args.
-//
-// Note this function cannot be inlined, to ensure expected
-// and consistent behaviour in setting trace / caller info.
-//
-//go:noinline
-func Newf(msgf string, args ...interface{}) error {
- var c caller
- var t trace
- if IncludesCaller {
- pcs := make([]uintptr, 1)
- _ = runtime.Callers(2, pcs)
- fn := runtime.FuncForPC(pcs[0])
- c.set(funcName(fn))
- }
- if IncludesStacktrace {
- pcs := make([]uintptr, 10)
- n := runtime.Callers(2, pcs)
- iter := runtime.CallersFrames(pcs[:n])
- t.set(gatherFrames(iter, n))
- }
- return &_errormsg{
- cfn: c,
- msg: fmt.Sprintf(msgf, args...),
- trc: t,
- }
-}
-
-// NewAt returns a new error created, skipping 'skip'
-// frames for trace / caller information, from message.
-//
-// Note this function cannot be inlined, to ensure expected
-// and consistent behaviour in setting trace / caller info.
-//
-//go:noinline
-func NewAt(skip int, msg string) error {
- var c caller
- var t trace
- if IncludesCaller {
- pcs := make([]uintptr, 1)
- _ = runtime.Callers(skip+1, pcs)
- fn := runtime.FuncForPC(pcs[0])
- c.set(funcName(fn))
- }
- if IncludesStacktrace {
- pcs := make([]uintptr, 10)
- n := runtime.Callers(skip+1, pcs)
- iter := runtime.CallersFrames(pcs[:n])
- t.set(gatherFrames(iter, n))
- }
- return &_errormsg{
- cfn: c,
- msg: msg,
- trc: t,
- }
-}
-
-// Wrap will wrap supplied error within a new error created from message.
-//
-// Note this function cannot be inlined, to ensure expected
-// and consistent behaviour in setting trace / caller info.
-//
-//go:noinline
-func Wrap(err error, msg string) error {
- if err == nil {
- panic("cannot wrap nil error")
- }
- var c caller
- var t trace
- if IncludesCaller {
- pcs := make([]uintptr, 1)
- _ = runtime.Callers(2, pcs)
- fn := runtime.FuncForPC(pcs[0])
- c.set(funcName(fn))
- }
- if IncludesStacktrace {
- pcs := make([]uintptr, 10)
- n := runtime.Callers(2, pcs)
- iter := runtime.CallersFrames(pcs[:n])
- t.set(gatherFrames(iter, n))
- }
- return &_errorwrap{
- cfn: c,
- msg: msg,
- err: err,
- trc: t,
- }
-}
-
-// Wrapf will wrap supplied error within a new error created from message format and args.
-//
-// Note this function cannot be inlined, to ensure expected
-// and consistent behaviour in setting trace / caller info.
-//
-//go:noinline
-func Wrapf(err error, msgf string, args ...interface{}) error {
- if err == nil {
- panic("cannot wrap nil error")
- }
- var c caller
- var t trace
- if IncludesCaller {
- pcs := make([]uintptr, 1)
- _ = runtime.Callers(2, pcs)
- fn := runtime.FuncForPC(pcs[0])
- c.set(funcName(fn))
- }
- if IncludesStacktrace {
- pcs := make([]uintptr, 10)
- n := runtime.Callers(2, pcs)
- iter := runtime.CallersFrames(pcs[:n])
- t.set(gatherFrames(iter, n))
- }
- return &_errorwrap{
- cfn: c,
- msg: fmt.Sprintf(msgf, args...),
- err: err,
- trc: t,
- }
-}
-
-// WrapAt wraps error within new error created from message,
-// skipping 'skip' frames for trace / caller information.
-//
-// Note this function cannot be inlined, to ensure expected
-// and consistent behaviour in setting trace / caller info.
-//
-//go:noinline
-func WrapAt(skip int, err error, msg string) error {
- if err == nil {
- panic("cannot wrap nil error")
- }
- var c caller
- var t trace
- if IncludesCaller {
- pcs := make([]uintptr, 1)
- _ = runtime.Callers(skip+1, pcs)
- fn := runtime.FuncForPC(pcs[0])
- c.set(funcName(fn))
- }
- if IncludesStacktrace {
- pcs := make([]uintptr, 10)
- n := runtime.Callers(skip+1, pcs)
- iter := runtime.CallersFrames(pcs[:n])
- t.set(gatherFrames(iter, n))
- }
- return &_errorwrap{
- cfn: c,
- msg: msg,
- err: err,
- trc: t,
- }
-}
-
-// Stacktrace fetches first stored stacktrace of callers from error chain.
-func Stacktrace(err error) Callers {
- if !IncludesStacktrace {
- // compile-time check
- return nil
- }
- if e := AsV2[*_errormsg](err); err != nil {
- return e.trc.value()
- }
- if e := AsV2[*_errorwrap](err); err != nil {
- return e.trc.value()
- }
- return nil
-}
-
-type _errormsg struct {
- cfn caller
- msg string
- trc trace
-}
-
-func (err *_errormsg) Error() string {
- if IncludesCaller {
- fn := err.cfn.value()
- return fn + " " + err.msg
- } else {
- return err.msg
- }
-}
-
-func (err *_errormsg) Is(other error) bool {
- oerr, ok := other.(*_errormsg)
- return ok && oerr.msg == err.msg
-}
-
-type _errorwrap struct {
- cfn caller
- msg string
- err error // wrapped
- trc trace
-}
-
-func (err *_errorwrap) Error() string {
- if IncludesCaller {
- fn := err.cfn.value()
- return fn + " " + err.msg + ": " + err.err.Error()
- } else {
- return err.msg + ": " + err.err.Error()
- }
-}
-
-func (err *_errorwrap) Is(other error) bool {
- oerr, ok := other.(*_errorwrap)
- return ok && oerr.msg == err.msg
-}
-
-func (err *_errorwrap) Unwrap() error {
- return err.err
-}
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 467fe726d..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/once.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package errors
-
-import (
- "sync/atomic"
-)
-
-// OnceError is an error structure that supports safe multi
-// threaded usage and setting only once (until reset).
-type OnceError struct{ ptr atomic.Pointer[error] }
-
-// Store will safely set the OnceError to value, no-op if nil.
-func (e *OnceError) Store(err error) bool {
- if err == nil {
- return false
- }
- return e.ptr.CompareAndSwap(nil, &err)
-}
-
-// Load will load the currently stored error.
-func (e *OnceError) Load() error {
- if ptr := e.ptr.Load(); ptr != nil {
- return *ptr
- }
- return nil
-}
-
-// IsSet returns whether OnceError has been set.
-func (e *OnceError) IsSet() bool { return (e.ptr.Load() != nil) }
-
-// Reset will reset the OnceError value.
-func (e *OnceError) Reset() { e.ptr.Store(nil) }
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/runtime.go b/vendor/codeberg.org/gruf/go-errors/v2/runtime.go
deleted file mode 100644
index 0c8cf11cd..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/runtime.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package errors
-
-import (
- "encoding/json"
- "runtime"
- "strconv"
- "strings"
- "unsafe"
-)
-
-// Callers ...
-type Callers []runtime.Frame
-
-// MarshalJSON implements json.Marshaler to provide an easy, simple default.
-func (c Callers) MarshalJSON() ([]byte, error) {
- // JSON-able frame type
- type jsonFrame struct {
- Func string `json:"func"`
- File string `json:"file"`
- Line int `json:"line"`
- }
-
- // Allocate expected size jsonFrame slice
- jsonFrames := make([]jsonFrame, len(c))
-
- // Convert each to jsonFrame object
- for i := 0; i < len(c); i++ {
- frame := c[i]
- jsonFrames[i] = jsonFrame{
- Func: funcName(frame.Func),
- File: frame.File,
- Line: frame.Line,
- }
- }
-
- // marshal converted frames
- return json.Marshal(jsonFrames)
-}
-
-// String will return a simple string representation of receiving Callers slice.
-func (c Callers) String() string {
- // Guess-timate to reduce allocs
- buf := make([]byte, 0, 64*len(c))
-
- for i := 0; i < len(c); i++ {
- frame := c[i]
-
- // Append formatted caller info
- fn := funcName(frame.Func)
- buf = append(buf, fn+"()\n\t"+frame.File+":"...)
- buf = strconv.AppendInt(buf, int64(frame.Line), 10)
- buf = append(buf, '\n')
- }
-
- return *(*string)(unsafe.Pointer(&buf))
-}
-
-// funcName formats a function name to a quickly-readable string.
-func funcName(fn *runtime.Func) string {
- if fn == nil {
- return ""
- }
-
- // Get func name
- // for formatting.
- name := fn.Name()
-
- // Drop all but the package name and function name, no mod path
- if idx := strings.LastIndex(name, "/"); idx >= 0 {
- name = name[idx+1:]
- }
-
- const params = `[...]`
-
- // Drop any generic type parameter markers
- if idx := strings.Index(name, params); idx >= 0 {
- name = name[:idx] + name[idx+len(params):]
- }
-
- return name
-}
-
-// gatherFrames collates runtime frames from a frame iterator.
-func gatherFrames(iter *runtime.Frames, n int) Callers {
- if iter == nil {
- return nil
- }
- frames := make([]runtime.Frame, 0, n)
- for {
- f, ok := iter.Next()
- if !ok {
- break
- }
- frames = append(frames, f)
- }
- return frames
-}
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 e1d7d1440..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/standard.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package errors
-
-import (
- "errors"
-)
-
-// See: errors.Is().
-func Is(err error, target error) bool { return errors.Is(err, target) }
-
-// IsV2 calls Is(err, target) for each target within targets.
-func IsV2(err error, targets ...error) bool {
- for _, target := range targets {
- if Is(err, target) {
- return true
- }
- }
- return false
-}
-
-// See: errors.As().
-func As(err error, target any) bool { return errors.As(err, target) }
-
-// AsV2 is functionally similar to As(), instead
-// leveraging generics to handle allocation and
-// returning of a concrete generic parameter type.
-func AsV2[Type any](err error) Type {
- var t Type
- var ok bool
- errs := []error{err}
- for len(errs) > 0 {
- // Pop next error to check.
- err := errs[len(errs)-1]
- errs = errs[:len(errs)-1]
-
- // Check direct type.
- t, ok = err.(Type)
- if ok {
- return t
- }
-
- // Look for .As() support.
- as, ok := err.(interface {
- As(target any) bool
- })
-
- if ok {
- // Attempt .As().
- if as.As(&t) {
- return t
- }
- }
-
- // Try unwrap errors.
- switch u := err.(type) {
- case interface{ Unwrap() error }:
- errs = append(errs, u.Unwrap())
- case interface{ Unwrap() []error }:
- errs = append(errs, u.Unwrap()...)
- }
- }
- return t
-}
-
-// See: errors.Unwrap().
-func Unwrap(err error) error { return errors.Unwrap(err) }
-
-// UnwrapV2 is functionally similar to Unwrap(), except that
-// it also handles the case of interface{ Unwrap() []error }.
-func UnwrapV2(err error) []error {
- switch u := err.(type) {
- case interface{ Unwrap() error }:
- if e := u.Unwrap(); err != nil {
- return []error{e}
- }
- case interface{ Unwrap() []error }:
- return u.Unwrap()
- }
- return nil
-}
-
-// See: errors.Join().
-func Join(errs ...error) error { return errors.Join(errs...) }
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/value.go b/vendor/codeberg.org/gruf/go-errors/v2/value.go
deleted file mode 100644
index 876e5f80e..000000000
--- a/vendor/codeberg.org/gruf/go-errors/v2/value.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package errors
-
-// WithValue wraps err to store given key-value pair, accessible via Value() function.
-func WithValue(err error, key any, value any) error {
- if err == nil {
- panic("nil error")
- }
- var kvs []kv
- if e := AsV2[*errWithValues](err); e != nil {
- kvs = e.kvs
- }
- return &errWithValues{
- err: err,
- kvs: append(kvs, kv{key, value}),
- }
-}
-
-// Value searches for value stored under given key in error chain.
-func Value(err error, key any) any {
- if e := AsV2[*errWithValues](err); e != nil {
- return e.Value(key)
- }
- return nil
-}
-
-// simple key-value type.
-type kv struct{ k, v any }
-
-// errWithValues wraps an error to provide key-value storage.
-type errWithValues struct {
- err error
- kvs []kv
-}
-
-func (e *errWithValues) Error() string {
- return e.err.Error()
-}
-
-func (e *errWithValues) Unwrap() error {
- return e.err
-}
-
-func (e *errWithValues) Value(key any) any {
- for i := range e.kvs {
- if e.kvs[i].k == key {
- return e.kvs[i].v
- }
- }
- return nil
-}
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 8d6b9d647..000000000
--- a/vendor/codeberg.org/gruf/go-fastcopy/copy.go
+++ /dev/null
@@ -1,135 +0,0 @@
-package fastcopy
-
-import (
- "errors"
- "io"
- "sync"
- _ "unsafe" // link to io.errInvalidWrite.
-)
-
-var (
- // global pool instance.
- pool = CopyPool{size: 4096}
-
- // errInvalidWrite means that a write returned an impossible count.
- errInvalidWrite = errors.New("invalid write result")
-)
-
-// 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/v2/LICENSE b/vendor/codeberg.org/gruf/go-fastpath/v2/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-fastpath/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-fastpath/v2/README.md b/vendor/codeberg.org/gruf/go-fastpath/v2/README.md
deleted file mode 100644
index f89700fb3..000000000
--- a/vendor/codeberg.org/gruf/go-fastpath/v2/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/v2/path.go b/vendor/codeberg.org/gruf/go-fastpath/v2/path.go
deleted file mode 100644
index 91ebb5b36..000000000
--- a/vendor/codeberg.org/gruf/go-fastpath/v2/path.go
+++ /dev/null
@@ -1,328 +0,0 @@
-package fastpath
-
-import (
- "unsafe"
-)
-
-// Clean: see Builder.Clean(). Analogous to path.Clean().
-func Clean(path string) string {
- return (&Builder{}).Clean(path)
-}
-
-// Join: see Builder.Join(). Analogous to path.Join().
-func Join(elems ...string) string {
- return (&Builder{}).Join(elems...)
-}
-
-// Builder provides a means of cleaning and joining system paths,
-// while retaining a singular underlying byte buffer for performance.
-type Builder struct {
- // B is the underlying byte buffer
- B []byte
-
- 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()
-}
-
-// 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 {
- return b.B
-}
-
-// String returns the accumulated path string.
-func (b Builder) String() string {
- return unsafe.String(unsafe.SliceData(b.B), len(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-or-from absolute.
-func (b *Builder) SetAbsolute(enabled bool) {
- if !b.set {
- // Ensure 1B avail
- b.Guarantee(1)
-
- if enabled {
- // Set empty 'abs'
- b.appendByte('/')
- b.abs = true
- } else {
- // Set empty 'rel'
- b.appendByte('.')
- b.abs = false
- }
-
- b.set = true
- return
- }
-
- if !enabled && b.abs {
- // set && absolute
- // -> update
- b.abs = false
-
- // If empty, set to '.' (empty rel path)
- if len(b.B) == 0 || (len(b.B) == 1 && b.B[0] == '/') {
- b.Guarantee(1)
- b.B = b.B[:1]
- b.B[0] = '.'
- return
- }
-
- if b.B[0] != '/' {
- // No need to change
- return
- }
-
- if len(b.B) > 1 {
- // Shift bytes 1 left
- copy(b.B, b.B[1:])
- }
-
- // and drop the '/' prefix'
- b.B = b.B[:len(b.B)-1]
- } else if enabled && !b.abs {
- // set && !absolute
- // -> update
- b.abs = true
-
- // Ensure 1B avail
- b.Guarantee(1)
-
- // If empty, set to '/' (empty abs path)
- if len(b.B) == 0 || (len(b.B) == 1 && b.B[0] == '.') {
- b.Guarantee(1)
- b.B = b.B[:1]
- b.B[0] = '/'
- 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] = '/'
- }
-}
-
-// AppendBytes 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) AppendBytes(path []byte) {
- if len(path) == 0 {
- return
- }
- b.Guarantee(len(path) + 1)
- b.append(unsafe.String(unsafe.SliceData(path), len(path)))
-}
-
-// Append 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) Append(path string) {
- if len(path) == 0 {
- return
- }
- b.Guarantee(len(path) + 1)
- b.append(path)
-}
-
-// 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 {
- if path == "" {
- return "."
- }
- b.Reset()
- b.Guarantee(len(path) + 1)
- b.append(path)
- return string(b.B)
-}
-
-// 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(elems ...string) string {
- var size int
- for _, elem := range elems {
- size += len(elem)
- }
- if size == 0 {
- return ""
- }
- b.Reset()
- b.Guarantee(size + 1)
- for _, elem := range elems {
- if elem == "" {
- continue
- }
- b.append(elem)
- }
- return string(b.B)
-}
-
-// append performs the main logic of 'Append()' but without an empty path check or preallocation.
-func (b *Builder) append(path string) {
- if !b.set {
- // Set if absolute or not
- b.abs = path[0] == '/'
- b.set = true
- } else if !b.abs && len(b.B) == 1 && b.B[0] == '.' {
- // Empty non-abs path segment, drop
- // the period so not prefixed './'
- b.B = b.B[:0]
- }
-
- for i := 0; 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()
-
- // 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)
- }
-
- default:
- if (b.abs && len(b.B) != 1) || (!b.abs && len(b.B) > 0) {
- // Append path separator
- b.appendByte('/')
- }
-
- // Append slice up to next '/'
- i += b.appendSlice(path[i:])
- }
- }
-
- if len(b.B) > 0 {
- return
- }
-
- if b.abs {
- // Empty absolute path => /
- b.appendByte('/')
- } else {
- // Empty relative path => .
- b.appendByte('.')
- }
-}
-
-// 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 byte slice is *effectively* empty,
-// i.e. absolute and "/" or relative and ".", it won't be truncated.
-func (b *Builder) Truncate(size int) {
- if len(b.B) == 0 {
- return
- }
-
- if len(b.B) == 1 && ((b.abs && b.B[0] == '/') ||
- (!b.abs && b.B[0] == '.')) {
- // *effectively* empty
- return
- }
-
- // Truncate requested bytes
- 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-ffmpreg/LICENSE b/vendor/codeberg.org/gruf/go-ffmpreg/LICENSE
deleted file mode 100644
index f288702d2..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/LICENSE
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<https://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpreg.wasm.gz b/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpreg.wasm.gz
deleted file mode 100644
index f920809c0..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpreg.wasm.gz
+++ /dev/null
Binary files differ
diff --git a/vendor/codeberg.org/gruf/go-ffmpreg/embed/lib.go b/vendor/codeberg.org/gruf/go-ffmpreg/embed/lib.go
deleted file mode 100644
index b39d7d10e..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/embed/lib.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package embed
-
-import (
- "compress/gzip"
- _ "embed"
- "io"
- "strings"
-)
-
-func init() {
- var err error
-
- // Wrap bytes in reader.
- r := strings.NewReader(s)
-
- // Create unzipper from reader.
- gz, err := gzip.NewReader(r)
- if err != nil {
- panic(err)
- }
-
- // Extract gzipped binary.
- b, err := io.ReadAll(gz)
- if err != nil {
- panic(err)
- }
-
- // Set binary.
- s = string(b)
-}
-
-// B returns a copy of
-// embedded binary data.
-func B() []byte {
- if s == "" {
- panic("binary already dropped from memory")
- }
- return []byte(s)
-}
-
-// Free will drop embedded
-// binary from runtime mem.
-func Free() { s = "" }
-
-//go:embed ffmpreg.wasm.gz
-var s string
diff --git a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/funcs.go b/vendor/codeberg.org/gruf/go-ffmpreg/wasm/funcs.go
deleted file mode 100644
index a0a199ca1..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/funcs.go
+++ /dev/null
@@ -1,139 +0,0 @@
-package wasm
-
-import (
- "context"
-
- "github.com/tetratelabs/wazero/api"
- "github.com/tetratelabs/wazero/experimental"
-)
-
-type snapshotskey struct{}
-
-type snapshotctx struct {
- context.Context
- snaps *snapshots
-}
-
-func (ctx snapshotctx) Value(key any) any {
- if _, ok := key.(snapshotskey); ok {
- return ctx.snaps
- }
- return ctx.Context.Value(key)
-}
-
-const ringsz uint = 8
-
-type snapshots struct {
- r [ringsz]struct {
- eptr uint32
- snap experimental.Snapshot
- }
- n uint
-}
-
-func (s *snapshots) get(envptr uint32) experimental.Snapshot {
- start := (s.n % ringsz)
-
- for i := start; i != ^uint(0); i-- {
- if s.r[i].eptr == envptr {
- snap := s.r[i].snap
- s.r[i].eptr = 0
- s.r[i].snap = nil
- s.n = i - 1
- return snap
- }
- }
-
- for i := ringsz - 1; i > start; i-- {
- if s.r[i].eptr == envptr {
- snap := s.r[i].snap
- s.r[i].eptr = 0
- s.r[i].snap = nil
- s.n = i - 1
- return snap
- }
- }
-
- panic("snapshot not found")
-}
-
-func (s *snapshots) set(envptr uint32, snapshot experimental.Snapshot) {
- start := (s.n % ringsz)
-
- for i := start; i < ringsz; i++ {
- switch s.r[i].eptr {
- case 0, envptr:
- s.r[i].eptr = envptr
- s.r[i].snap = snapshot
- s.n = i
- return
- }
- }
-
- for i := uint(0); i < start; i++ {
- switch s.r[i].eptr {
- case 0, envptr:
- s.r[i].eptr = envptr
- s.r[i].snap = snapshot
- s.n = i
- return
- }
- }
-
- panic("snapshots full")
-}
-
-// withSetjmpLongjmp updates the context to contain wazero/experimental.Snapshotter{} support,
-// and embeds the necessary snapshots map required for later calls to Setjmp() / Longjmp().
-func withSetjmpLongjmp(ctx context.Context) context.Context {
- return snapshotctx{Context: experimental.WithSnapshotter(ctx), snaps: new(snapshots)}
-}
-
-func getSnapshots(ctx context.Context) *snapshots {
- v, _ := ctx.Value(snapshotskey{}).(*snapshots)
- return v
-}
-
-// setjmp implements the C function: setjmp(env jmp_buf)
-func setjmp(ctx context.Context, _ api.Module, stack []uint64) {
-
- // Input arguments.
- envptr := api.DecodeU32(stack[0])
-
- // Take snapshot of current execution environment.
- snapshotter := experimental.GetSnapshotter(ctx)
- snapshot := snapshotter.Snapshot()
-
- // Get stored snapshots map.
- snapshots := getSnapshots(ctx)
-
- // Set latest snapshot in map.
- snapshots.set(envptr, snapshot)
-
- // Set return.
- stack[0] = 0
-}
-
-// longjmp implements the C function: int longjmp(env jmp_buf, value int)
-func longjmp(ctx context.Context, _ api.Module, stack []uint64) {
-
- // Input arguments.
- envptr := api.DecodeU32(stack[0])
- // val := stack[1]
-
- // Get stored snapshots map.
- snapshots := getSnapshots(ctx)
- if snapshots == nil {
- panic("setjmp / longjmp not supported")
- }
-
- // Get snapshot stored in map.
- snapshot := snapshots.get(envptr)
-
- // Set return.
- stack[0] = 0
-
- // Restore execution and
- // return passed value arg.
- snapshot.Restore(stack[1:])
-}
diff --git a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/run.go b/vendor/codeberg.org/gruf/go-ffmpreg/wasm/run.go
deleted file mode 100644
index c247abaf0..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/run.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package wasm
-
-import (
- "context"
- "io"
- "unsafe"
-
- "github.com/tetratelabs/wazero"
- "github.com/tetratelabs/wazero/sys"
-)
-
-// Args encompasses a common set of
-// configuration options often passed to
-// wazero.Runtime on module instantiation.
-type Args struct {
-
- // Program name, depending on the
- // module being run this may or may
- // not be necessary.
- Name string
-
- // Optional further module configuration function.
- // (e.g. to mount filesystem dir, set env vars, etc).
- Config func(wazero.ModuleConfig) wazero.ModuleConfig
-
- // Standard FDs.
- Stdin io.Reader
- Stdout io.Writer
- Stderr io.Writer
-
- // CLI args.
- Args []string
-}
-
-// Run will run given compiled WebAssembly module
-// within the given runtime, with given arguments.
-// Returns the exit code, or error.
-func Run(
- ctx context.Context,
- runtime wazero.Runtime,
- module wazero.CompiledModule,
- args Args,
-) (rc uint32, err error) {
-
- // Prefix arguments with module name.
- cargs := make([]string, len(args.Args)+1)
- cargs[0] = args.Name
- copy(cargs[1:], args.Args)
-
- // Prepare new module configuration.
- modcfg := wazero.NewModuleConfig()
- modcfg = modcfg.WithArgs(cargs...)
- modcfg = modcfg.WithStdin(args.Stdin)
- modcfg = modcfg.WithStdout(args.Stdout)
- modcfg = modcfg.WithStderr(args.Stderr)
- modcfg = modcfg.WithName("")
-
- if args.Config != nil {
- // Pass through config fn.
- modcfg = args.Config(modcfg)
- }
-
- // Enable setjmp longjmp.
- ctx = withSetjmpLongjmp(ctx)
-
- // Instantiate the module from precompiled wasm module data.
- mod, err := runtime.InstantiateModule(ctx, module, modcfg)
-
- if !isNil(mod) {
- // Ensure closed.
- _ = mod.Close(ctx)
- }
-
- // Try extract exit code.
- switch err := err.(type) {
- case *sys.ExitError:
- return err.ExitCode(), nil
- default:
- return 0, err
- }
-}
-
-// 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 }
- return (*(*eface)(unsafe.Pointer(&i))).Data == nil
-}
diff --git a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/runtime.go b/vendor/codeberg.org/gruf/go-ffmpreg/wasm/runtime.go
deleted file mode 100644
index 048486ee4..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/runtime.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package wasm
-
-import (
- "context"
-
- "github.com/tetratelabs/wazero"
- "github.com/tetratelabs/wazero/api"
- "github.com/tetratelabs/wazero/experimental"
- "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
-)
-
-// CoreFeatures are the WebAssembly Core specification
-// features our embedded binaries are compiled with.
-const CoreFeatures = api.CoreFeatureSIMD |
- api.CoreFeatureBulkMemoryOperations |
- api.CoreFeatureNonTrappingFloatToIntConversion |
- api.CoreFeatureMutableGlobal |
- api.CoreFeatureReferenceTypes |
- api.CoreFeatureSignExtensionOps |
- experimental.CoreFeaturesTailCall
-
-// NewRuntime returns a new WebAssembly wazero.Runtime compatible with go-ffmpreg.
-func NewRuntime(ctx context.Context, cfg wazero.RuntimeConfig) (wazero.Runtime, error) {
- var err error
-
- if cfg == nil {
- // Ensure runtime config is set.
- cfg = wazero.NewRuntimeConfig()
- }
-
- // Set core features ffmpeg compiled with.
- cfg = cfg.WithCoreFeatures(CoreFeatures)
- cfg = cfg.WithDebugInfoEnabled(false)
-
- // Instantiate runtime with prepared config.
- rt := wazero.NewRuntimeWithConfig(ctx, cfg)
-
- // Prepare default "env" host module.
- env := rt.NewHostModuleBuilder("env")
-
- // Register setjmp host function.
- env = env.NewFunctionBuilder().
- WithGoModuleFunction(
- api.GoModuleFunc(setjmp),
- []api.ValueType{api.ValueTypeI32, api.ValueTypeI32, api.ValueTypeI32},
- []api.ValueType{},
- ).Export("__wasm_setjmp")
-
- // Register longjmp host function.
- env = env.NewFunctionBuilder().
- WithGoModuleFunction(
- api.GoModuleFunc(longjmp),
- []api.ValueType{api.ValueTypeI32, api.ValueTypeI32},
- []api.ValueType{},
- ).Export("__wasm_longjmp")
-
- // Instantiate "env" module.
- _, err = env.Instantiate(ctx)
- if err != nil {
- return nil, err
- }
-
- // Instantiate the wasi snapshot preview 1 in runtime.
- _, err = wasi_snapshot_preview1.Instantiate(ctx, rt)
- if err != nil {
- return nil, err
- }
-
- return rt, nil
-}
diff --git a/vendor/codeberg.org/gruf/go-iotools/LICENSE b/vendor/codeberg.org/gruf/go-iotools/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-iotools/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-iotools/close.go b/vendor/codeberg.org/gruf/go-iotools/close.go
deleted file mode 100644
index f3d4814ba..000000000
--- a/vendor/codeberg.org/gruf/go-iotools/close.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package iotools
-
-import "io"
-
-// NopCloser is an empty
-// implementation of io.Closer,
-// that simply does nothing!
-type NopCloser struct{}
-
-func (NopCloser) Close() error { return nil }
-
-// CloserFunc is a function signature which allows
-// a function to implement the io.Closer type.
-type CloserFunc func() error
-
-func (c CloserFunc) Close() error {
- return c()
-}
-
-// CloserCallback wraps io.Closer to add a callback deferred to call just after Close().
-func CloserCallback(c io.Closer, cb func()) io.Closer {
- return CloserFunc(func() error {
- defer cb()
- return c.Close()
- })
-}
-
-// CloserAfterCallback wraps io.Closer to add a callback called just before Close().
-func CloserAfterCallback(c io.Closer, cb func()) io.Closer {
- return CloserFunc(func() (err error) {
- defer func() { err = c.Close() }()
- cb()
- return
- })
-}
-
-// CloseOnce wraps an io.Closer to ensure it only performs the close logic once.
-func CloseOnce(c io.Closer) io.Closer {
- return CloserFunc(func() error {
- if c == nil {
- // already run.
- return nil
- }
-
- // Acquire.
- cptr := c
- c = nil
-
- // Call the closer.
- return cptr.Close()
- })
-}
diff --git a/vendor/codeberg.org/gruf/go-iotools/helpers.go b/vendor/codeberg.org/gruf/go-iotools/helpers.go
deleted file mode 100644
index 0e50e05e0..000000000
--- a/vendor/codeberg.org/gruf/go-iotools/helpers.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package iotools
-
-import "io"
-
-// AtEOF returns true when reader at EOF,
-// this is checked with a 0 length read.
-func AtEOF(r io.Reader) bool {
- _, err := r.Read(nil)
- return (err == io.EOF)
-}
-
-// GetReadCloserLimit attempts to cast io.Reader to access its io.LimitedReader with limit.
-func GetReaderLimit(r io.Reader) (*io.LimitedReader, int64) {
- lr, ok := r.(*io.LimitedReader)
- if !ok {
- return nil, -1
- }
- return lr, lr.N
-}
-
-// UpdateReaderLimit attempts to update the limit of a reader for existing, newly wrapping if necessary.
-func UpdateReaderLimit(r io.Reader, limit int64) (*io.LimitedReader, int64) {
- lr, ok := r.(*io.LimitedReader)
- if !ok {
- lr = &io.LimitedReader{r, limit}
- return lr, limit
- }
-
- if limit < lr.N {
- // Update existing.
- lr.N = limit
- }
-
- return lr, lr.N
-}
-
-// GetReadCloserLimit attempts to unwrap io.ReadCloser to access its io.LimitedReader with limit.
-func GetReadCloserLimit(rc io.ReadCloser) (*io.LimitedReader, int64) {
- rct, ok := rc.(*ReadCloserType)
- if !ok {
- return nil, -1
- }
- lr, ok := rct.Reader.(*io.LimitedReader)
- if !ok {
- return nil, -1
- }
- return lr, lr.N
-}
-
-// UpdateReadCloserLimit attempts to update the limit of a readcloser for existing, newly wrapping if necessary.
-func UpdateReadCloserLimit(rc io.ReadCloser, limit int64) (io.ReadCloser, *io.LimitedReader, int64) {
-
- // Check for our wrapped ReadCloserType.
- if rct, ok := rc.(*ReadCloserType); ok {
-
- // Attempt to update existing wrapped limit reader.
- if lr, ok := rct.Reader.(*io.LimitedReader); ok {
-
- if limit < lr.N {
- // Update existing.
- lr.N = limit
- }
-
- return rct, lr, lr.N
- }
-
- // Wrap the reader type with new limit.
- lr := &io.LimitedReader{rct.Reader, limit}
- rct.Reader = lr
-
- return rct, lr, lr.N
- }
-
- // Wrap separated types.
- rct := &ReadCloserType{
- Reader: rc,
- Closer: rc,
- }
-
- // Wrap separated reader part with limit.
- lr := &io.LimitedReader{rct.Reader, limit}
- rct.Reader = lr
-
- return rct, lr, lr.N
-}
diff --git a/vendor/codeberg.org/gruf/go-iotools/read.go b/vendor/codeberg.org/gruf/go-iotools/read.go
deleted file mode 100644
index 13c5e21ac..000000000
--- a/vendor/codeberg.org/gruf/go-iotools/read.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package iotools
-
-import (
- "io"
-)
-
-// ReadCloserType implements io.ReadCloser
-// by combining the two underlying interfaces,
-// while providing an exported type to still
-// access the underlying original io.Reader or
-// io.Closer separately (e.g. without wrapping).
-type ReadCloserType struct {
- io.Reader
- io.Closer
-}
-
-// ReaderFunc is a function signature which allows
-// a function to implement the io.Reader type.
-type ReaderFunc func([]byte) (int, error)
-
-func (r ReaderFunc) Read(b []byte) (int, error) {
- return r(b)
-}
-
-// ReaderFromFunc is a function signature which allows
-// a function to implement the io.ReaderFrom type.
-type ReaderFromFunc func(io.Reader) (int64, error)
-
-func (rf ReaderFromFunc) ReadFrom(r io.Reader) (int64, error) {
- return rf(r)
-}
-
-// ReadCloser wraps an io.Reader and io.Closer in order to implement io.ReadCloser.
-func ReadCloser(r io.Reader, c io.Closer) io.ReadCloser {
- return &ReadCloserType{r, c}
-}
-
-// NopReadCloser wraps io.Reader with NopCloser{} in ReadCloserType.
-func NopReadCloser(r io.Reader) io.ReadCloser {
- return &ReadCloserType{r, NopCloser{}}
-}
diff --git a/vendor/codeberg.org/gruf/go-iotools/size.go b/vendor/codeberg.org/gruf/go-iotools/size.go
deleted file mode 100644
index f3841facf..000000000
--- a/vendor/codeberg.org/gruf/go-iotools/size.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package iotools
-
-type Sizer interface {
- Size() int64
-}
-
-// SizerFunc is a function signature which allows
-// a function to implement the Sizer type.
-type SizerFunc func() int64
-
-func (s SizerFunc) Size() int64 {
- return s()
-}
-
-type Lengther interface {
- Len() int
-}
-
-// LengthFunc is a function signature which allows
-// a function to implement the Lengther type.
-type LengthFunc func() int
-
-func (l LengthFunc) Len() int {
- return l()
-}
diff --git a/vendor/codeberg.org/gruf/go-iotools/write.go b/vendor/codeberg.org/gruf/go-iotools/write.go
deleted file mode 100644
index 2037c42af..000000000
--- a/vendor/codeberg.org/gruf/go-iotools/write.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package iotools
-
-import "io"
-
-// WriterFunc is a function signature which allows
-// a function to implement the io.Writer type.
-type WriterFunc func([]byte) (int, error)
-
-func (w WriterFunc) Write(b []byte) (int, error) {
- return w(b)
-}
-
-// WriterToFunc is a function signature which allows
-// a function to implement the io.WriterTo type.
-type WriterToFunc func(io.Writer) (int64, error)
-
-func (wt WriterToFunc) WriteTo(r io.Writer) (int64, error) {
- return wt(r)
-}
-
-// WriteCloser wraps an io.Writer and io.Closer in order to implement io.WriteCloser.
-func WriteCloser(w io.Writer, c io.Closer) io.WriteCloser {
- return &struct {
- io.Writer
- io.Closer
- }{w, c}
-}
-
-// NopWriteCloser wraps an io.Writer to implement io.WriteCloser with empty io.Closer implementation.
-func NopWriteCloser(w io.Writer) io.WriteCloser {
- return &nopWriteCloser{w}
-}
-
-// nopWriteCloser implements io.WriteCloser with a no-op Close().
-type nopWriteCloser struct{ io.Writer }
-
-func (wc *nopWriteCloser) Close() error { return nil }
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 ca66d2fd3..000000000
--- a/vendor/codeberg.org/gruf/go-kv/README.md
+++ /dev/null
@@ -1,36 +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:
-```
-grufwub @ ~/Projects/main/go-kv
---> go test -run=none -benchmem -bench=.*
-goos: linux
-goarch: amd64
-pkg: codeberg.org/gruf/go-kv
-cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
-BenchmarkFieldAppendMulti-8 125241 9389 ns/op 849 B/op 98 allocs/op
-BenchmarkFieldStringMulti-8 113227 10444 ns/op 3029 B/op 120 allocs/op
-BenchmarkFieldFprintfMulti-8 147915 7448 ns/op 1121 B/op 115 allocs/op
-BenchmarkFieldsAppend-8 189126 6255 ns/op 849 B/op 98 allocs/op
-BenchmarkFieldsString-8 166219 6517 ns/op 3798 B/op 100 allocs/op
-PASS
-ok codeberg.org/gruf/go-kv 6.169s
-
-grufwub @ ~/Projects/main/go-kv
---> go test -run=none -benchmem -bench=.* -tags=kvformat
-goos: linux
-goarch: amd64
-pkg: codeberg.org/gruf/go-kv
-cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
-BenchmarkFieldAppendMulti-8 190161 5709 ns/op 592 B/op 56 allocs/op
-BenchmarkFieldStringMulti-8 161763 7930 ns/op 3240 B/op 95 allocs/op
-BenchmarkFieldFprintfMulti-8 181557 6207 ns/op 1120 B/op 115 allocs/op
-BenchmarkFieldsAppend-8 247052 4580 ns/op 592 B/op 56 allocs/op
-BenchmarkFieldsString-8 231235 5103 ns/op 1768 B/op 58 allocs/op
-PASS
-ok codeberg.org/gruf/go-kv 6.134s
-```
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 06c2b2573..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)}
- AppendQuoteString(&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 5d6e77f4b..000000000
--- a/vendor/codeberg.org/gruf/go-kv/field_fmt.go
+++ /dev/null
@@ -1,63 +0,0 @@
-//go:build !kvformat
-// +build !kvformat
-
-package kv
-
-import (
- "fmt"
- "sync"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-// bufPool is a memory pool of byte buffers.
-var bufPool = sync.Pool{
- New: func() interface{} {
- return &byteutil.Buffer{B: make([]byte, 0, 512)}
- },
-}
-
-// 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`
- }
- AppendQuoteString(buf, f.K)
- buf.WriteByte('=')
- appendValuef(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 = `%#v`
- } else /* regular */ {
- fmtstr = `%+v`
- }
- buf := byteutil.Buffer{B: make([]byte, 0, bufsize/2)}
- appendValuef(&buf, fmtstr, f.V)
- return buf.String()
-}
-
-// appendValuef appends a quoted value string (formatted by fmt.Appendf) to 'buf'.
-func appendValuef(buf *byteutil.Buffer, format string, args ...interface{}) {
- // Write format string to a byte buffer
- fmtbuf := bufPool.Get().(*byteutil.Buffer)
- fmtbuf.B = fmt.Appendf(fmtbuf.B, format, args...)
-
- // Append quoted value to dst buffer
- AppendQuoteValue(buf, fmtbuf.String())
-
- // Drop overly large capacity buffers
- if fmtbuf.Cap() > int(^uint16(0)) {
- return
- }
-
- // Replace buffer in pool
- fmtbuf.Reset()
- bufPool.Put(fmtbuf)
-}
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 f27c28ebd..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}"
- }
- AppendQuoteString(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 f27e229ef..000000000
--- a/vendor/codeberg.org/gruf/go-kv/format/README.md
+++ /dev/null
@@ -1,4 +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.
-
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 cd0b574ea..000000000
--- a/vendor/codeberg.org/gruf/go-kv/format/format.go
+++ /dev/null
@@ -1,896 +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()
-
- // Quoted only if spaces/requires escaping
- case f.Key():
- s := byteutil.B2S(b)
- f.AppendStringSafe(s)
-
- // 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)
- }
- })
-
- // Quoted only if spaces/requires escaping
- case f.Value():
- s := byteutil.B2S(b)
- f.AppendStringSafe(s)
-
- // 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()
-
- // Quoted only if spaces/requires escaping
- case f.Key():
- f.AppendStringSafe(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)
- }
- })
-
- // Quoted only if spaces/requires escaping
- case f.Value():
- f.AppendStringSafe(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.AppendStringSafe(s)
-
- // Always quoted with type
- case f.Verbose():
- f._AppendPrimitiveTyped(func(f format) {
- f.AppendStringQuoted(s)
- })
-
- // Quoted only if spaces/requires escaping
- case f.Value():
- f.AppendStringSafe(s)
-
- // All else
- default:
- f.Buffer.B = append(f.Buffer.B, s...)
- }
-}
-
-func (f format) AppendStringSafe(s string) {
- if len(s) > SingleTermLine || !IsSafeASCII(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 if len(s) == 0 || ContainsSpaceOrTab(s) {
- // Contains space / empty, 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 len(s) > SingleTermLine || !IsSafeASCII(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.AppendStringSafe(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.AppendStringSafe(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, '}')
-}
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 dbb918952..000000000
--- a/vendor/codeberg.org/gruf/go-kv/format/util.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package format
-
-import (
- "strings"
- "unsafe"
-)
-
-const (
- // SingleTermLine: beyond a certain length of string, all of the
- // extra checks to handle quoting/not-quoting add a significant
- // amount of extra processing time. Quoting in this manner only really
- // effects readability on a single line, so a max string length that
- // encompasses the maximum number of columns on *most* terminals was
- // selected. This was chosen using the metric that 1080p is one of the
- // most common display resolutions, and that a relatively small font size
- // of 7 requires 223 columns. So 256 should be >= $COLUMNS (fullscreen)
- // in 99% of usecases (these figures all pulled out of my ass).
- SingleTermLine = 256
-)
-
-// IsSafeASCII checks whether string is printable (i.e. non-control char) ASCII text.
-func IsSafeASCII(str string) bool {
- for _, r := range str {
- if (r < ' ' && r != '\t') ||
- r >= 0x7f {
- return false
- }
- }
- return true
-}
-
-// ContainsSpaceOrTab checks if "s" contains space or tabs. EXPECTS ASCII.
-func ContainsSpaceOrTab(s string) bool {
- if i := strings.IndexByte(s, ' '); i >= 0 {
- return true // note using indexbyte as it is ASM.
- } else if i := strings.IndexByte(s, '\t'); i >= 0 {
- return true
- }
- return false
-}
-
-// ContainsDoubleQuote checks if "s" contains a double quote. EXPECTS ASCII.
-func ContainsDoubleQuote(s string) bool {
- return (strings.IndexByte(s, '"') >= 0)
-}
-
-// AppendEscape will append 's' to 'dst' and escape any double quotes. EXPECTS ASCII.
-func AppendEscape(dst []byte, str string) []byte {
- for i := range str {
- switch str[i] {
- case '\\':
- // Append delimited '\'
- dst = append(dst, '\\', '\\')
-
- case '"':
- // Append delimited '"'
- dst = append(dst, '\\', '"')
- default:
- // Append char as-is
- dst = append(dst, str[i])
- }
- }
- return dst
-}
-
-// 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)
- }
-}
-
-// 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
-}
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 c0c8ccdab..000000000
--- a/vendor/codeberg.org/gruf/go-kv/util.go
+++ /dev/null
@@ -1,151 +0,0 @@
-package kv
-
-import (
- "strconv"
- "strings"
-
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-kv/format"
-)
-
-// AppendQuoteString will append (and escape/quote where necessary) a field string.
-func AppendQuoteString(buf *byteutil.Buffer, str string) {
- switch {
- case len(str) == 0:
- // Append empty quotes.
- buf.B = append(buf.B, `""`...)
- return
-
- case len(str) == 1:
- // Append quote single byte.
- buf.B = append(buf.B, '\'')
- buf.B = append(buf.B, format.Byte2Str(str[0])...)
- buf.B = append(buf.B, '\'')
- return
-
- case len(str) > format.SingleTermLine || !format.IsSafeASCII(str):
- // Long line or contains non-ascii chars.
- buf.B = strconv.AppendQuote(buf.B, str)
- return
-
- case !isQuoted(str):
- // Not single/double quoted already.
-
- if format.ContainsSpaceOrTab(str) {
- // Quote un-enclosed spaces.
- buf.B = append(buf.B, '"')
- buf.B = append(buf.B, str...)
- buf.B = append(buf.B, '"')
- return
- }
-
- if format.ContainsDoubleQuote(str) {
- // Contains double quote, double quote
- // and append escaped existing.
- buf.B = append(buf.B, '"')
- buf.B = format.AppendEscape(buf.B, str)
- buf.B = append(buf.B, '"')
- return
- }
- }
-
- // Double quoted, enclosed in braces, or
- // literally anything else: append as-is.
- buf.B = append(buf.B, str...)
- return
-}
-
-// AppendQuoteValue will append (and escape/quote where necessary) a formatted value string.
-func AppendQuoteValue(buf *byteutil.Buffer, str string) {
- switch {
- case len(str) == 0:
- // Append empty quotes.
- buf.B = append(buf.B, `""`...)
- return
-
- case len(str) == 1:
- // Append quote single byte.
- buf.B = append(buf.B, '\'')
- buf.B = append(buf.B, format.Byte2Str(str[0])...)
- buf.B = append(buf.B, '\'')
- return
-
- case len(str) > format.SingleTermLine || !format.IsSafeASCII(str):
- // Long line or contains non-ascii chars.
- buf.B = strconv.AppendQuote(buf.B, str)
- return
-
- case !isQuoted(str):
- // Not single/double quoted already.
-
- // Get space / tab indices (if any).
- s := strings.IndexByte(str, ' ')
- t := strings.IndexByte(str, '\t')
-
- // Find first whitespace.
- sp0 := smallest(s, t)
- if sp0 < 0 {
- break
- }
-
- // Check if str is enclosed by braces.
- // (but without any key-value separator).
- if (enclosedBy(str, sp0, '{', '}') ||
- enclosedBy(str, sp0, '[', ']') ||
- enclosedBy(str, sp0, '(', ')')) &&
- strings.IndexByte(str, '=') < 0 {
- break
- }
-
- if format.ContainsDoubleQuote(str) {
- // Contains double quote, double quote
- // and append escaped existing.
- buf.B = append(buf.B, '"')
- buf.B = format.AppendEscape(buf.B, str)
- buf.B = append(buf.B, '"')
- return
- }
-
- // Quote un-enclosed spaces.
- buf.B = append(buf.B, '"')
- buf.B = append(buf.B, str...)
- buf.B = append(buf.B, '"')
- return
- }
-
- // Double quoted, enclosed in braces, or
- // literally anything else: append as-is.
- buf.B = append(buf.B, str...)
- return
-}
-
-// isQuoted checks if string is single or double quoted.
-func isQuoted(str string) bool {
- return (str[0] == '"' && str[len(str)-1] == '"') ||
- (str[0] == '\'' && str[len(str)-1] == '\'')
-}
-
-// smallest attempts to return the smallest positive value of those given.
-func smallest(i1, i2 int) int {
- if i1 >= 0 && (i2 < 0 || i1 < i2) {
- return i1
- }
- return i2
-}
-
-// enclosedBy will check if given string is enclosed by end, and at least non-whitespace up to start.
-func enclosedBy(str string, sp int, start, end byte) bool {
- // Check for ending char in string.
- if str[len(str)-1] != end {
- return false
- }
-
- // Check for starting char in string.
- i := strings.IndexByte(str, start)
- if i < 0 {
- return false
- }
-
- // Check before space.
- return i < sp
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/LICENSE b/vendor/codeberg.org/gruf/go-kv/v2/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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/v2/README.md b/vendor/codeberg.org/gruf/go-kv/v2/README.md
deleted file mode 100644
index 2815f1c83..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/README.md
+++ /dev/null
@@ -1,5 +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 more performant 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/`.
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/field.go b/vendor/codeberg.org/gruf/go-kv/v2/field.go
deleted file mode 100644
index 58399e4a9..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/field.go
+++ /dev/null
@@ -1,103 +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)}
- AppendQuoteString(&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.
-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/v2/field_fmt.go b/vendor/codeberg.org/gruf/go-kv/v2/field_fmt.go
deleted file mode 100644
index 5d6e77f4b..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/field_fmt.go
+++ /dev/null
@@ -1,63 +0,0 @@
-//go:build !kvformat
-// +build !kvformat
-
-package kv
-
-import (
- "fmt"
- "sync"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-// bufPool is a memory pool of byte buffers.
-var bufPool = sync.Pool{
- New: func() interface{} {
- return &byteutil.Buffer{B: make([]byte, 0, 512)}
- },
-}
-
-// 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`
- }
- AppendQuoteString(buf, f.K)
- buf.WriteByte('=')
- appendValuef(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 = `%#v`
- } else /* regular */ {
- fmtstr = `%+v`
- }
- buf := byteutil.Buffer{B: make([]byte, 0, bufsize/2)}
- appendValuef(&buf, fmtstr, f.V)
- return buf.String()
-}
-
-// appendValuef appends a quoted value string (formatted by fmt.Appendf) to 'buf'.
-func appendValuef(buf *byteutil.Buffer, format string, args ...interface{}) {
- // Write format string to a byte buffer
- fmtbuf := bufPool.Get().(*byteutil.Buffer)
- fmtbuf.B = fmt.Appendf(fmtbuf.B, format, args...)
-
- // Append quoted value to dst buffer
- AppendQuoteValue(buf, fmtbuf.String())
-
- // Drop overly large capacity buffers
- if fmtbuf.Cap() > int(^uint16(0)) {
- return
- }
-
- // Replace buffer in pool
- fmtbuf.Reset()
- bufPool.Put(fmtbuf)
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/field_format.go b/vendor/codeberg.org/gruf/go-kv/v2/field_format.go
deleted file mode 100644
index f5db0f123..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/field_format.go
+++ /dev/null
@@ -1,44 +0,0 @@
-//go:build kvformat
-// +build kvformat
-
-package kv
-
-import (
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-kv/v2/format"
-)
-
-var argsDefault = format.DefaultArgs()
-
-var argsVerbose = func() format.Args {
- args := format.DefaultArgs()
- args.SetWithType()
- args.SetNoMethod()
- return args
-}()
-
-// AppendFormat will append formatted format of Field to 'buf'. See .String() for details.
-func (f Field) AppendFormat(buf *byteutil.Buffer, vbose bool) {
- var args format.Args
- if vbose {
- args = argsVerbose
- } else {
- args = argsDefault
- }
- AppendQuoteString(buf, f.K)
- buf.WriteByte('=')
- buf.B = format.Global.Append(buf.B, f.V, args)
-}
-
-// Value returns the formatted value string of this Field.
-func (f Field) Value(vbose bool) string {
- var args format.Args
- if vbose {
- args = argsVerbose
- } else {
- args = argsDefault
- }
- buf := make([]byte, 0, bufsize/2)
- buf = format.Global.Append(buf, f.V, args)
- return byteutil.B2S(buf)
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/README.md b/vendor/codeberg.org/gruf/go-kv/v2/format/README.md
deleted file mode 100644
index 5d11cc6b9..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# format
-
-a low-level string formatting library that takes arbitrary input types as interfaces, and arguments as a struct. this does not contain any printf-like argument parsing, only log-friendly serialization of arbitrary input arguments. (noting that our output is noticably more log-friendly for struct / map types than stdlib "fmt").
-
-benchmarks:
-```shell
-goos: linux
-goarch: amd64
-pkg: codeberg.org/gruf/go-kv/v2/format
-cpu: AMD Ryzen 7 7840U w/ Radeon 780M Graphics
-
-# go-kv/v2/format (i.e. latest)
-BenchmarkFormatV2Append
-BenchmarkFormatV2Append-16 590422 1977 ns/op 488 B/op 23 allocs/op
-BenchmarkFormatV2AppendVerbose
-BenchmarkFormatV2AppendVerbose-16 375628 2981 ns/op 1704 B/op 45 allocs/op
-
-# go-kv/format (i.e. v1)
-BenchmarkFormatAppend
-BenchmarkFormatAppend-16 208357 5883 ns/op 2624 B/op 169 allocs/op
-BenchmarkFormatAppendVerbose
-BenchmarkFormatAppendVerbose-16 35916 33563 ns/op 3734 B/op 208 allocs/op
-
-# fmt (i.e. stdlib)
-BenchmarkFmtAppend
-BenchmarkFmtAppend-16 147722 8418 ns/op 4747 B/op 191 allocs/op
-BenchmarkFmtAppendVerbose
-BenchmarkFmtAppendVerbose-16 167112 7238 ns/op 4401 B/op 178 allocs/op
-
-PASS
-ok codeberg.org/gruf/go-kv/v2/format
-```
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/abi.go b/vendor/codeberg.org/gruf/go-kv/v2/format/abi.go
deleted file mode 100644
index 16b9c8cb9..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/abi.go
+++ /dev/null
@@ -1,25 +0,0 @@
-//go:build go1.24 && !go1.26
-
-package format
-
-import (
- "reflect"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// add returns the ptr addition of starting ptr and a delta.
-func add(ptr unsafe.Pointer, delta uintptr) unsafe.Pointer {
- return unsafe.Pointer(uintptr(ptr) + delta)
-}
-
-// typeof is short-hand for reflect.TypeFor[T]().
-func typeof[T any]() reflect.Type {
- return reflect.TypeFor[T]()
-}
-
-const (
- // custom xunsafe.Reflect_flag to indicate key types.
- flagKeyType xunsafe.Reflect_flag = 1 << 10
-)
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/args.go b/vendor/codeberg.org/gruf/go-kv/v2/format/args.go
deleted file mode 100644
index c85a04d26..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/args.go
+++ /dev/null
@@ -1,247 +0,0 @@
-package format
-
-const (
- // TypeMask when set in argument flags
- // indicates that type information of
- // the passed value, and all nested types,
- // should be included in formatted output.
- TypeMask = uint64(1) << 0
-
- // LogfmtMask when set in argument flags
- // indicates that strings should be escaped
- // and quoted only where necessary. i.e. if
- // it contains any unsafe ASCII chars or double
- // quotes it will be quoted and escaped, if it
- // contains any spaces it will be quoted, and
- // all else will be printed as-is. This proves
- // particularly well readable in key-value types.
- LogfmtMask = uint64(1) << 1
-
- // NumberMask when set in argument flags
- // indicates that where possible value
- // types should be formatted as numbers,
- // i.e. byte or rune types.
- NumberMask = uint64(1) << 2
-
- // TextMask when set in argument flags
- // indicates that where possible value
- // types should be formatted as text,
- // i.e. []byte or []rune types.
- TextMask = uint64(1) << 3
-
- // QuotedTextMask when set in argument flags
- // indicates that text should always be quoted.
- QuotedTextMask = uint64(1) << 4
-
- // QuotedAsciiMask when set in argument flags
- // indicates that text should always be quoted,
- // and escaped as ASCII characters where needed.
- QuotedAsciiMask = uint64(1) << 5
-
- // NoMethodMask when set in argument flags
- // indicates that where a type supports a
- // known method, (e.g. Error() or String()),
- // this should not be used for formatting
- // instead treating as a method-less type.
- // e.g. printing the entire struct value of
- // a &url.URL{} without calling String().
- NoMethodMask = uint64(1) << 6
-)
-
-var (
- // default set of Args.
- defaultArgs = Args{
- Flags: LogfmtMask | TextMask,
- Int: IntArgs{Base: 10},
- Uint: IntArgs{Base: 10},
- Float: FloatArgs{Fmt: 'g', Prec: -1},
- Complex: ComplexArgs{
- Real: FloatArgs{Fmt: 'g', Prec: -1},
- Imag: FloatArgs{Fmt: 'g', Prec: -1},
- },
- }
-
- // zeroArgs used for checking
- // zero value Arg{} fields.
- zeroArgs Args
-)
-
-// DefaultArgs returns default
-// set of formatter arguments.
-func DefaultArgs() Args {
- return defaultArgs
-}
-
-// Args contains arguments
-// for a call to a FormatFunc.
-type Args struct {
-
- // Boolean argument
- // flags as bit-field.
- Flags uint64
-
- // Integer
- // arguments.
- // i.e. for:
- // - int
- // - int8
- // - int16
- // - int32 (treated as rune char, number with NumberMask)
- // - int64
- Int IntArgs
-
- // Unsigned
- // integer
- // arguments.
- // i.e. for:
- // - uint
- // - uint8 (treated as byte char, number with NumberMask)
- // - uint16
- // - uint32
- // - uint64
- Uint IntArgs
-
- // Float
- // arguments.
- // i.e. for:
- // - float32
- // - float64
- Float FloatArgs
-
- // Complex
- // arguments.
- // i.e. for:
- // - complex64
- // - complex128
- Complex ComplexArgs
-}
-
-// IntArgs provides a set of
-// arguments for customizing
-// integer number serialization.
-type IntArgs struct {
- Base int
- Pad int
-}
-
-// FloatArgs provides a set of
-// arguments for customizing
-// float number serialization.
-type FloatArgs struct {
- Fmt byte
- Prec int
-}
-
-// ComplexArgs provides a set of
-// arguments for customizing complex
-// number serialization, as real and
-// imaginary float number parts.
-type ComplexArgs struct {
- Real FloatArgs
- Imag FloatArgs
-}
-
-// WithType returns if TypeMask is set.
-func (a *Args) WithType() bool {
- return a.Flags&TypeMask != 0
-}
-
-// Logfmt returns if LogfmtMask is set.
-func (a *Args) Logfmt() bool {
- return a.Flags&LogfmtMask != 0
-}
-
-// AsNumber returns if NumberMask is set.
-func (a *Args) AsNumber() bool {
- return a.Flags&NumberMask != 0
-}
-
-// AsText returns if TextMask is set.
-func (a *Args) AsText() bool {
- return a.Flags&TextMask != 0
-}
-
-// AsQuotedText returns if QuotedTextMask is set.
-func (a *Args) AsQuotedText() bool {
- return a.Flags&QuotedTextMask != 0
-}
-
-// AsQuotedASCII returns if QuotedAsciiMask is set.
-func (a *Args) AsQuotedASCII() bool {
- return a.Flags&QuotedAsciiMask != 0
-}
-
-// NoMethod returns if NoMethodMask is set.
-func (a *Args) NoMethod() bool {
- return a.Flags&NoMethodMask != 0
-}
-
-// SetWithType sets the TypeMask bit.
-func (a *Args) SetWithType() {
- a.Flags = a.Flags | TypeMask
-}
-
-// SetLogfmt sets the LogfmtMask bit.
-func (a *Args) SetLogfmt() {
- a.Flags = a.Flags | LogfmtMask
-}
-
-// SetAsNumber sets the NumberMask bit.
-func (a *Args) SetAsNumber() {
- a.Flags = a.Flags | NumberMask
-}
-
-// SetAsText sets the TextMask bit.
-func (a *Args) SetAsText() {
- a.Flags = a.Flags | TextMask
-}
-
-// SetAsQuotedText sets the QuotedTextMask bit.
-func (a *Args) SetAsQuotedText() {
- a.Flags = a.Flags | QuotedTextMask
-}
-
-// SetAsQuotedASCII sets the QuotedAsciiMask bit.
-func (a *Args) SetAsQuotedASCII() {
- a.Flags = a.Flags | QuotedAsciiMask
-}
-
-// SetNoMethod sets the NoMethodMask bit.
-func (a *Args) SetNoMethod() {
- a.Flags = a.Flags | NoMethodMask
-}
-
-// UnsetWithType unsets the TypeMask bit.
-func (a *Args) UnsetWithType() {
- a.Flags = a.Flags & ^TypeMask
-}
-
-// UnsetLogfmt unsets the LogfmtMask bit.
-func (a *Args) UnsetLogfmt() {
- a.Flags = a.Flags & ^LogfmtMask
-}
-
-// UnsetAsNumber unsets the NumberMask bit.
-func (a *Args) UnsetAsNumber() {
- a.Flags = a.Flags & ^NumberMask
-}
-
-// UnsetAsText unsets the TextMask bit.
-func (a *Args) UnsetAsText() {
- a.Flags = a.Flags & ^TextMask
-}
-
-// UnsetAsQuotedText unsets the QuotedTextMask bit.
-func (a *Args) UnsetAsQuotedText() {
- a.Flags = a.Flags & ^QuotedTextMask
-}
-
-// UnsetAsQuotedASCII unsets the QuotedAsciiMask bit.
-func (a *Args) UnsetAsQuotedASCII() {
- a.Flags = a.Flags & ^QuotedAsciiMask
-}
-
-// UnsetNoMethod unsets the NoMethodMask bit.
-func (a *Args) UnsetNoMethod() {
- a.Flags = a.Flags & ^NoMethodMask
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/array.go b/vendor/codeberg.org/gruf/go-kv/v2/format/array.go
deleted file mode 100644
index 1ece16378..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/array.go
+++ /dev/null
@@ -1,235 +0,0 @@
-package format
-
-import (
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// iterArrayType returns a FormatFunc capable of iterating
-// and formatting the given array type currently in TypeIter{}.
-// note this will fetch a sub-FormatFunc for the array element
-// type, and also handle special cases of [n]byte, [n]rune arrays.
-func (fmt *Formatter) iterArrayType(t xunsafe.TypeIter) FormatFunc {
-
- // Array element type.
- elem := t.Type.Elem()
-
- // Get nested elem TypeIter with appropriate flags.
- flags := xunsafe.ReflectArrayElemFlags(t.Flag, elem)
- et := t.Child(elem, flags)
-
- // Get elem format func.
- fn := fmt.loadOrGet(et)
- if fn == nil {
- panic("unreachable")
- }
-
- // Handle possible sizes.
- switch t.Type.Len() {
- case 0:
- return emptyArrayType(t)
- case 1:
- return iterSingleArrayType(t, fn)
- default:
- return iterMultiArrayType(t, fn)
- }
-}
-
-func emptyArrayType(t xunsafe.TypeIter) FormatFunc {
- if !needs_typestr(t) {
- // Simply append empty.
- return func(s *State) {
- s.B = append(s.B, "[]"...)
- }
- }
-
- // Array type string with refs.
- typestr := typestr_with_refs(t)
-
- // Append empty with type.
- return func(s *State) {
- if s.A.WithType() {
- s.B = append(s.B, typestr...)
- s.B = append(s.B, "{}"...)
- } else {
- s.B = append(s.B, "[]"...)
- }
- }
-}
-
-func iterSingleArrayType(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
- if !needs_typestr(t) {
- return func(s *State) {
- // Wrap 'fn' in braces.
- s.B = append(s.B, '[')
- fn(s)
- s.B = append(s.B, ']')
- }
- }
-
- // Array type string with refs.
- typestr := typestr_with_refs(t)
-
- // Wrap in type+braces.
- return func(s *State) {
-
- // Open / close braces.
- var open, close uint8
- open, close = '[', ']'
-
- // Include type info.
- if s.A.WithType() {
- s.B = append(s.B, typestr...)
- open, close = '{', '}'
- }
-
- // Wrap 'fn' in braces.
- s.B = append(s.B, open)
- fn(s)
- s.B = append(s.B, close)
- }
-}
-
-func iterMultiArrayType(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
- // Array element in-memory size.
- esz := t.Type.Elem().Size()
-
- // Number of elements.
- n := t.Type.Len()
-
- if !needs_typestr(t) {
- // Wrap elems in braces.
- return func(s *State) {
- ptr := s.P
-
- // Prepend array brace.
- s.B = append(s.B, '[')
-
- for i := 0; i < n; i++ {
- // Format at array index.
- offset := esz * uintptr(i)
- s.P = add(ptr, offset)
- fn(s)
-
- // Append separator.
- s.B = append(s.B, ',')
- }
-
- // Drop final space.
- s.B = s.B[:len(s.B)-1]
-
- // Prepend array brace.
- s.B = append(s.B, ']')
- }
- }
-
- // Array type string with refs.
- typestr := typestr_with_refs(t)
-
- // Wrap in type+braces.
- return func(s *State) {
- ptr := s.P
-
- // Open / close braces.
- var open, close uint8
- open, close = '[', ']'
-
- // Include type info.
- if s.A.WithType() {
- s.B = append(s.B, typestr...)
- open, close = '{', '}'
- }
-
- // Prepend array brace.
- s.B = append(s.B, open)
-
- for i := 0; i < n; i++ {
- // Format at array index.
- offset := esz * uintptr(i)
- s.P = add(ptr, offset)
- fn(s)
-
- // Append separator.
- s.B = append(s.B, ',')
- }
-
- // Drop final comma.
- s.B = s.B[:len(s.B)-1]
-
- // Prepend array brace.
- s.B = append(s.B, close)
- }
-}
-
-func wrapByteArray(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
- n := t.Type.Len()
- if !needs_typestr(t) {
- return func(s *State) {
- if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
- var v string
- p := (*xunsafe.Unsafeheader_String)(unsafe.Pointer(&v))
- p.Len = n
- p.Data = s.P
- appendString(s, v)
- } else {
- fn(s)
- }
- }
- }
- typestr := typestr_with_ptrs(t)
- return func(s *State) {
- if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
- var v string
- p := (*xunsafe.Unsafeheader_String)(unsafe.Pointer(&v))
- p.Len = n
- p.Data = s.P
- if s.A.WithType() {
- s.B = append(s.B, "("+typestr+")("...)
- appendString(s, v)
- s.B = append(s.B, ")"...)
- } else {
- appendString(s, v)
- }
- } else {
- fn(s)
- }
- }
-}
-
-func wrapRuneArray(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
- n := t.Type.Len()
- if !needs_typestr(t) {
- return func(s *State) {
- if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
- var v []rune
- p := (*xunsafe.Unsafeheader_Slice)(unsafe.Pointer(&v))
- p.Cap = n
- p.Len = n
- p.Data = s.P
- appendString(s, string(v))
- } else {
- fn(s)
- }
- }
- }
- typestr := typestr_with_ptrs(t)
- return func(s *State) {
- if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
- var v []rune
- p := (*xunsafe.Unsafeheader_Slice)(unsafe.Pointer(&v))
- p.Cap = n
- p.Len = n
- p.Data = s.P
- if s.A.WithType() {
- s.B = append(s.B, "("+typestr+")("...)
- appendString(s, string(v))
- s.B = append(s.B, ")"...)
- } else {
- appendString(s, string(v))
- }
- } else {
- fn(s)
- }
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/cache.go b/vendor/codeberg.org/gruf/go-kv/v2/format/cache.go
deleted file mode 100644
index 8c9bfa210..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/cache.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package format
-
-import (
- "sync/atomic"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// cache is a concurrency-safe map[xunsafe.TypeInfo]FormatFunc
-// cache, designed for heavy reads but with unfortunately expensive
-// writes. it is designed such that after some initial load period
-// in which functions are cached by types, all future ops are reads.
-type cache struct{ p unsafe.Pointer }
-
-// Get will check cache for format func under key.
-func (c *cache) Get(t xunsafe.TypeInfo) FormatFunc {
- if p := c.load(); p != nil {
- return (*p)[t]
- }
- return nil
-}
-
-// Put will place given format func in cache under key, if not already exists.
-func (c *cache) Put(t xunsafe.TypeInfo, fn FormatFunc) {
- for {
- p := c.load()
-
- var cache map[xunsafe.TypeInfo]FormatFunc
-
- if p != nil {
- if _, ok := (*p)[t]; ok {
- return
- }
-
- cache = make(map[xunsafe.TypeInfo]FormatFunc, len(*p)+1)
- for key, value := range *p {
- cache[key] = value
- }
- } else {
- cache = make(map[xunsafe.TypeInfo]FormatFunc, 1)
- }
-
- cache[t] = fn
-
- if c.cas(p, &cache) {
- return
- }
- }
-}
-
-// load is a typed wrapper around atomic.LoadPointer().
-func (c *cache) load() *map[xunsafe.TypeInfo]FormatFunc {
- return (*map[xunsafe.TypeInfo]FormatFunc)(atomic.LoadPointer(&c.p))
-}
-
-// cas is a typed wrapper around atomic.CompareAndSwapPointer().
-func (c *cache) cas(old, new *map[xunsafe.TypeInfo]FormatFunc) bool {
- return atomic.CompareAndSwapPointer(&c.p, unsafe.Pointer(old), unsafe.Pointer(new))
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/format.go b/vendor/codeberg.org/gruf/go-kv/v2/format/format.go
deleted file mode 100644
index 0629c6f96..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/format.go
+++ /dev/null
@@ -1,687 +0,0 @@
-package format
-
-import (
- "reflect"
- "runtime/debug"
- "strconv"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// Global formatter instance.
-var Global Formatter
-
-// FormatFunc defines a function capable of formatting
-// the value contained in State{}.P, based on args in
-// State{}.A, storing the result in buffer State{}.B.
-type FormatFunc func(*State)
-
-// State contains all necessary
-// arguments, buffer and value
-// data pointer required for a
-// FormatFunc operation, in a
-// reusable structure if wanted.
-type State struct {
-
- // A contains args
- // passed to this
- // FormatFunc call.
- A Args
-
- // B is the buffer
- // that values will
- // be formatted into.
- B []byte
-
- // P contains a ptr
- // to the value type
- // being formatted.
- P unsafe.Pointer
-
- // stores pointers to the
- // recent interface values
- // we have visited. to prevent
- // possible recursion of
- // runtime defined data.
- ifaces ptr_ring
-}
-
-// ptr_ring size.
-const ringsz = 16
-
-// ptr_ring is a ring buffer of pointers,
-// purposely stored as uintptrs as all we
-// need them for is integer comparisons and
-// we don't want to hold-up the GC.
-type ptr_ring struct {
- p [ringsz]uintptr
- n uint8
-}
-
-func (p *ptr_ring) contains(ptr unsafe.Pointer) bool {
- for _, eptr := range p.p {
- if uintptr(ptr) == eptr {
- return true
- }
- }
- return false
-}
-
-func (p *ptr_ring) set(ptr unsafe.Pointer) {
- p.p[p.n%ringsz] = uintptr(ptr)
- p.n++
-}
-
-func (p *ptr_ring) clear() {
- p.p = [ringsz]uintptr{}
- p.n = 0
-}
-
-// Formatter provides access to value formatting
-// provided by this library. It encompasses a set
-// of configurable default arguments for when none
-// are set, and an internal concurrency-safe cache
-// of FormatFuncs to passed value type.
-type Formatter struct {
-
- // Defaults defines the default
- // set of arguments to use when
- // none are supplied to calls to
- // Append() and AppendState().
- Defaults Args
-
- // internal
- // format func
- // cache map.
- fns cache
-}
-
-// Append calls AppendState() with a newly allocated State{}, returning byte buffer.
-func (fmt *Formatter) Append(buf []byte, value any, args Args) []byte {
- s := new(State)
- s.A = args
- s.B = buf
- fmt.AppendState(s, value)
- return s.B
-}
-
-// AppendState will format the given value into the given
-// State{}'s byte buffer, using currently-set arguments.
-func (fmt *Formatter) AppendState(s *State, value any) {
- switch {
- case s.A != zeroArgs:
- break
- case fmt.Defaults != zeroArgs:
- // use fmt defaults.
- s.A = fmt.Defaults
- default:
- // global defaults.
- s.A = defaultArgs
- }
- t := xunsafe.TypeIterFrom(value)
- s.P = xunsafe.UnpackEface(value)
- s.ifaces.clear()
- s.ifaces.set(s.P)
- fmt.loadOrStore(t)(s)
-}
-
-func (fmt *Formatter) loadOrGet(t xunsafe.TypeIter) FormatFunc {
- // Look for existing stored
- // func under this type key.
- fn := fmt.fns.Get(t.TypeInfo)
-
- if fn == nil {
- // Load format func
- // for typecontext.
- fn = fmt.get(t)
- if fn == nil {
- panic("unreachable")
- }
- }
-
- return fn
-}
-
-func (fmt *Formatter) loadOrStore(t xunsafe.TypeIter) FormatFunc {
- // Get cache key.
- key := t.TypeInfo
-
- // Look for existing stored
- // func under this type key.
- fn := fmt.fns.Get(key)
-
- if fn == nil {
- // Load format func
- // for typecontext.
- fn = fmt.get(t)
- if fn == nil {
- panic("unreachable")
- }
-
- // Store under type.
- fmt.fns.Put(key, fn)
- }
-
- return fn
-}
-
-var (
- // reflectTypeType is the reflected type of the reflect type,
- // used in fmt.get() to prevent iter of internal ABI structs.
- reflectTypeType = reflect.TypeOf(reflect.TypeOf(0))
-
- // stringable int types.
- byteType = typeof[byte]()
- runeType = typeof[rune]()
-
- // stringable slice types.
- bytesType = typeof[[]byte]()
- runesType = typeof[[]rune]()
-)
-
-func (fmt *Formatter) get(t xunsafe.TypeIter) (fn FormatFunc) {
- if t.Type == nil {
- // catch nil type.
- return appendNil
- }
-
- defer func() {
- if r := recover(); r != nil {
- debug.PrintStack()
- panic(r) // keep panicking
- } else if fn == nil {
- panic("nil func")
- }
-
- // Don't allow method functions for map keys,
- // to prevent situation of the method receiver
- // attempting to modify stored map key itself.
- if t.Flag&flagKeyType != 0 {
- return
- }
-
- // Check if type supports known method receiver.
- if methodFn := getMethodType(t); methodFn != nil {
-
- // Keep ptr to existing
- // non-method format fn.
- noMethodFn := fn
-
- // Wrap 'fn' to switch
- // between method / none.
- fn = func(s *State) {
- if s.A.NoMethod() {
- noMethodFn(s)
- } else {
- methodFn(s)
- }
- }
- }
- }()
-
- if t.Type == reflectTypeType {
- // DO NOT iterate down internal ABI
- // types, some are in non-GC memory.
- return getPointerType(t)
- }
-
- if !visit(t) {
- // On type recursion simply
- // format as raw pointer.
- return getPointerType(t)
- }
-
- // Get func for type kind.
- switch t.Type.Kind() {
- case reflect.Interface:
- return fmt.getInterfaceType(t)
- case reflect.String:
- return getStringType(t)
- case reflect.Bool:
- return getBoolType(t)
- case reflect.Int,
- reflect.Int8,
- reflect.Int16,
- reflect.Int32,
- reflect.Int64:
- return getIntType(t)
- case reflect.Uint,
- reflect.Uint8,
- reflect.Uint16,
- reflect.Uint32,
- reflect.Uint64:
- return getUintType(t)
- case reflect.Float32,
- reflect.Float64:
- return getFloatType(t)
- case reflect.Complex64,
- reflect.Complex128:
- return getComplexType(t)
- case reflect.Pointer:
- return fmt.derefPointerType(t)
- case reflect.Array:
- elem := t.Type.Elem()
- switch fn := fmt.iterArrayType(t); {
- case elem.AssignableTo(byteType):
- return wrapByteArray(t, fn)
- case elem.AssignableTo(runeType):
- return wrapRuneArray(t, fn)
- default:
- return fn
- }
- case reflect.Slice:
- switch fn := fmt.iterSliceType(t); {
- case t.Type.AssignableTo(bytesType):
- return wrapByteSlice(t, fn)
- case t.Type.AssignableTo(runesType):
- return wrapRuneSlice(t, fn)
- default:
- return fn
- }
- case reflect.Struct:
- return fmt.iterStructType(t)
- case reflect.Map:
- return fmt.iterMapType(t)
- default:
- return getPointerType(t)
- }
-}
-
-func (fmt *Formatter) getInterfaceType(t xunsafe.TypeIter) FormatFunc {
- if t.Type.NumMethod() == 0 {
- return func(s *State) {
- // Unpack empty interface.
- eface := *(*any)(s.P)
- s.P = xunsafe.UnpackEface(eface)
-
- // Get reflected type information.
- rtype := reflect.TypeOf(eface)
- if rtype == nil {
- appendNil(s)
- return
- }
-
- // Check for ptr recursion.
- if s.ifaces.contains(s.P) {
- getPointerType(t)(s)
- return
- }
-
- // Store value ptr.
- s.ifaces.set(s.P)
-
- // Wrap before load.
- var t xunsafe.TypeIter
- t.Flag = xunsafe.ReflectIfaceElemFlags(rtype)
- t.Type = rtype
-
- // Load + pass to func.
- fmt.loadOrStore(t)(s)
- }
- } else {
- return func(s *State) {
- // Unpack interface-with-method ptr.
- iface := *(*interface{ M() })(s.P)
- s.P = xunsafe.UnpackEface(iface)
-
- // Get reflected type information.
- rtype := reflect.TypeOf(iface)
- if rtype == nil {
- appendNil(s)
- return
- }
-
- // Check for ptr recursion.
- if s.ifaces.contains(s.P) {
- getPointerType(t)(s)
- return
- }
-
- // Store value ptr.
- s.ifaces.set(s.P)
-
- // Wrap before load.
- var t xunsafe.TypeIter
- t.Flag = xunsafe.ReflectIfaceElemFlags(rtype)
- t.Type = rtype
-
- // Load + pass to func.
- fmt.loadOrStore(t)(s)
- }
- }
-}
-
-func getStringType(t xunsafe.TypeIter) FormatFunc {
- return with_typestr_ptrs(t, func(s *State) {
- appendString(s, *(*string)(s.P))
- })
-}
-
-func getBoolType(t xunsafe.TypeIter) FormatFunc {
- return with_typestr_ptrs(t, func(s *State) {
- s.B = strconv.AppendBool(s.B, *(*bool)(s.P))
- })
-}
-
-func getIntType(t xunsafe.TypeIter) FormatFunc {
- switch t.Type.Bits() {
- case 8:
- return with_typestr_ptrs(t, func(s *State) {
- appendInt(s, int64(*(*int8)(s.P)))
- })
- case 16:
- return with_typestr_ptrs(t, func(s *State) {
- appendInt(s, int64(*(*int16)(s.P)))
- })
- case 32:
- return with_typestr_ptrs(t, func(s *State) {
- switch {
- case s.A.AsNumber():
- // fallthrough
- case s.A.AsQuotedASCII():
- s.B = strconv.AppendQuoteRuneToASCII(s.B, *(*rune)(s.P))
- return
- case s.A.AsText() || s.A.AsQuotedText():
- s.B = strconv.AppendQuoteRune(s.B, *(*rune)(s.P))
- return
- }
- appendInt(s, int64(*(*int32)(s.P)))
- })
- case 64:
- return with_typestr_ptrs(t, func(s *State) {
- appendInt(s, int64(*(*int64)(s.P)))
- })
- default:
- panic("unreachable")
- }
-}
-
-func getUintType(t xunsafe.TypeIter) FormatFunc {
- switch t.Type.Bits() {
- case 8:
- return with_typestr_ptrs(t, func(s *State) {
- switch {
- case s.A.AsNumber():
- // fallthrough
- case s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII():
- s.B = AppendQuoteByte(s.B, *(*byte)(s.P))
- return
- }
- appendUint(s, uint64(*(*uint8)(s.P)))
- })
- case 16:
- return with_typestr_ptrs(t, func(s *State) {
- appendUint(s, uint64(*(*uint16)(s.P)))
- })
- case 32:
- return with_typestr_ptrs(t, func(s *State) {
- appendUint(s, uint64(*(*uint32)(s.P)))
- })
- case 64:
- return with_typestr_ptrs(t, func(s *State) {
- appendUint(s, uint64(*(*uint64)(s.P)))
- })
- default:
- panic("unreachable")
- }
-}
-
-func getFloatType(t xunsafe.TypeIter) FormatFunc {
- switch t.Type.Bits() {
- case 32:
- return with_typestr_ptrs(t, func(s *State) {
- appendFloat(s, float64(*(*float32)(s.P)), 32)
- })
- case 64:
- return with_typestr_ptrs(t, func(s *State) {
- appendFloat(s, float64(*(*float64)(s.P)), 64)
- })
- default:
- panic("unreachable")
- }
-}
-
-func getComplexType(t xunsafe.TypeIter) FormatFunc {
- switch t.Type.Bits() {
- case 64:
- return with_typestr_ptrs(t, func(s *State) {
- v := *(*complex64)(s.P)
- r, i := real(v), imag(v)
- appendComplex(s, float64(r), float64(i), 32)
- })
- case 128:
- return with_typestr_ptrs(t, func(s *State) {
- v := *(*complex128)(s.P)
- r, i := real(v), imag(v)
- appendComplex(s, float64(r), float64(i), 64)
- })
- default:
- panic("unreachable")
- }
-}
-
-func getPointerType(t xunsafe.TypeIter) FormatFunc {
- switch t.Indirect() {
- case true:
- return with_typestr_ptrs(t, func(s *State) {
- s.P = *(*unsafe.Pointer)(s.P)
- appendPointer(s, s.P)
- })
- case false:
- return with_typestr_ptrs(t, func(s *State) {
- appendPointer(s, s.P)
- })
- default:
- panic("unreachable")
- }
-}
-
-func with_typestr_ptrs(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
- if fn == nil {
- panic("nil func")
- }
-
- // Check for type wrapping.
- if !needs_typestr(t) {
- return fn
- }
-
- // Get type string with pointers.
- typestr := typestr_with_ptrs(t)
-
- // Wrap format func to include
- // type information when needed.
- return func(s *State) {
- if s.A.WithType() {
- s.B = append(s.B, "("+typestr+")("...)
- fn(s)
- s.B = append(s.B, ")"...)
- } else {
- fn(s)
- }
- }
-}
-
-func appendString(s *State, v string) {
- switch {
- case s.A.WithType():
- if len(v) > SingleTermLine || !IsSafeASCII(v) {
- // Requires quoting AND escaping
- s.B = strconv.AppendQuote(s.B, v)
- } else if ContainsDoubleQuote(v) {
- // Contains double quotes, needs escaping
- s.B = append(s.B, '"')
- s.B = AppendEscape(s.B, v)
- s.B = append(s.B, '"')
- } else {
- // All else, needs quotes
- s.B = append(s.B, '"')
- s.B = append(s.B, v...)
- s.B = append(s.B, '"')
- }
- case s.A.Logfmt():
- if len(v) > SingleTermLine || !IsSafeASCII(v) {
- // Requires quoting AND escaping
- s.B = strconv.AppendQuote(s.B, v)
- } else if ContainsDoubleQuote(v) {
- // Contains double quotes, needs escaping
- s.B = append(s.B, '"')
- s.B = AppendEscape(s.B, v)
- s.B = append(s.B, '"')
- } else if len(v) == 0 || ContainsSpaceOrTab(v) {
- // Contains space / empty, needs quotes
- s.B = append(s.B, '"')
- s.B = append(s.B, v...)
- s.B = append(s.B, '"')
- } else {
- // All else write as-is
- s.B = append(s.B, v...)
- }
- case s.A.AsQuotedText():
- s.B = strconv.AppendQuote(s.B, v)
- case s.A.AsQuotedASCII():
- s.B = strconv.AppendQuoteToASCII(s.B, v)
- default:
- s.B = append(s.B, v...)
- }
-}
-
-func appendInt(s *State, v int64) {
- args := s.A.Int
-
- // Set argument defaults.
- if args == zeroArgs.Int {
- args = defaultArgs.Int
- }
-
- // Add any padding.
- if args.Pad > 0 {
- const zeros = `00000000000000000000`
- if args.Pad > len(zeros) {
- panic("cannot pad > " + zeros)
- }
-
- if v == 0 {
- s.B = append(s.B, zeros[:args.Pad]...)
- return
- }
-
- // Get absolute.
- abs := abs64(v)
-
- // Get number of required chars.
- chars := int(v / int64(args.Base))
- if v%int64(args.Base) != 0 {
- chars++
- }
-
- if abs != v {
- // If this is a negative value,
- // prepend minus ourselves and
- // set value as the absolute.
- s.B = append(s.B, '-')
- v = abs
- }
-
- // Prepend required zeros.
- n := args.Pad - chars
- s.B = append(s.B, zeros[:n]...)
- }
-
- // Append value as signed integer w/ args.
- s.B = strconv.AppendInt(s.B, v, args.Base)
-}
-
-func appendUint(s *State, v uint64) {
- args := s.A.Int
-
- // Set argument defaults.
- if args == zeroArgs.Int {
- args = defaultArgs.Int
- }
-
- // Add any padding.
- if args.Pad > 0 {
- const zeros = `00000000000000000000`
- if args.Pad > len(zeros) {
- panic("cannot pad > " + zeros)
- }
-
- if v == 0 {
- s.B = append(s.B, zeros[:args.Pad]...)
- return
- }
-
- // Get number of required chars.
- chars := int(v / uint64(args.Base))
- if v%uint64(args.Base) != 0 {
- chars++
- }
-
- // Prepend required zeros.
- n := args.Pad - chars
- s.B = append(s.B, zeros[:n]...)
- }
-
- // Append value as unsigned integer w/ args.
- s.B = strconv.AppendUint(s.B, v, args.Base)
-}
-
-func appendFloat(s *State, v float64, bits int) {
- args := s.A.Float
-
- // Set argument defaults.
- if args == zeroArgs.Float {
- args = defaultArgs.Float
- }
-
- // Append value as float${bit} w/ args.
- s.B = strconv.AppendFloat(s.B, float64(v),
- args.Fmt, args.Prec, bits)
-}
-
-func appendComplex(s *State, r, i float64, bits int) {
- args := s.A.Complex
-
- // Set argument defaults.
- if args == zeroArgs.Complex {
- args = defaultArgs.Complex
- }
-
- // Append real value as float${bit} w/ args.
- s.B = strconv.AppendFloat(s.B, float64(r),
- args.Real.Fmt, args.Real.Prec, bits)
- s.B = append(s.B, '+')
-
- // Append imag value as float${bit} w/ args.
- s.B = strconv.AppendFloat(s.B, float64(i),
- args.Imag.Fmt, args.Imag.Prec, bits)
- s.B = append(s.B, 'i')
-}
-
-func appendPointer(s *State, v unsafe.Pointer) {
- if v != nil {
- s.B = append(s.B, "0x"...)
- s.B = strconv.AppendUint(s.B, uint64(uintptr(v)), 16)
- } else {
- appendNil(s)
- }
-}
-
-func appendNilType(s *State, typestr string) {
- if s.A.WithType() {
- s.B = append(s.B, "("+typestr+")(<nil>)"...)
- } else {
- s.B = append(s.B, "<nil>"...)
- }
-}
-
-func appendNil(s *State) {
- s.B = append(s.B, "<nil>"...)
-}
-
-func abs64(i int64) int64 {
- u := uint64(i >> 63)
- return (i ^ int64(u)) + int64(u&1)
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/formatting.go b/vendor/codeberg.org/gruf/go-kv/v2/format/formatting.go
deleted file mode 100644
index e09edbefc..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/formatting.go
+++ /dev/null
@@ -1,161 +0,0 @@
-package format
-
-import (
- "strings"
- "unicode"
- "unicode/utf8"
-)
-
-const (
- // SingleTermLine: beyond a certain length of string, all of the
- // extra checks to handle quoting/not-quoting add a significant
- // amount of extra processing time. Quoting in this manner only really
- // effects readability on a single line, so a max string length that
- // encompasses the maximum number of columns on *most* terminals was
- // selected. This was chosen using the metric that 1080p is one of the
- // most common display resolutions, and that a relatively small font size
- // of 7 requires 223 columns. So 256 should be >= $COLUMNS (fullscreen)
- // in 99% of usecases (these figures all pulled out of my ass).
- SingleTermLine = 256
-)
-
-// IsSafeASCII checks whether string is printable (i.e. non-control char) ASCII text.
-func IsSafeASCII(str string) bool {
- for _, r := range str {
- if (r < ' ' && r != '\t') ||
- r >= 0x7f {
- return false
- }
- }
- return true
-}
-
-// ContainsSpaceOrTab checks if "s" contains space or tabs. EXPECTS ASCII.
-func ContainsSpaceOrTab(s string) bool {
- if i := strings.IndexByte(s, ' '); i >= 0 {
- return true // note using indexbyte as it is ASM.
- } else if i := strings.IndexByte(s, '\t'); i >= 0 {
- return true
- }
- return false
-}
-
-// ContainsDoubleQuote checks if "s" contains a double quote. EXPECTS ASCII.
-func ContainsDoubleQuote(s string) bool {
- return (strings.IndexByte(s, '"') >= 0)
-}
-
-// AppendEscape will append 's' to 'buf' and escape any double quotes. EXPECTS ASCII.
-func AppendEscape(buf []byte, str string) []byte {
- for i := range str {
- switch str[i] {
- case '\\':
- // Append delimited '\'
- buf = append(buf, '\\', '\\')
-
- case '"':
- // Append delimited '"'
- buf = append(buf, '\\', '"')
- default:
- // Append char as-is
- buf = append(buf, str[i])
- }
- }
- return buf
-}
-
-const hex = "0123456789abcdef"
-
-// AppendEscapeByte ...
-func AppendEscapeByte(buf []byte, c byte) []byte {
- switch c {
- case '\a':
- return append(buf, `\a`...)
- case '\b':
- return append(buf, `\b`...)
- case '\f':
- return append(buf, `\f`...)
- case '\n':
- return append(buf, `\n`...)
- case '\r':
- return append(buf, `\r`...)
- case '\t':
- return append(buf, `\t`...)
- case '\v':
- return append(buf, `\v`...)
- case '\\':
- return append(buf, `\\`...)
- default:
- if c < ' ' {
- return append(buf, '\\', 'x', hex[c>>4], hex[c&0xF])
- }
- return append(buf, c)
- }
-}
-
-// AppendQuoteByte ...
-func AppendQuoteByte(buf []byte, c byte) []byte {
- if c == '\'' {
- return append(buf, `'\''`...)
- }
- buf = append(buf, '\'')
- buf = AppendEscapeByte(buf, c)
- buf = append(buf, '\'')
- return buf
-}
-
-// AppendEscapeRune ...
-func AppendEscapeRune(buf []byte, r rune) []byte {
- if unicode.IsPrint(r) {
- return utf8.AppendRune(buf, r)
- }
- switch r {
- case '\a':
- return append(buf, `\a`...)
- case '\b':
- return append(buf, `\b`...)
- case '\f':
- return append(buf, `\f`...)
- case '\n':
- return append(buf, `\n`...)
- case '\r':
- return append(buf, `\r`...)
- case '\t':
- return append(buf, `\t`...)
- case '\v':
- return append(buf, `\v`...)
- case '\\':
- return append(buf, `\\`...)
- default:
- switch {
- case r < ' ' || r == 0x7f:
- buf = append(buf, `\x`...)
- buf = append(buf, hex[byte(r)>>4])
- buf = append(buf, hex[byte(r)&0xF])
- case !utf8.ValidRune(r):
- r = 0xFFFD
- fallthrough
- case r < 0x10000:
- buf = append(buf, `\u`...)
- buf = append(buf,
- hex[r>>uint(12)&0xF],
- hex[r>>uint(8)&0xF],
- hex[r>>uint(4)&0xF],
- hex[r>>uint(0)&0xF],
- )
- default:
- buf = append(buf, `\U`...)
- buf = append(buf,
- hex[r>>uint(28)&0xF],
- hex[r>>uint(24)&0xF],
- hex[r>>uint(20)&0xF],
- hex[r>>uint(16)&0xF],
- hex[r>>uint(12)&0xF],
- hex[r>>uint(8)&0xF],
- hex[r>>uint(4)&0xF],
- hex[r>>uint(0)&0xF],
- )
- }
- }
- return buf
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/map.go b/vendor/codeberg.org/gruf/go-kv/v2/format/map.go
deleted file mode 100644
index a3c4acd60..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/map.go
+++ /dev/null
@@ -1,134 +0,0 @@
-package format
-
-import (
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// iterMapType returns a FormatFunc capable of iterating
-// and formatting the given map type currently in TypeIter{}.
-// note this will fetch sub-FormatFuncs for key / value types.
-func (fmt *Formatter) iterMapType(t xunsafe.TypeIter) FormatFunc {
-
- // Key / value types.
- key := t.Type.Key()
- elem := t.Type.Elem()
-
- // Get nested k / v TypeIters with appropriate flags.
- flagsKey := xunsafe.ReflectMapKeyFlags(key) | flagKeyType
- flagsVal := xunsafe.ReflectMapElemFlags(elem)
- kt := t.Child(key, flagsKey)
- vt := t.Child(elem, flagsVal)
-
- // Get key format func.
- kfn := fmt.loadOrGet(kt)
- if kfn == nil {
- panic("unreachable")
- }
-
- // Get value format func.
- vfn := fmt.loadOrGet(vt)
- if vfn == nil {
- panic("unreachable")
- }
-
- // Final map type.
- rtype := t.Type
- flags := t.Flag
-
- // Map type string with ptrs / refs.
- typestrPtrs := typestr_with_ptrs(t)
- typestrRefs := typestr_with_refs(t)
-
- if !needs_typestr(t) {
- return func(s *State) {
- if s.P == nil || *(*unsafe.Pointer)(s.P) == nil {
- // Append nil.
- appendNil(s)
- return
- }
-
- // Build reflect value, and then a map iterator.
- v := xunsafe.BuildReflectValue(rtype, s.P, flags)
- i := xunsafe.GetMapIter(v)
-
- // Prepend object brace.
- s.B = append(s.B, '{')
-
- // Before len.
- l := len(s.B)
-
- for i.Next() {
- // Pass to map key func.
- s.P = xunsafe.Map_Key(i)
- kfn(s)
-
- // Add key seperator.
- s.B = append(s.B, '=')
-
- // Pass to map elem func.
- s.P = xunsafe.Map_Elem(i)
- vfn(s)
-
- // Add comma pair seperator.
- s.B = append(s.B, ',', ' ')
- }
-
- if len(s.B) != l {
- // Drop final ", ".
- s.B = s.B[:len(s.B)-2]
- }
-
- // Append object brace.
- s.B = append(s.B, '}')
- }
- }
-
- return func(s *State) {
- if s.P == nil || *(*unsafe.Pointer)(s.P) == nil {
- // Append nil value with type.
- appendNilType(s, typestrPtrs)
- return
- }
-
- // Build reflect value, and then a map iter.
- v := xunsafe.BuildReflectValue(rtype, s.P, flags)
- i := xunsafe.GetMapIter(v)
-
- // Include type info.
- if s.A.WithType() {
- s.B = append(s.B, typestrRefs...)
- }
-
- // Prepend object brace.
- s.B = append(s.B, '{')
-
- // Before len.
- l := len(s.B)
-
- for i.Next() {
- // Pass to map key func.
- s.P = xunsafe.Map_Key(i)
- kfn(s)
-
- // Add key seperator.
- s.B = append(s.B, '=')
-
- // Pass to map elem func.
- s.P = xunsafe.Map_Elem(i)
- vfn(s)
-
- // Add comma pair seperator.
- s.B = append(s.B, ',', ' ')
- }
-
- if len(s.B) != l {
- // Drop final ", ".
- s.B = s.B[:len(s.B)-2]
- }
-
- // Append object brace.
- s.B = append(s.B, '}')
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/methods.go b/vendor/codeberg.org/gruf/go-kv/v2/format/methods.go
deleted file mode 100644
index 4c0c1dbda..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/methods.go
+++ /dev/null
@@ -1,242 +0,0 @@
-package format
-
-import (
- "reflect"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-type Stringer interface{ String() string }
-
-type Formattable interface{ Format(*State) }
-
-var (
- // stringer type for implement checks.
- stringerType = typeof[Stringer]()
-
- // formattableType type for implement checks.
- formattableType = typeof[Formattable]()
-
- // error type for implement checks.
- errorType = typeof[error]()
-)
-
-// getMethodType returns a *possible* FormatFunc to handle case
-// of a type that implements any known interface{} types, else nil.
-func getMethodType(t xunsafe.TypeIter) FormatFunc {
- switch {
- case t.Type.Implements(stringerType):
- switch t.Type.Kind() {
- case reflect.Interface:
- return getInterfaceStringerType(t)
- default:
- return getConcreteStringerType(t)
- }
- case t.Type.Implements(formattableType):
- switch t.Type.Kind() {
- case reflect.Interface:
- return getInterfaceFormattableType(t)
- default:
- return getConcreteFormattableType(t)
- }
- case t.Type.Implements(errorType):
- switch t.Type.Kind() {
- case reflect.Interface:
- return getInterfaceErrorType(t)
- default:
- return getConcreteErrorType(t)
- }
- default:
- return nil
- }
-}
-
-// getInterfaceStringerType returns a FormatFunc to handle case of an interface{}
-// type that implements Stringer{}, i.e. Stringer{} itself and any superset of.
-func getInterfaceStringerType(t xunsafe.TypeIter) FormatFunc {
- switch t.Indirect() && !t.IfaceIndir() {
- case true:
- return with_typestr_ptrs(t, func(s *State) {
- s.P = *(*unsafe.Pointer)(s.P)
- if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
- appendNil(s)
- return
- }
- v := *(*Stringer)(s.P)
- appendString(s, v.String())
- })
- case false:
- return with_typestr_ptrs(t, func(s *State) {
- if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
- appendNil(s)
- return
- }
- v := *(*Stringer)(s.P)
- appendString(s, v.String())
- })
- default:
- panic("unreachable")
- }
-}
-
-// getConcreteStringerType returns a FormatFunc to handle case of concrete
-// (i.e. non-interface{}) type that has a Stringer{} method receiver.
-func getConcreteStringerType(t xunsafe.TypeIter) FormatFunc {
- itab := xunsafe.GetIfaceITab[Stringer](t.Type)
- switch {
- case t.Indirect() && !t.IfaceIndir():
- return with_typestr_ptrs(t, func(s *State) {
- s.P = *(*unsafe.Pointer)(s.P)
- if s.P == nil {
- appendNil(s)
- return
- }
- v := *(*Stringer)(xunsafe.PackIface(itab, s.P))
- appendString(s, v.String())
- })
- case t.Type.Kind() == reflect.Pointer && t.Type.Implements(stringerType):
- // if the interface implementation is received by
- // value type, the pointer type will also support
- // it but it requires an extra dereference check.
- return with_typestr_ptrs(t, func(s *State) {
- if s.P == nil {
- appendNil(s)
- return
- }
- v := *(*Stringer)(xunsafe.PackIface(itab, s.P))
- appendString(s, v.String())
- })
- default:
- return with_typestr_ptrs(t, func(s *State) {
- v := *(*Stringer)(xunsafe.PackIface(itab, s.P))
- appendString(s, v.String())
- })
- }
-}
-
-// getInterfaceFormattableType returns a FormatFunc to handle case of an interface{}
-// type that implements Formattable{}, i.e. Formattable{} itself and any superset of.
-func getInterfaceFormattableType(t xunsafe.TypeIter) FormatFunc {
- switch t.Indirect() && !t.IfaceIndir() {
- case true:
- return with_typestr_ptrs(t, func(s *State) {
- s.P = *(*unsafe.Pointer)(s.P)
- if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
- appendNil(s)
- return
- }
- v := *(*Formattable)(s.P)
- v.Format(s)
- })
- case false:
- return with_typestr_ptrs(t, func(s *State) {
- if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
- appendNil(s)
- return
- }
- v := *(*Formattable)(s.P)
- v.Format(s)
- })
- default:
- panic("unreachable")
- }
-}
-
-// getConcreteFormattableType returns a FormatFunc to handle case of concrete
-// (i.e. non-interface{}) type that has a Formattable{} method receiver.
-func getConcreteFormattableType(t xunsafe.TypeIter) FormatFunc {
- itab := xunsafe.GetIfaceITab[Formattable](t.Type)
- switch {
- case t.Indirect() && !t.IfaceIndir():
- return with_typestr_ptrs(t, func(s *State) {
- s.P = *(*unsafe.Pointer)(s.P)
- if s.P == nil {
- appendNil(s)
- return
- }
- v := *(*Formattable)(xunsafe.PackIface(itab, s.P))
- v.Format(s)
- })
- case t.Type.Kind() == reflect.Pointer && t.Type.Implements(formattableType):
- // if the interface implementation is received by
- // value type, the pointer type will also support
- // it but it requires an extra dereference check.
- return with_typestr_ptrs(t, func(s *State) {
- if s.P == nil {
- appendNil(s)
- return
- }
- v := *(*Formattable)(xunsafe.PackIface(itab, s.P))
- v.Format(s)
- })
- default:
- return with_typestr_ptrs(t, func(s *State) {
- v := *(*Formattable)(xunsafe.PackIface(itab, s.P))
- v.Format(s)
- })
- }
-}
-
-// getInterfaceErrorType returns a FormatFunc to handle case of an interface{}
-// type that implements error{}, i.e. error{} itself and any superset of.
-func getInterfaceErrorType(t xunsafe.TypeIter) FormatFunc {
- switch t.Indirect() && !t.IfaceIndir() {
- case true:
- return with_typestr_ptrs(t, func(s *State) {
- s.P = *(*unsafe.Pointer)(s.P)
- if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
- appendNil(s)
- return
- }
- v := *(*error)(s.P)
- appendString(s, v.Error())
- })
- case false:
- return with_typestr_ptrs(t, func(s *State) {
- if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
- appendNil(s)
- return
- }
- v := *(*error)(s.P)
- appendString(s, v.Error())
- })
- default:
- panic("unreachable")
- }
-}
-
-// getConcreteErrorType returns a FormatFunc to handle case of concrete
-// (i.e. non-interface{}) type that has an error{} method receiver.
-func getConcreteErrorType(t xunsafe.TypeIter) FormatFunc {
- itab := xunsafe.GetIfaceITab[error](t.Type)
- switch {
- case t.Indirect() && !t.IfaceIndir():
- return with_typestr_ptrs(t, func(s *State) {
- s.P = *(*unsafe.Pointer)(s.P)
- if s.P == nil {
- appendNil(s)
- return
- }
- v := *(*error)(xunsafe.PackIface(itab, s.P))
- appendString(s, v.Error())
- })
- case t.Type.Kind() == reflect.Pointer && t.Type.Implements(errorType):
- // if the interface implementation is received by
- // value type, the pointer type will also support
- // it but it requires an extra dereference check.
- return with_typestr_ptrs(t, func(s *State) {
- if s.P == nil {
- appendNil(s)
- return
- }
- v := *(*error)(xunsafe.PackIface(itab, s.P))
- appendString(s, v.Error())
- })
- default:
- return with_typestr_ptrs(t, func(s *State) {
- v := *(*error)(xunsafe.PackIface(itab, s.P))
- appendString(s, v.Error())
- })
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go b/vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go
deleted file mode 100644
index ec1e2e15d..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go
+++ /dev/null
@@ -1,130 +0,0 @@
-package format
-
-import (
- "reflect"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// derefPointerType returns a FormatFunc capable of dereferencing
-// and formatting the given pointer type currently in TypeIter{}.
-// note this will fetch a sub-FormatFunc for resulting value type.
-func (fmt *Formatter) derefPointerType(t xunsafe.TypeIter) FormatFunc {
- var n int
- rtype := t.Type
- flags := t.Flag
-
- // Iteratively dereference pointer types.
- for rtype.Kind() == reflect.Pointer {
-
- // If this actual indirect memory,
- // increase dereferences counter.
- if flags&xunsafe.Reflect_flagIndir != 0 {
- n++
- }
-
- // Get next elem type.
- rtype = rtype.Elem()
-
- // Get next set of dereferenced element type flags.
- flags = xunsafe.ReflectPointerElemFlags(flags, rtype)
- }
-
- // Wrap value as TypeIter.
- vt := t.Child(rtype, flags)
-
- // Get value format func.
- fn := fmt.loadOrGet(vt)
- if fn == nil {
- panic("unreachable")
- }
-
- if !needs_typestr(t) {
- if n <= 0 {
- // No derefs are needed.
- return func(s *State) {
- if s.P == nil {
- // Final check.
- appendNil(s)
- return
- }
-
- // Format
- // final
- // value.
- fn(s)
- }
- }
-
- return func(s *State) {
- // Deref n number times.
- for i := n; i > 0; i-- {
-
- if s.P == nil {
- // Nil check.
- appendNil(s)
- return
- }
-
- // Further deref pointer value.
- s.P = *(*unsafe.Pointer)(s.P)
- }
-
- if s.P == nil {
- // Final check.
- appendNil(s)
- return
- }
-
- // Format
- // final
- // value.
- fn(s)
- }
- }
-
- // Final type string with ptrs.
- typestr := typestr_with_ptrs(t)
-
- if n <= 0 {
- // No derefs are needed.
- return func(s *State) {
- if s.P == nil {
- // Final nil value check.
- appendNilType(s, typestr)
- return
- }
-
- // Format
- // final
- // value.
- fn(s)
- }
- }
-
- return func(s *State) {
- // Deref n number times.
- for i := n; i > 0; i-- {
- if s.P == nil {
- // Check for nil value.
- appendNilType(s, typestr)
- return
- }
-
- // Further deref pointer value.
- s.P = *(*unsafe.Pointer)(s.P)
- }
-
- if s.P == nil {
- // Final nil value check.
- appendNilType(s, typestr)
- return
- }
-
- // Format
- // final
- // value.
- fn(s)
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/slice.go b/vendor/codeberg.org/gruf/go-kv/v2/format/slice.go
deleted file mode 100644
index e53fc5c4b..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/slice.go
+++ /dev/null
@@ -1,160 +0,0 @@
-package format
-
-import "codeberg.org/gruf/go-xunsafe"
-
-// iterSliceType returns a FormatFunc capable of iterating
-// and formatting the given slice type currently in TypeIter{}.
-// note this will fetch a sub-FormatFunc for the slice element
-// type, and also handle special cases of []byte, []rune slices.
-func (fmt *Formatter) iterSliceType(t xunsafe.TypeIter) FormatFunc {
-
- // Get nested element type.
- elem := t.Type.Elem()
- esz := elem.Size()
-
- // Get nested elem TypeIter{} with flags.
- flags := xunsafe.ReflectSliceElemFlags(elem)
- et := t.Child(elem, flags)
-
- // Get elem format func.
- fn := fmt.loadOrGet(et)
- if fn == nil {
- panic("unreachable")
- }
-
- if !needs_typestr(t) {
- return func(s *State) {
- ptr := s.P
-
- // Get data as unsafe slice header.
- hdr := (*xunsafe.Unsafeheader_Slice)(ptr)
- if hdr == nil || hdr.Data == nil {
-
- // Append nil.
- appendNil(s)
- return
- }
-
- // Prepend array brace.
- s.B = append(s.B, '[')
-
- if hdr.Len > 0 {
- for i := 0; i < hdr.Len; i++ {
- // Format at array index.
- offset := esz * uintptr(i)
- s.P = add(hdr.Data, offset)
- fn(s)
-
- // Append separator.
- s.B = append(s.B, ',')
- }
-
- // Drop final comma.
- s.B = s.B[:len(s.B)-1]
- }
-
- // Append array brace.
- s.B = append(s.B, ']')
- }
- }
-
- // Slice type string with ptrs / refs.
- typestrPtrs := typestr_with_ptrs(t)
- typestrRefs := typestr_with_refs(t)
-
- return func(s *State) {
- ptr := s.P
-
- // Get data as unsafe slice header.
- hdr := (*xunsafe.Unsafeheader_Slice)(ptr)
- if hdr == nil || hdr.Data == nil {
-
- // Append nil value with type.
- appendNilType(s, typestrPtrs)
- return
- }
-
- // Open / close braces.
- var open, close uint8
- open, close = '[', ']'
-
- // Include type info.
- if s.A.WithType() {
- s.B = append(s.B, typestrRefs...)
- open, close = '{', '}'
- }
-
- // Prepend array brace.
- s.B = append(s.B, open)
-
- if hdr.Len > 0 {
- for i := 0; i < hdr.Len; i++ {
- // Format at array index.
- offset := esz * uintptr(i)
- s.P = add(hdr.Data, offset)
- fn(s)
-
- // Append separator.
- s.B = append(s.B, ',')
- }
-
- // Drop final comma.
- s.B = s.B[:len(s.B)-1]
- }
-
- // Append array brace.
- s.B = append(s.B, close)
- }
-}
-
-func wrapByteSlice(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
- if !needs_typestr(t) {
- return func(s *State) {
- if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
- appendString(s, *(*string)(s.P))
- } else {
- fn(s)
- }
- }
- }
- typestr := typestr_with_ptrs(t)
- return func(s *State) {
- if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
- if s.A.WithType() {
- s.B = append(s.B, "("+typestr+")("...)
- appendString(s, *(*string)(s.P))
- s.B = append(s.B, ")"...)
- } else {
- appendString(s, *(*string)(s.P))
- }
- } else {
- fn(s)
- }
- }
-}
-
-func wrapRuneSlice(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
- if !needs_typestr(t) {
- return func(s *State) {
- if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
- appendString(s, string(*(*[]rune)(s.P)))
- } else {
- fn(s)
- }
- }
- }
- typestr := typestr_with_ptrs(t)
- return func(s *State) {
- if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
- if s.A.WithType() {
- s.B = append(s.B, "("+typestr+")("...)
- appendString(s, string(*(*[]rune)(s.P)))
- s.B = append(s.B, ")"...)
- } else {
- appendString(s, string(*(*[]rune)(s.P)))
- }
- } else {
- fn(s)
- }
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/struct.go b/vendor/codeberg.org/gruf/go-kv/v2/format/struct.go
deleted file mode 100644
index 617f65d81..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/struct.go
+++ /dev/null
@@ -1,175 +0,0 @@
-package format
-
-import "codeberg.org/gruf/go-xunsafe"
-
-// field stores the minimum necessary
-// data for iterating and formatting
-// each field in a given struct.
-type field struct {
- format FormatFunc
- name string
- offset uintptr
-}
-
-// iterStructType returns a FormatFunc capable of iterating
-// and formatting the given struct type currently in TypeIter{}.
-// note this will fetch sub-FormatFuncs for each struct field.
-func (fmt *Formatter) iterStructType(t xunsafe.TypeIter) FormatFunc {
- // Number of struct fields.
- n := t.Type.NumField()
-
- // Gather format functions.
- fields := make([]field, n)
- for i := 0; i < n; i++ {
-
- // Get struct field at index.
- sfield := t.Type.Field(i)
- rtype := sfield.Type
-
- // Get nested field TypeIter with appropriate flags.
- flags := xunsafe.ReflectStructFieldFlags(t.Flag, rtype)
- ft := t.Child(sfield.Type, flags)
-
- // Get field format func.
- fn := fmt.loadOrGet(ft)
- if fn == nil {
- panic("unreachable")
- }
-
- // Set field info.
- fields[i] = field{
- format: fn,
- name: sfield.Name,
- offset: sfield.Offset,
- }
- }
-
- // Handle no. fields.
- switch len(fields) {
- case 0:
- return emptyStructType(t)
- case 1:
- return iterSingleFieldStructType(t, fields[0])
- default:
- return iterMultiFieldStructType(t, fields)
- }
-}
-
-func emptyStructType(t xunsafe.TypeIter) FormatFunc {
- if !needs_typestr(t) {
- return func(s *State) {
- // Append empty object.
- s.B = append(s.B, "{}"...)
- }
- }
-
- // Struct type string with refs.
- typestr := typestr_with_refs(t)
-
- // Append empty object
- // with type information.
- return func(s *State) {
- if s.A.WithType() {
- s.B = append(s.B, typestr...)
- }
- s.B = append(s.B, "{}"...)
- }
-}
-
-func iterSingleFieldStructType(t xunsafe.TypeIter, field field) FormatFunc {
- if field.format == nil {
- panic("nil func")
- }
-
- if !needs_typestr(t) {
- return func(s *State) {
- // Wrap 'fn' with braces + field name.
- s.B = append(s.B, "{"+field.name+"="...)
- field.format(s)
- s.B = append(s.B, "}"...)
- }
- }
-
- // Struct type string with refs.
- typestr := typestr_with_refs(t)
-
- return func(s *State) {
- // Include type info.
- if s.A.WithType() {
- s.B = append(s.B, typestr...)
- }
-
- // Wrap 'fn' with braces + field name.
- s.B = append(s.B, "{"+field.name+"="...)
- field.format(s)
- s.B = append(s.B, "}"...)
- }
-}
-
-func iterMultiFieldStructType(t xunsafe.TypeIter, fields []field) FormatFunc {
- for _, field := range fields {
- if field.format == nil {
- panic("nil func")
- }
- }
-
- if !needs_typestr(t) {
- return func(s *State) {
- ptr := s.P
-
- // Prepend object brace.
- s.B = append(s.B, '{')
-
- for i := 0; i < len(fields); i++ {
- // Get struct field ptr via offset.
- s.P = add(ptr, fields[i].offset)
-
- // Append field name and value separator.
- s.B = append(s.B, fields[i].name+"="...)
-
- // Format i'th field.
- fields[i].format(s)
- s.B = append(s.B, ',', ' ')
- }
-
- // Drop final ", ".
- s.B = s.B[:len(s.B)-2]
-
- // Append object brace.
- s.B = append(s.B, '}')
- }
- }
-
- // Struct type string with refs.
- typestr := typestr_with_refs(t)
-
- return func(s *State) {
- ptr := s.P
-
- // Include type info.
- if s.A.WithType() {
- s.B = append(s.B, typestr...)
- }
-
- // Prepend object brace.
- s.B = append(s.B, '{')
-
- for i := 0; i < len(fields); i++ {
- // Get struct field ptr via offset.
- s.P = add(ptr, fields[i].offset)
-
- // Append field name and value separator.
- s.B = append(s.B, fields[i].name+"="...)
-
- // Format i'th field.
- fields[i].format(s)
- s.B = append(s.B, ',', ' ')
- }
-
- // Drop final ", ".
- s.B = s.B[:len(s.B)-2]
-
- // Append object brace.
- s.B = append(s.B, '}')
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/type.go b/vendor/codeberg.org/gruf/go-kv/v2/format/type.go
deleted file mode 100644
index ce2235c88..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/type.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package format
-
-import (
- "reflect"
- "strings"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// visit ...
-func visit(iter xunsafe.TypeIter) bool {
- t := iter.Type
-
- // Check if type is already encountered further up tree.
- for node := iter.Parent; node != nil; node = node.Parent {
- if node.Type == t {
- return false
- }
- }
-
- return true
-}
-
-// needs_typestr returns whether the type contained in the
-// receiving TypeIter{} needs type string information prefixed
-// when the TypeMask argument flag bit is set. Certain types
-// don't need this as the parent type already indicates this.
-func needs_typestr(iter xunsafe.TypeIter) bool {
- if iter.Parent == nil {
- return true
- }
- switch p := iter.Parent.Type; p.Kind() {
- case reflect.Pointer:
- return needs_typestr(*iter.Parent)
- case reflect.Slice,
- reflect.Array,
- reflect.Map:
- return false
- default:
- return true
- }
-}
-
-// typestr_with_ptrs returns the type string for
-// current xunsafe.TypeIter{} with asterisks for pointers.
-func typestr_with_ptrs(iter xunsafe.TypeIter) string {
- t := iter.Type
-
- // Check for parent.
- if iter.Parent == nil {
- return t.String()
- }
-
- // Get parent type.
- p := iter.Parent.Type
-
- // If parent is not ptr, then
- // this was not a deref'd ptr.
- if p.Kind() != reflect.Pointer {
- return t.String()
- }
-
- // Return un-deref'd
- // ptr (parent) type.
- return p.String()
-}
-
-// typestr_with_refs returns the type string for
-// current xunsafe.TypeIter{} with ampersands for pointers.
-func typestr_with_refs(iter xunsafe.TypeIter) string {
- t := iter.Type
-
- // Check for parent.
- if iter.Parent == nil {
- return t.String()
- }
-
- // Get parent type.
- p := iter.Parent.Type
-
- var d int
-
- // Count number of dereferences.
- for p.Kind() == reflect.Pointer {
- p = p.Elem()
- d++
- }
-
- if d <= 0 {
- // Prefer just returning our
- // own string if possible, to
- // reduce number of strings
- // we need to allocate.
- return t.String()
- }
-
- // Value type str.
- str := t.String()
-
- // Return with type ptrs
- // symbolized by 'refs'.
- var buf strings.Builder
- buf.Grow(len(str) + d)
- for i := 0; i < d; i++ {
- buf.WriteByte('&')
- }
- buf.WriteString(str)
- return buf.String()
-}
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/util.go b/vendor/codeberg.org/gruf/go-kv/v2/util.go
deleted file mode 100644
index 5939ce844..000000000
--- a/vendor/codeberg.org/gruf/go-kv/v2/util.go
+++ /dev/null
@@ -1,147 +0,0 @@
-package kv
-
-import (
- "strconv"
- "strings"
-
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-kv/v2/format"
-)
-
-// AppendQuoteString will append (and escape/quote where necessary) a field string.
-func AppendQuoteString(buf *byteutil.Buffer, str string) {
- switch {
- case len(str) == 0:
- // Append empty quotes.
- buf.B = append(buf.B, `""`...)
- return
-
- case len(str) == 1:
- // Append quoted escaped single byte.
- buf.B = format.AppendQuoteByte(buf.B, str[0])
- return
-
- case len(str) > format.SingleTermLine || !format.IsSafeASCII(str):
- // Long line or contains non-ascii chars.
- buf.B = strconv.AppendQuote(buf.B, str)
- return
-
- case !isQuoted(str):
- // Not single/double quoted already.
-
- if format.ContainsSpaceOrTab(str) {
- // Quote un-enclosed spaces.
- buf.B = append(buf.B, '"')
- buf.B = append(buf.B, str...)
- buf.B = append(buf.B, '"')
- return
- }
-
- if format.ContainsDoubleQuote(str) {
- // Contains double quote, double quote
- // and append escaped existing.
- buf.B = append(buf.B, '"')
- buf.B = format.AppendEscape(buf.B, str)
- buf.B = append(buf.B, '"')
- return
- }
- }
-
- // Double quoted, enclosed in braces, or
- // literally anything else: append as-is.
- buf.B = append(buf.B, str...)
- return
-}
-
-// AppendQuoteValue will append (and escape/quote where necessary) a formatted value string.
-func AppendQuoteValue(buf *byteutil.Buffer, str string) {
- switch {
- case len(str) == 0:
- // Append empty quotes.
- buf.B = append(buf.B, `""`...)
- return
-
- case len(str) == 1:
- // Append quoted escaped single byte.
- buf.B = format.AppendQuoteByte(buf.B, str[0])
- return
-
- case len(str) > format.SingleTermLine || !format.IsSafeASCII(str):
- // Long line or contains non-ascii chars.
- buf.B = strconv.AppendQuote(buf.B, str)
- return
-
- case !isQuoted(str):
- // Not single/double quoted already.
-
- // Get space / tab indices (if any).
- s := strings.IndexByte(str, ' ')
- t := strings.IndexByte(str, '\t')
-
- // Find first whitespace.
- sp0 := smallest(s, t)
- if sp0 < 0 {
- break
- }
-
- // Check if str is enclosed by braces.
- // (but without any key-value separator).
- if (enclosedBy(str, sp0, '{', '}') ||
- enclosedBy(str, sp0, '[', ']') ||
- enclosedBy(str, sp0, '(', ')')) &&
- strings.IndexByte(str, '=') < 0 {
- break
- }
-
- if format.ContainsDoubleQuote(str) {
- // Contains double quote, double quote
- // and append escaped existing.
- buf.B = append(buf.B, '"')
- buf.B = format.AppendEscape(buf.B, str)
- buf.B = append(buf.B, '"')
- return
- }
-
- // Quote un-enclosed spaces.
- buf.B = append(buf.B, '"')
- buf.B = append(buf.B, str...)
- buf.B = append(buf.B, '"')
- return
- }
-
- // Double quoted, enclosed in braces, or
- // literally anything else: append as-is.
- buf.B = append(buf.B, str...)
- return
-}
-
-// isQuoted checks if string is single or double quoted.
-func isQuoted(str string) bool {
- return (str[0] == '"' && str[len(str)-1] == '"') ||
- (str[0] == '\'' && str[len(str)-1] == '\'')
-}
-
-// smallest attempts to return the smallest positive value of those given.
-func smallest(i1, i2 int) int {
- if i1 >= 0 && (i2 < 0 || i1 < i2) {
- return i1
- }
- return i2
-}
-
-// enclosedBy will check if given string is enclosed by end, and at least non-whitespace up to start.
-func enclosedBy(str string, sp int, start, end byte) bool {
- // Check for ending char in string.
- if str[len(str)-1] != end {
- return false
- }
-
- // Check for starting char in string.
- i := strings.IndexByte(str, start)
- if i < 0 {
- return false
- }
-
- // Check before space.
- return i < sp
-}
diff --git a/vendor/codeberg.org/gruf/go-list/LICENSE b/vendor/codeberg.org/gruf/go-list/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-list/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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-list/README.md b/vendor/codeberg.org/gruf/go-list/README.md
deleted file mode 100644
index c5ae37cc0..000000000
--- a/vendor/codeberg.org/gruf/go-list/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-list
-
-a doubly-linked list library with generic support.
diff --git a/vendor/codeberg.org/gruf/go-list/list.go b/vendor/codeberg.org/gruf/go-list/list.go
deleted file mode 100644
index 5490fa636..000000000
--- a/vendor/codeberg.org/gruf/go-list/list.go
+++ /dev/null
@@ -1,204 +0,0 @@
-package list
-
-// Elem represents an element in a doubly-linked list.
-type Elem[T any] struct {
- Next *Elem[T]
- Prev *Elem[T]
- Value T
-}
-
-// List implements a doubly-linked list, where:
-// - Head = index 0 (i.e. the front)
-// - Tail = index n-1 (i.e. the back)
-type List[T any] struct {
- Head *Elem[T]
- Tail *Elem[T]
- len int
-}
-
-// Len returns the current list length.
-func (l *List[T]) Len() int {
- return l.len
-}
-
-// PushFront adds 'v' to the beginning of the list.
-func (l *List[T]) PushFront(v T) *Elem[T] {
- elem := &Elem[T]{Value: v}
- l.PushElemFront(elem)
- return elem
-}
-
-// PushBack adds 'v' to the end of the list.
-func (l *List[T]) PushBack(v T) *Elem[T] {
- elem := &Elem[T]{Value: v}
- l.PushElemBack(elem)
- return elem
-}
-
-// InsertBefore adds 'v' into the list before 'at'.
-func (l *List[T]) InsertBefore(v T, at *Elem[T]) *Elem[T] {
- elem := &Elem[T]{Value: v}
- l.InsertElemBefore(elem, at)
- return elem
-}
-
-// InsertAfter adds 'v' into the list after 'at'.
-func (l *List[T]) InsertAfter(v T, at *Elem[T]) *Elem[T] {
- elem := &Elem[T]{Value: v}
- l.InsertElemAfter(elem, at)
- return elem
-}
-
-// PushFrontNode adds 'elem' to the front of the list.
-func (l *List[T]) PushElemFront(elem *Elem[T]) {
- if elem == l.Head {
- return
- }
-
- // Set new head.
- oldHead := l.Head
- l.Head = elem
-
- if oldHead != nil {
- // Link to old head
- elem.Next = oldHead
- oldHead.Prev = elem
- } else {
- // First in list.
- l.Tail = elem
- }
-
- // Incr count
- l.len++
-}
-
-// PushBackNode adds 'elem' to the back of the list.
-func (l *List[T]) PushElemBack(elem *Elem[T]) {
- if elem == l.Tail {
- return
- }
-
- // Set new tail.
- oldTail := l.Tail
- l.Tail = elem
-
- if oldTail != nil {
- // Link to old tail
- elem.Prev = oldTail
- oldTail.Next = elem
- } else {
- // First in list.
- l.Head = elem
- }
-
- // Incr count
- l.len++
-}
-
-// InsertElemAfter adds 'elem' into the list after 'at' (i.e. at.Next = elem).
-func (l *List[T]) InsertElemAfter(elem *Elem[T], at *Elem[T]) {
- if elem == at {
- return
- }
-
- // Set new 'next'.
- oldNext := at.Next
- at.Next = elem
-
- // Link to 'at'.
- elem.Prev = at
-
- if oldNext == nil {
- // Set new tail
- l.Tail = elem
- } else {
- // Link to 'prev'.
- oldNext.Prev = elem
- elem.Next = oldNext
- }
-
- // Incr count
- l.len++
-}
-
-// InsertElemBefore adds 'elem' into the list before 'at' (i.e. at.Prev = elem).
-func (l *List[T]) InsertElemBefore(elem *Elem[T], at *Elem[T]) {
- if elem == at {
- return
- }
-
- // Set new 'prev'.
- oldPrev := at.Prev
- at.Prev = elem
-
- // Link to 'at'.
- elem.Next = at
-
- if oldPrev == nil {
- // Set new head
- l.Head = elem
- } else {
- // Link to 'next'.
- oldPrev.Next = elem
- elem.Prev = oldPrev
- }
-
- // Incr count
- l.len++
-}
-
-// Remove removes the 'elem' from the list.
-func (l *List[T]) Remove(elem *Elem[T]) {
- // Get linked elems.
- next := elem.Next
- prev := elem.Prev
-
- // Unset elem.
- elem.Next = nil
- elem.Prev = nil
-
- switch {
- // elem is ONLY one in list.
- case next == nil && prev == nil:
- l.Head = nil
- l.Tail = nil
-
- // elem is front in list.
- case next != nil && prev == nil:
- l.Head = next
- next.Prev = nil
-
- // elem is last in list.
- case prev != nil && next == nil:
- l.Tail = prev
- prev.Next = nil
-
- // elem in middle of list.
- default:
- next.Prev = prev
- prev.Next = next
- }
-
- // Decr count
- l.len--
-}
-
-// Range calls 'fn' on every element from head forward in list.
-func (l *List[T]) Range(fn func(*Elem[T])) {
- if fn == nil {
- panic("nil function")
- }
- for elem := l.Head; elem != nil; elem = elem.Next {
- fn(elem)
- }
-}
-
-// RangeReverse calls 'fn' on every element from tail backward in list.
-func (l *List[T]) RangeReverse(fn func(*Elem[T])) {
- if fn == nil {
- panic("nil function")
- }
- for elem := l.Tail; elem != nil; elem = elem.Prev {
- fn(elem)
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/LICENSE b/vendor/codeberg.org/gruf/go-mangler/v2/LICENSE
deleted file mode 100644
index dffbdf0c9..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2023 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-mangler/v2/README.md b/vendor/codeberg.org/gruf/go-mangler/v2/README.md
deleted file mode 100644
index 636c2494c..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# go-mangler
-
-[Documentation](https://pkg.go.dev/codeberg.org/gruf/go-mangler).
-
-To put it simply is a bit of an odd library. It aims to provide incredibly fast, unique string outputs for all default supported input data types during a given runtime instance. See `mangler.String()`for supported types.
-
-It is useful, for example, for use as part of larger abstractions involving hashmaps. That was my particular usecase anyways...
-
-This package does make liberal use of the "unsafe" package.
-
-Benchmarks are below. Please note the more important thing to notice here is the relative difference in benchmark scores, the actual `ns/op`,`B/op`,`allocs/op` accounts for running through ~80 possible test cases, including some not-ideal situations.
-
-The choice of libraries in the benchmark are just a selection of libraries that could be used in a similar manner to this one, i.e. serializing in some manner.
-
-```
-go test -run=none -benchmem -gcflags=all='-l=4' -bench=.*
-goos: linux
-goarch: amd64
-pkg: codeberg.org/gruf/go-mangler
-cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
-BenchmarkMangle-8 1278526 966.0 ns/op 0 B/op 0 allocs/op
-BenchmarkMangleKnown-8 3443587 345.9 ns/op 0 B/op 0 allocs/op
-BenchmarkJSON-8 228962 4717 ns/op 1849 B/op 99 allocs/op
-BenchmarkLoosy-8 307194 3447 ns/op 776 B/op 65 allocs/op
-BenchmarkFmt-8 150254 7405 ns/op 1377 B/op 143 allocs/op
-BenchmarkFxmackerCbor-8 364411 3037 ns/op 1224 B/op 105 allocs/op
-BenchmarkMitchellhHashStructure-8 102272 11268 ns/op 8996 B/op 1000 allocs/op
-BenchmarkCnfStructhash-8 6789 168703 ns/op 288301 B/op 5779 allocs/op
-PASS
-ok codeberg.org/gruf/go-mangler 11.715s
-```
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/array.go b/vendor/codeberg.org/gruf/go-mangler/v2/array.go
deleted file mode 100644
index 6638a6e2d..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/array.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package mangler
-
-import (
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// iterArrayType returns a Mangler capable of iterating
-// and mangling the given array type currently in TypeIter{}.
-// note this will fetch sub-Mangler for array element type.
-func iterArrayType(t xunsafe.TypeIter) Mangler {
-
- // Array element type.
- elem := t.Type.Elem()
-
- // Get nested elem TypeIter with appropriate flags.
- flags := xunsafe.ReflectArrayElemFlags(t.Flag, elem)
- et := t.Child(elem, flags)
-
- // Get elem mangler.
- fn := loadOrGet(et)
- if fn == nil {
- return nil
- }
-
- // Array element in-memory size.
- esz := t.Type.Elem().Size()
-
- // No of elements.
- n := t.Type.Len()
- switch n {
- case 0:
- return empty_mangler
- case 1:
- return fn
- default:
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- for i := 0; i < n; i++ {
- // Mangle data at array index.
- offset := esz * uintptr(i)
- eptr := add(ptr, offset)
- buf = fn(buf, eptr)
- buf = append(buf, ',')
- }
-
- if n > 0 {
- // Drop final comma.
- buf = buf[:len(buf)-1]
- }
-
- return buf
- }
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/cache.go b/vendor/codeberg.org/gruf/go-mangler/v2/cache.go
deleted file mode 100644
index 0f6f71cd0..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/cache.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package mangler
-
-import (
- "sync/atomic"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-var manglers cache
-
-// cache is a concurrency-safe map[xunsafe.TypeInfo]Mangler
-// cache, designed for heavy reads but with unfortunately expensive
-// writes. it is designed such that after some initial load period
-// in which functions are cached by types, all future ops are reads.
-type cache struct{ p unsafe.Pointer }
-
-// Get will check cache for mangler func under key.
-func (c *cache) Get(t xunsafe.TypeInfo) Mangler {
- if p := c.load(); p != nil {
- return (*p)[t]
- }
- return nil
-}
-
-// Put will place given mangler func in cache under key, if not already exists.
-func (c *cache) Put(t xunsafe.TypeInfo, fn Mangler) {
- for {
- p := c.load()
-
- var cache map[xunsafe.TypeInfo]Mangler
-
- if p != nil {
- if _, ok := (*p)[t]; ok {
- return
- }
-
- cache = make(map[xunsafe.TypeInfo]Mangler, len(*p)+1)
- for key, value := range *p {
- cache[key] = value
- }
- } else {
- cache = make(map[xunsafe.TypeInfo]Mangler, 1)
- }
-
- cache[t] = fn
-
- if c.cas(p, &cache) {
- return
- }
- }
-}
-
-// load is a typed wrapper around atomic.LoadPointer().
-func (c *cache) load() *map[xunsafe.TypeInfo]Mangler {
- return (*map[xunsafe.TypeInfo]Mangler)(atomic.LoadPointer(&c.p))
-}
-
-// cas is a typed wrapper around atomic.CompareAndSwapPointer().
-func (c *cache) cas(old, new *map[xunsafe.TypeInfo]Mangler) bool {
- return atomic.CompareAndSwapPointer(&c.p, unsafe.Pointer(old), unsafe.Pointer(new))
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/helpers.go b/vendor/codeberg.org/gruf/go-mangler/v2/helpers.go
deleted file mode 100644
index 0b07bba13..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/helpers.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package mangler
-
-import (
- "unsafe"
-)
-
-func append_uint16(b []byte, u uint16) []byte {
- return append(b, // LE
- byte(u),
- byte(u>>8),
- )
-}
-
-func append_uint32(b []byte, u uint32) []byte {
- return append(b, // LE
- byte(u),
- byte(u>>8),
- byte(u>>16),
- byte(u>>24),
- )
-}
-
-func append_uint64(b []byte, u uint64) []byte {
- return append(b, // LE
- byte(u),
- byte(u>>8),
- byte(u>>16),
- byte(u>>24),
- byte(u>>32),
- byte(u>>40),
- byte(u>>48),
- byte(u>>56),
- )
-}
-
-func empty_mangler(buf []byte, _ unsafe.Pointer) []byte {
- return buf
-}
-
-// add returns the ptr addition of starting ptr and a delta.
-func add(ptr unsafe.Pointer, delta uintptr) unsafe.Pointer {
- return unsafe.Pointer(uintptr(ptr) + delta)
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/load.go b/vendor/codeberg.org/gruf/go-mangler/v2/load.go
deleted file mode 100644
index 8355c5f3c..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/load.go
+++ /dev/null
@@ -1,150 +0,0 @@
-package mangler
-
-import (
- "reflect"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// loadOrStore first checks the cache for a Mangler
-// function, else generates one by calling get().
-// note: this does store generated funcs in cache.
-func loadOrStore(t xunsafe.TypeIter) Mangler {
-
- // Get cache key.
- key := t.TypeInfo
-
- // Check cache for func.
- fn := manglers.Get(key)
-
- if fn == nil {
- // Generate new mangler
- // func for this type.
- fn = get(t)
- if fn == nil {
- return nil
- }
-
- // Store func in cache.
- manglers.Put(key, fn)
- }
-
- return fn
-}
-
-// loadOrGet first checks the cache for a Mangler
-// function, else generates one by calling get().
-// note: it does not store the function in cache.
-func loadOrGet(t xunsafe.TypeIter) Mangler {
-
- // Check cache for mangler func.
- fn := manglers.Get(t.TypeInfo)
-
- if fn == nil {
- // Generate new mangler
- // func for this type.
- fn = get(t)
- }
-
- return fn
-}
-
-var (
- // reflectTypeType is the reflected type of the reflect type,
- // used in fmt.get() to prevent iter of internal ABI structs.
- reflectTypeType = reflect.TypeOf(reflect.TypeOf(0))
-)
-
-// get attempts to generate a new Mangler function
-// capable of mangling a ptr of given type information.
-func get(t xunsafe.TypeIter) (fn Mangler) {
- defer func() {
- if fn == nil {
- // nothing more
- // we can do.
- return
- }
-
- if t.Parent != nil {
- // We're only interested
- // in wrapping top-level.
- return
- }
-
- // Get reflected type ptr for prefix.
- ptr := xunsafe.ReflectTypeData(t.Type)
- uptr := uintptr(ptr)
-
- // Outer fn.
- mng := fn
-
- // Wrap the mangler func to prepend type pointer.
- fn = func(buf []byte, ptr unsafe.Pointer) []byte {
- buf = append_uint64(buf, uint64(uptr))
- return mng(buf, ptr)
- }
- }()
-
- if t.Type == nil {
- // nil type.
- return nil
- }
-
- if t.Type == reflectTypeType {
- // DO NOT iterate down internal ABI
- // types, some are in non-GC memory.
- return nil
- }
-
- // Check supports known method receiver.
- if fn := getMethodType(t); fn != nil {
- return fn
- }
-
- if !visit(t) {
- // On type recursion simply
- // mangle as raw pointer.
- return mangle_int
- }
-
- // Get func for type kind.
- switch t.Type.Kind() {
- case reflect.Pointer:
- return derefPointerType(t)
- case reflect.Struct:
- return iterStructType(t)
- case reflect.Array:
- return iterArrayType(t)
- case reflect.Slice:
- return iterSliceType(t)
- case reflect.Map:
- return iterMapType(t)
- case reflect.String:
- return mangle_string
- case reflect.Bool:
- return mangle_bool
- case reflect.Int,
- reflect.Uint,
- reflect.Uintptr:
- return mangle_int
- case reflect.Int8, reflect.Uint8:
- return mangle_8bit
- case reflect.Int16, reflect.Uint16:
- return mangle_16bit
- case reflect.Int32, reflect.Uint32:
- return mangle_32bit
- case reflect.Int64, reflect.Uint64:
- return mangle_64bit
- case reflect.Float32:
- return mangle_32bit
- case reflect.Float64:
- return mangle_64bit
- case reflect.Complex64:
- return mangle_64bit
- case reflect.Complex128:
- return mangle_128bit
- default:
- return nil
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/mangle.go b/vendor/codeberg.org/gruf/go-mangler/v2/mangle.go
deleted file mode 100644
index 0c746fc95..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/mangle.go
+++ /dev/null
@@ -1,93 +0,0 @@
-package mangler
-
-import (
- "fmt"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// Mangler is a function that will take an input value of known type,
-// and append it in mangled serialized form to the given byte buffer.
-type Mangler func(buf []byte, ptr unsafe.Pointer) []byte
-
-// Get will fetch the Mangler function for given runtime type information.
-// The required argument is of type xunsafe.TypeIter{} as unsafe pointer
-// access requires further contextual information like type nesting.
-func Get(t xunsafe.TypeIter) Mangler {
- t.Parent = nil // enforce type prefix
- fn := loadOrStore(t)
- if fn == nil {
- panic(fmt.Sprintf("cannot mangle type: %s", t.Type))
- }
- return fn
-}
-
-// GetNoLoad is functionally similar to Get(),
-// without caching the resulting Mangler.
-func GetNoLoad(t xunsafe.TypeIter) Mangler {
- t.Parent = nil // enforce type prefix
- fn := loadOrGet(t)
- if fn == nil {
- panic(fmt.Sprintf("cannot mangle type: %s", t.Type))
- }
- return fn
-}
-
-// Append will append the mangled form of input value 'a' to buffer 'b'.
-//
-// See mangler.String() for more information on mangled output.
-func Append(b []byte, a any) []byte {
- t := xunsafe.TypeIterFrom(a)
- p := xunsafe.UnpackEface(a)
- return Get(t)(b, p)
-}
-
-// AppendMulti appends all mangled forms of input value(s) 'a' to buffer 'b'
-// separated by colon characters. When all type manglers are currently cached
-// for all types in 'a', this will be faster than multiple calls to Append().
-//
-// See mangler.String() for more information on mangled output.
-func AppendMulti(b []byte, a ...any) []byte {
- if p := manglers.load(); p != nil {
- b4 := len(b)
- for _, a := range a {
- t := xunsafe.TypeIterFrom(a)
- m := (*p)[t.TypeInfo]
- if m == nil {
- b = b[:b4]
- goto slow
- }
- b = m(b, xunsafe.UnpackEface(a))
- b = append(b, '.')
- }
- return b
- }
-slow:
- for _, a := range a {
- b = Append(b, a)
- b = append(b, '.')
- }
- return b
-}
-
-// String will return the mangled format of input value 'a'. This
-// mangled output will be unique for all default supported input types
-// during a single runtime instance. Uniqueness cannot be guaranteed
-// between separate runtime instances (whether running concurrently, or
-// the same application running at different times).
-//
-// The exact formatting of the output data should not be relied upon,
-// only that it is unique given the above constraints. Generally though,
-// the mangled output is the binary formatted text of given input data.
-//
-// Uniqueness is guaranteed for similar input data of differing types
-// (e.g. string("hello world") vs. []byte("hello world")) by prefixing
-// mangled output with the input data's runtime type pointer.
-//
-// Default supported types include all concrete (i.e. non-interface{})
-// data types, and interfaces implementing Mangleable{}.
-func String(a any) string {
- b := Append(make([]byte, 0, 32), a)
- return *(*string)(unsafe.Pointer(&b))
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/manglers.go b/vendor/codeberg.org/gruf/go-mangler/v2/manglers.go
deleted file mode 100644
index 79bfe3c00..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/manglers.go
+++ /dev/null
@@ -1,113 +0,0 @@
-package mangler
-
-import (
- "unsafe"
- _ "unsafe"
-)
-
-// Notes:
-// the use of unsafe conversion from the direct interface values to
-// the chosen types in each of the below functions allows us to convert
-// not only those types directly, but anything type-aliased to those
-// types. e.g. `time.Duration` directly as int64.
-
-func mangle_string(buf []byte, ptr unsafe.Pointer) []byte {
- return append(buf, *(*string)(ptr)...)
-}
-
-func mangle_string_slice(buf []byte, ptr unsafe.Pointer) []byte {
- s := *(*[]string)(ptr)
- for _, s := range s {
- buf = append(buf, s...)
- buf = append(buf, ',')
- }
- if len(s) > 0 {
- buf = buf[:len(buf)-1]
- }
- return buf
-}
-
-func mangle_bool(buf []byte, ptr unsafe.Pointer) []byte {
- if *(*bool)(ptr) {
- return append(buf, '1')
- }
- return append(buf, '0')
-}
-
-func mangle_bool_slice(buf []byte, ptr unsafe.Pointer) []byte {
- for _, b := range *(*[]bool)(ptr) {
- if b {
- buf = append(buf, '1')
- } else {
- buf = append(buf, '0')
- }
- }
- return buf
-}
-
-func mangle_8bit(buf []byte, ptr unsafe.Pointer) []byte {
- return append(buf, *(*uint8)(ptr))
-}
-
-func mangle_8bit_slice(buf []byte, ptr unsafe.Pointer) []byte {
- return append(buf, *(*[]uint8)(ptr)...)
-}
-
-func mangle_16bit(buf []byte, ptr unsafe.Pointer) []byte {
- return append_uint16(buf, *(*uint16)(ptr))
-}
-
-func mangle_16bit_slice(buf []byte, ptr unsafe.Pointer) []byte {
- for _, u := range *(*[]uint16)(ptr) {
- buf = append_uint16(buf, u)
- }
- return buf
-}
-
-func mangle_32bit(buf []byte, ptr unsafe.Pointer) []byte {
- return append_uint32(buf, *(*uint32)(ptr))
-}
-
-func mangle_32bit_slice(buf []byte, ptr unsafe.Pointer) []byte {
- for _, u := range *(*[]uint32)(ptr) {
- buf = append_uint32(buf, u)
- }
- return buf
-}
-
-func mangle_64bit(buf []byte, ptr unsafe.Pointer) []byte {
- return append_uint64(buf, *(*uint64)(ptr))
-}
-
-func mangle_64bit_slice(buf []byte, ptr unsafe.Pointer) []byte {
- for _, u := range *(*[]uint64)(ptr) {
- buf = append_uint64(buf, u)
- }
- return buf
-}
-
-func mangle_int(buf []byte, ptr unsafe.Pointer) []byte {
- return append_uint64(buf, uint64(*(*uint)(ptr)))
-}
-
-func mangle_int_slice(buf []byte, ptr unsafe.Pointer) []byte {
- for _, u := range *(*[]uint)(ptr) {
- buf = append_uint64(buf, uint64(u))
- }
- return buf
-}
-
-func mangle_128bit(buf []byte, ptr unsafe.Pointer) []byte {
- u2 := *(*[2]uint64)(ptr)
- buf = append_uint64(buf, u2[0])
- buf = append_uint64(buf, u2[1])
- return buf
-}
-
-func mangle_128bit_slice(buf []byte, ptr unsafe.Pointer) []byte {
- for _, u2 := range *(*[][2]uint64)(ptr) {
- buf = append_uint64(buf, u2[0])
- buf = append_uint64(buf, u2[1])
- }
- return buf
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/map.go b/vendor/codeberg.org/gruf/go-mangler/v2/map.go
deleted file mode 100644
index 986aca4b0..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/map.go
+++ /dev/null
@@ -1,80 +0,0 @@
-package mangler
-
-import (
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// iterMapType returns a Mangler capable of iterating
-// and mangling the given map type currently in TypeIter{}.
-// note this will fetch sub-Manglers for key / value types.
-func iterMapType(t xunsafe.TypeIter) Mangler {
-
- // Key / value types.
- key := t.Type.Key()
- elem := t.Type.Elem()
-
- // Get nested k / v TypeIters with appropriate flags.
- flagsKey := xunsafe.ReflectMapKeyFlags(key)
- flagsVal := xunsafe.ReflectMapElemFlags(elem)
- kt := t.Child(key, flagsKey)
- vt := t.Child(elem, flagsVal)
-
- // Get key mangler.
- kfn := loadOrGet(kt)
- if kfn == nil {
- return nil
- }
-
- // Get value mangler.
- vfn := loadOrGet(vt)
- if vfn == nil {
- return nil
- }
-
- // Final map type.
- rtype := t.Type
- flags := t.Flag
-
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- if ptr == nil || *(*unsafe.Pointer)(ptr) == nil {
- // Append nil indicator.
- buf = append(buf, '0')
- return buf
- }
-
- // Build reflect value, and then a map iterator.
- v := xunsafe.BuildReflectValue(rtype, ptr, flags)
- i := xunsafe.GetMapIter(v)
-
- // Before len.
- l := len(buf)
-
- // Append not-nil flag.
- buf = append(buf, '1')
-
- for i.Next() {
- // Pass to map key func.
- ptr = xunsafe.Map_Key(i)
- buf = kfn(buf, ptr)
-
- // Add key seperator.
- buf = append(buf, ':')
-
- // Pass to map elem func.
- ptr = xunsafe.Map_Elem(i)
- buf = vfn(buf, ptr)
-
- // Add comma seperator.
- buf = append(buf, ',')
- }
-
- if len(buf) != l {
- // Drop final comma.
- buf = buf[:len(buf)-1]
- }
-
- return buf
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/method.go b/vendor/codeberg.org/gruf/go-mangler/v2/method.go
deleted file mode 100644
index 7a938d6ae..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/method.go
+++ /dev/null
@@ -1,105 +0,0 @@
-package mangler
-
-import (
- "reflect"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-var (
- // mangleable type for implement checks.
- mangleableType = reflect.TypeFor[Mangleable]()
-)
-
-type Mangleable interface {
- Mangle(dst []byte) []byte
-}
-
-// getMethodType returns a *possible* Mangler to handle case
-// of a type that implements any known interface{} types, else nil.
-func getMethodType(t xunsafe.TypeIter) Mangler {
- switch {
- case t.Type.Implements(mangleableType):
- switch t.Type.Kind() {
- case reflect.Interface:
- return getInterfaceMangleableType(t)
- default:
- return getConcreteMangleableType(t)
- }
- default:
- return nil
- }
-}
-
-// getInterfaceMangleableType returns a Mangler to handle case of an interface{}
-// type that implements Mangleable{}, i.e. Mangleable{} itself and any superset of.
-func getInterfaceMangleableType(t xunsafe.TypeIter) Mangler {
- switch t.Indirect() && !t.IfaceIndir() {
- case true:
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- ptr = *(*unsafe.Pointer)(ptr)
- if ptr == nil || (*xunsafe.Abi_NonEmptyInterface)(ptr).Data == nil {
- buf = append(buf, '0')
- return buf
- }
- v := *(*Mangleable)(ptr)
- buf = append(buf, '1')
- buf = v.Mangle(buf)
- return buf
- }
- case false:
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- if ptr == nil || (*xunsafe.Abi_NonEmptyInterface)(ptr).Data == nil {
- buf = append(buf, '0')
- return buf
- }
- v := *(*Mangleable)(ptr)
- buf = append(buf, '1')
- buf = v.Mangle(buf)
- return buf
- }
- default:
- panic("unreachable")
- }
-}
-
-// getConcreteMangleableType returns a Manlger to handle case of concrete
-// (i.e. non-interface{}) type that has a Mangleable{} method receiver.
-func getConcreteMangleableType(t xunsafe.TypeIter) Mangler {
- itab := xunsafe.GetIfaceITab[Mangleable](t.Type)
- switch {
- case t.Indirect() && !t.IfaceIndir():
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- ptr = *(*unsafe.Pointer)(ptr)
- if ptr == nil {
- buf = append(buf, '0')
- return buf
- }
- v := *(*Mangleable)(xunsafe.PackIface(itab, ptr))
- buf = append(buf, '1')
- buf = v.Mangle(buf)
- return buf
- }
- case t.Type.Kind() == reflect.Pointer && t.Type.Implements(mangleableType):
- // if the interface implementation is received by
- // value type, the pointer type will also support
- // it but it requires an extra dereference check.
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- if ptr == nil {
- buf = append(buf, '0')
- return buf
- }
- v := *(*Mangleable)(xunsafe.PackIface(itab, ptr))
- buf = append(buf, '1')
- buf = v.Mangle(buf)
- return buf
- }
- default:
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- v := *(*Mangleable)(xunsafe.PackIface(itab, ptr))
- buf = v.Mangle(buf)
- return buf
- }
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/pointer.go b/vendor/codeberg.org/gruf/go-mangler/v2/pointer.go
deleted file mode 100644
index d732b2f67..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/pointer.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package mangler
-
-import (
- "reflect"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// derefPointerType returns a Mangler capable of dereferencing
-// and formatting the given pointer type currently in TypeIter{}.
-// note this will fetch a sub-Mangler for resulting value type.
-func derefPointerType(t xunsafe.TypeIter) Mangler {
- var derefs int
- var indirects int64
- rtype := t.Type
- flags := t.Flag
-
- // Iteratively dereference pointer types.
- for rtype.Kind() == reflect.Pointer {
-
- // Only if this is actual indirect memory do we
- // perform a derefence, otherwise we just skip over
- // and increase the dereference indicator, i.e. '1'.
- if flags&xunsafe.Reflect_flagIndir != 0 {
- indirects |= 1 << derefs
- }
- derefs++
-
- // Get next elem type.
- rtype = rtype.Elem()
-
- // Get next set of dereferenced element type flags.
- flags = xunsafe.ReflectPointerElemFlags(flags, rtype)
- }
-
- // Ensure this is a reasonable number of derefs.
- if derefs > 4*int(unsafe.Sizeof(indirects)) {
- return nil
- }
-
- // Wrap value as TypeIter.
- vt := t.Child(rtype, flags)
-
- // Get value mangler.
- fn := loadOrGet(vt)
- if fn == nil {
- return nil
- }
-
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- for i := 0; i < derefs; i++ {
- switch {
- case indirects&1<<i == 0:
- // No dereference needed.
- buf = append(buf, '1')
-
- case ptr == nil:
- // Nil value, return here.
- buf = append(buf, '0')
- return buf
-
- default:
- // Further deref ptr.
- buf = append(buf, '1')
- ptr = *(*unsafe.Pointer)(ptr)
- }
- }
-
- if ptr == nil {
- // Final nil val check.
- buf = append(buf, '0')
- return buf
- }
-
- // Mangle fully deref'd.
- buf = append(buf, '1')
- buf = fn(buf, ptr)
- return buf
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/slice.go b/vendor/codeberg.org/gruf/go-mangler/v2/slice.go
deleted file mode 100644
index 0a68c0575..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/slice.go
+++ /dev/null
@@ -1,95 +0,0 @@
-package mangler
-
-import (
- "reflect"
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// iterSliceType returns a Mangler capable of iterating
-// and mangling the given slice type currently in TypeIter{}.
-// note this will fetch sub-Mangler for slice element type.
-func iterSliceType(t xunsafe.TypeIter) Mangler {
-
- // Get nested element type.
- elem := t.Type.Elem()
- esz := elem.Size()
-
- // Get nested elem TypeIter{} with flags.
- flags := xunsafe.ReflectSliceElemFlags(elem)
- et := t.Child(elem, flags)
-
- // Prefer to use a known slice mangler func.
- if fn := mangleKnownSlice(et); fn != nil {
- return fn
- }
-
- // Get elem mangler.
- fn := loadOrGet(et)
- if fn == nil {
- return nil
- }
-
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- // Get data as unsafe slice header.
- hdr := (*xunsafe.Unsafeheader_Slice)(ptr)
- if hdr == nil || hdr.Data == nil {
-
- // Append nil indicator.
- buf = append(buf, '0')
- return buf
- }
-
- // Append not-nil flag.
- buf = append(buf, '1')
-
- for i := 0; i < hdr.Len; i++ {
- // Mangle at array index.
- offset := esz * uintptr(i)
- ptr = add(hdr.Data, offset)
- buf = fn(buf, ptr)
- buf = append(buf, ',')
- }
-
- if hdr.Len > 0 {
- // Drop final comma.
- buf = buf[:len(buf)-1]
- }
-
- return buf
- }
-}
-
-// mangleKnownSlice loads a Mangler function for a
-// known slice-of-element type (in this case, primtives).
-func mangleKnownSlice(t xunsafe.TypeIter) Mangler {
- switch t.Type.Kind() {
- case reflect.String:
- return mangle_string_slice
- case reflect.Bool:
- return mangle_bool_slice
- case reflect.Int,
- reflect.Uint,
- reflect.Uintptr:
- return mangle_int_slice
- case reflect.Int8, reflect.Uint8:
- return mangle_8bit_slice
- case reflect.Int16, reflect.Uint16:
- return mangle_16bit_slice
- case reflect.Int32, reflect.Uint32:
- return mangle_32bit_slice
- case reflect.Int64, reflect.Uint64:
- return mangle_64bit_slice
- case reflect.Float32:
- return mangle_32bit_slice
- case reflect.Float64:
- return mangle_64bit_slice
- case reflect.Complex64:
- return mangle_64bit_slice
- case reflect.Complex128:
- return mangle_128bit_slice
- default:
- return nil
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/struct.go b/vendor/codeberg.org/gruf/go-mangler/v2/struct.go
deleted file mode 100644
index e9672bf2b..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/struct.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package mangler
-
-import (
- "unsafe"
-
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// field stores the minimum necessary
-// data for iterating and mangling
-// each field in a given struct.
-type field struct {
- mangle Mangler
- offset uintptr
-}
-
-// iterStructType returns a Mangler capable of iterating
-// and mangling the given struct type currently in TypeIter{}.
-// note this will fetch sub-Manglers for each struct field.
-func iterStructType(t xunsafe.TypeIter) Mangler {
-
- // Number of struct fields.
- n := t.Type.NumField()
-
- // Gather mangler functions.
- fields := make([]field, n)
- for i := 0; i < n; i++ {
-
- // Get struct field at index.
- sfield := t.Type.Field(i)
- rtype := sfield.Type
-
- // Get nested field TypeIter with appropriate flags.
- flags := xunsafe.ReflectStructFieldFlags(t.Flag, rtype)
- ft := t.Child(sfield.Type, flags)
-
- // Get field mangler.
- fn := loadOrGet(ft)
- if fn == nil {
- return nil
- }
-
- // Set field info.
- fields[i] = field{
- mangle: fn,
- offset: sfield.Offset,
- }
- }
-
- // Handle no. fields.
- switch len(fields) {
- case 0:
- return empty_mangler
- case 1:
- return fields[0].mangle
- default:
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- for i := range fields {
- // Get struct field ptr via offset.
- fptr := add(ptr, fields[i].offset)
-
- // Mangle the struct field data.
- buf = fields[i].mangle(buf, fptr)
- buf = append(buf, ',')
- }
-
- if len(fields) > 0 {
- // Drop final comma.
- buf = buf[:len(buf)-1]
- }
-
- return buf
- }
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/type.go b/vendor/codeberg.org/gruf/go-mangler/v2/type.go
deleted file mode 100644
index 71be7f0b4..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/v2/type.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package mangler
-
-import (
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// visit checks if current type has already
-// appeared in the TypeIter{}'s parent heirarchy.
-func visit(iter xunsafe.TypeIter) bool {
- t := iter.Type
-
- // Check if type is already encountered further up tree.
- for node := iter.Parent; node != nil; node = node.Parent {
- if node.Type == t {
- return false
- }
- }
-
- return true
-}
diff --git a/vendor/codeberg.org/gruf/go-maps/LICENSE b/vendor/codeberg.org/gruf/go-maps/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-maps/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-maps/README.md b/vendor/codeberg.org/gruf/go-maps/README.md
deleted file mode 100644
index cf1aea644..000000000
--- a/vendor/codeberg.org/gruf/go-maps/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# go-maps
-
-Provides a selection of hashmaps (or, "dictionaries") with features exceeding that of the default Go runtime hashmap.
-
-Includes:
-- OrderedMap
-- LRUMap
diff --git a/vendor/codeberg.org/gruf/go-maps/common.go b/vendor/codeberg.org/gruf/go-maps/common.go
deleted file mode 100644
index 0c92b41a2..000000000
--- a/vendor/codeberg.org/gruf/go-maps/common.go
+++ /dev/null
@@ -1,293 +0,0 @@
-package maps
-
-import (
- "fmt"
- "reflect"
-
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-kv"
-)
-
-// ordered provides a common ordered hashmap base, storing order in a doubly-linked list.
-type ordered[K comparable, V any] struct {
- hmap map[K]*elem[K, V]
- list list[K, V]
- pool []*elem[K, V]
- rnly bool
-}
-
-// write_check panics if map is not in a safe-state to write to.
-func (m *ordered[K, V]) write_check() {
- if m.rnly {
- panic("map write during read loop")
- }
-}
-
-// Has returns whether key exists in map.
-func (m *ordered[K, V]) Has(key K) bool {
- _, ok := m.hmap[key]
- return ok
-}
-
-// Delete will delete given key from map, returns false if not found.
-func (m *ordered[K, V]) Delete(key K) bool {
- // Ensure safe
- m.write_check()
-
- // Look for existing elem
- elem, ok := m.hmap[key]
- if !ok {
- return false
- }
-
- // Drop from list
- m.list.Unlink(elem)
-
- // Delete from map
- delete(m.hmap, key)
-
- // Return to pool
- m.free(elem)
-
- return true
-}
-
-// Range passes given function over the requested range of the map.
-func (m *ordered[K, V]) Range(start, length int, fn func(int, K, V)) {
- // Nil check
- if fn == nil {
- panic("nil func")
- }
-
- // Disallow writes
- m.rnly = true
- defer func() {
- m.rnly = false
- }()
-
- switch end := start + length; {
- // No loop to iterate
- case length == 0:
- if start < 0 || (m.list.len > 0 && start >= m.list.len) {
- panic("index out of bounds")
- }
-
- // Step backwards
- case length < 0:
- // Check loop indices are within map bounds
- if end < -1 || start >= m.list.len || m.list.len == 0 {
- panic("index out of bounds")
- }
-
- // Get starting index elem
- elem := m.list.Index(start)
-
- for i := start; i > end; i-- {
- fn(i, elem.K, elem.V)
- elem = elem.prev
- }
-
- // Step forwards
- case length > 0:
- // Check loop indices are within map bounds
- if start < 0 || end > m.list.len || m.list.len == 0 {
- panic("index out of bounds")
- }
-
- // Get starting index elem
- elem := m.list.Index(start)
-
- for i := start; i < end; i++ {
- fn(i, elem.K, elem.V)
- elem = elem.next
- }
- }
-}
-
-// RangeIf passes given function over the requested range of the map. Returns early on 'fn' -> false.
-func (m *ordered[K, V]) RangeIf(start, length int, fn func(int, K, V) bool) {
- // Nil check
- if fn == nil {
- panic("nil func")
- }
-
- // Disallow writes
- m.rnly = true
- defer func() {
- m.rnly = false
- }()
-
- switch end := start + length; {
- // No loop to iterate
- case length == 0:
- if start < 0 || (m.list.len > 0 && start >= m.list.len) {
- panic("index out of bounds")
- }
-
- // Step backwards
- case length < 0:
- // Check loop indices are within map bounds
- if end < -1 || start >= m.list.len || m.list.len == 0 {
- panic("index out of bounds")
- }
-
- // Get starting index elem
- elem := m.list.Index(start)
-
- for i := start; i > end; i-- {
- if !fn(i, elem.K, elem.V) {
- return
- }
- elem = elem.prev
- }
-
- // Step forwards
- case length > 0:
- // Check loop indices are within map bounds
- if start < 0 || end > m.list.len || m.list.len == 0 {
- panic("index out of bounds")
- }
-
- // Get starting index elem
- elem := m.list.Index(start)
-
- for i := start; i < end; i++ {
- if !fn(i, elem.K, elem.V) {
- return
- }
- elem = elem.next
- }
- }
-}
-
-// Truncate will truncate the map from the back by given amount, passing dropped elements to given function.
-func (m *ordered[K, V]) Truncate(sz int, fn func(K, V)) {
- // Check size withing bounds
- if sz > m.list.len {
- panic("index out of bounds")
- }
-
- // Nil check
- if fn == nil {
- fn = func(K, V) {}
- }
-
- // Disallow writes
- m.rnly = true
- defer func() {
- m.rnly = false
- }()
-
- for i := 0; i < sz; i++ {
- // Pop current tail
- elem := m.list.tail
- m.list.Unlink(elem)
-
- // Delete from map
- delete(m.hmap, elem.K)
-
- // Pass dropped to func
- fn(elem.K, elem.V)
-
- // Release to pool
- m.free(elem)
- }
-}
-
-// Len returns the current length of the map.
-func (m *ordered[K, V]) Len() int {
- return m.list.len
-}
-
-// format implements fmt.Formatter, allowing performant string formatting of map.
-func (m *ordered[K, V]) format(rtype reflect.Type, state fmt.State, verb rune) {
- var (
- kvbuf byteutil.Buffer
- field kv.Field
- vbose bool
- )
-
- switch {
- // Only handle 'v' verb
- case verb != 'v':
- panic("invalid verb '" + string(verb) + "' for map")
-
- // Prefix with type when verbose
- case state.Flag('#'):
- state.Write([]byte(rtype.String()))
- }
-
- // Disallow writes
- m.rnly = true
- defer func() {
- m.rnly = false
- }()
-
- // Write map opening brace
- state.Write([]byte{'{'})
-
- if m.list.len > 0 {
- // Preallocate buffer
- kvbuf.Guarantee(64)
-
- // Start at index 0
- elem := m.list.head
-
- for i := 0; i < m.list.len-1; i++ {
- // Append formatted key-val pair to state
- field.K = fmt.Sprint(elem.K)
- field.V = elem.V
- field.AppendFormat(&kvbuf, vbose)
- _, _ = state.Write(kvbuf.B)
- kvbuf.Reset()
-
- // Prepare buffer with comma separator
- kvbuf.B = append(kvbuf.B, `, `...)
-
- // Jump to next in list
- elem = elem.next
- }
-
- // Append formatted key-val pair to state
- field.K = fmt.Sprint(elem.K)
- field.V = elem.V
- field.AppendFormat(&kvbuf, vbose)
- _, _ = state.Write(kvbuf.B)
- }
-
- // Write map closing brace
- state.Write([]byte{'}'})
-}
-
-// Std returns a clone of map's data in the standard library equivalent map type.
-func (m *ordered[K, V]) Std() map[K]V {
- std := make(map[K]V, m.list.len)
- for _, elem := range m.hmap {
- std[elem.K] = elem.V
- }
- return std
-}
-
-// alloc will acquire list element from pool, or allocate new.
-func (m *ordered[K, V]) alloc() *elem[K, V] {
- if len(m.pool) == 0 {
- return &elem[K, V]{}
- }
- idx := len(m.pool) - 1
- elem := m.pool[idx]
- m.pool = m.pool[:idx]
- return elem
-}
-
-// free will reset elem fields and place back in pool.
-func (m *ordered[K, V]) free(elem *elem[K, V]) {
- var (
- zk K
- zv V
- )
- elem.K = zk
- elem.V = zv
- elem.next = nil
- elem.prev = nil
- m.pool = append(m.pool, elem)
-}
diff --git a/vendor/codeberg.org/gruf/go-maps/list.go b/vendor/codeberg.org/gruf/go-maps/list.go
deleted file mode 100644
index 2d960976b..000000000
--- a/vendor/codeberg.org/gruf/go-maps/list.go
+++ /dev/null
@@ -1,154 +0,0 @@
-package maps
-
-// list is a doubly-linked list containing elemnts with key-value pairs of given generic parameter types.
-type list[K comparable, V any] struct {
- head *elem[K, V]
- tail *elem[K, V]
- len int
-}
-
-// Index returns the element at index from list.
-func (l *list[K, V]) Index(idx int) *elem[K, V] {
- switch {
- // Idx in first half
- case idx < l.len/2:
- elem := l.head
- for i := 0; i < idx; i++ {
- elem = elem.next
- }
- return elem
-
- // Index in last half
- default:
- elem := l.tail
- for i := l.len - 1; i > idx; i-- {
- elem = elem.prev
- }
- return elem
- }
-}
-
-// PushFront will push the given element to the front of the list.
-func (l *list[K, V]) PushFront(elem *elem[K, V]) {
- if l.len == 0 {
- // Set new tail + head
- l.head = elem
- l.tail = elem
-
- // Link elem to itself
- elem.next = elem
- elem.prev = elem
- } else {
- oldHead := l.head
-
- // Link to old head
- elem.next = oldHead
- oldHead.prev = elem
-
- // Link up to tail
- elem.prev = l.tail
- l.tail.next = elem
-
- // Set new head
- l.head = elem
- }
-
- // Incr count
- l.len++
-}
-
-// PushBack will push the given element to the back of the list.
-func (l *list[K, V]) PushBack(elem *elem[K, V]) {
- if l.len == 0 {
- // Set new tail + head
- l.head = elem
- l.tail = elem
-
- // Link elem to itself
- elem.next = elem
- elem.prev = elem
- } else {
- oldTail := l.tail
-
- // Link up to head
- elem.next = l.head
- l.head.prev = elem
-
- // Link to old tail
- elem.prev = oldTail
- oldTail.next = elem
-
- // Set new tail
- l.tail = elem
- }
-
- // Incr count
- l.len++
-}
-
-// PopTail will pop the current tail of the list, returns nil if empty.
-func (l *list[K, V]) PopTail() *elem[K, V] {
- if l.len == 0 {
- return nil
- }
- elem := l.tail
- l.Unlink(elem)
- return elem
-}
-
-// Unlink will unlink the given element from the doubly-linked list chain.
-func (l *list[K, V]) Unlink(elem *elem[K, V]) {
- if l.len <= 1 {
- // Drop elem's links
- elem.next = nil
- elem.prev = nil
-
- // Only elem in list
- l.head = nil
- l.tail = nil
- l.len = 0
- return
- }
-
- // Get surrounding elems
- next := elem.next
- prev := elem.prev
-
- // Relink chain
- next.prev = prev
- prev.next = next
-
- switch elem {
- // Set new head
- case l.head:
- l.head = next
-
- // Set new tail
- case l.tail:
- l.tail = prev
- }
-
- // Drop elem's links
- elem.next = nil
- elem.prev = nil
-
- // Decr count
- l.len--
-}
-
-// elem represents an element in a doubly-linked list.
-type elem[K comparable, V any] struct {
- next *elem[K, V]
- prev *elem[K, V]
- K K
- V V
-}
-
-// allocElems will allocate a slice of empty elements of length.
-func allocElems[K comparable, V any](i int) []*elem[K, V] {
- s := make([]*elem[K, V], i)
- for i := range s {
- s[i] = &elem[K, V]{}
- }
- return s
-}
diff --git a/vendor/codeberg.org/gruf/go-maps/lru.go b/vendor/codeberg.org/gruf/go-maps/lru.go
deleted file mode 100644
index 06ea2ab10..000000000
--- a/vendor/codeberg.org/gruf/go-maps/lru.go
+++ /dev/null
@@ -1,153 +0,0 @@
-package maps
-
-import (
- "fmt"
- "reflect"
-)
-
-// LRU provides an ordered hashmap implementation that keeps elements ordered according to last recently used (hence, LRU).
-type LRUMap[K comparable, V any] struct {
- ordered[K, V]
- size int
-}
-
-// NewLRU returns a new instance of LRUMap with given initializing length and maximum capacity.
-func NewLRU[K comparable, V any](len, cap int) *LRUMap[K, V] {
- m := new(LRUMap[K, V])
- m.Init(len, cap)
- return m
-}
-
-// Init will initialize this map with initial length and maximum capacity.
-func (m *LRUMap[K, V]) Init(len, cap int) {
- if cap <= 0 {
- panic("lru cap must be greater than zero")
- } else if m.pool != nil {
- panic("lru map already initialized")
- }
- m.ordered.hmap = make(map[K]*elem[K, V], len)
- m.ordered.pool = allocElems[K, V](len)
- m.size = cap
-}
-
-// Get will fetch value for given key from map, in the process pushing it to the front of the map. Returns false if not found.
-func (m *LRUMap[K, V]) Get(key K) (V, bool) {
- if elem, ok := m.hmap[key]; ok {
- // Ensure safe
- m.write_check()
-
- // Unlink elem from list
- m.list.Unlink(elem)
-
- // Push to front of list
- m.list.PushFront(elem)
-
- return elem.V, true
- }
- var z V // zero value
- return z, false
-}
-
-// Add will add the given key-value pair to the map, pushing them to the front of the map. Returns false if already exists. Evicts old at maximum capacity.
-func (m *LRUMap[K, V]) Add(key K, value V) bool {
- return m.AddWithHook(key, value, nil)
-}
-
-// AddWithHook performs .Add() but passing any evicted entry to given hook function.
-func (m *LRUMap[K, V]) AddWithHook(key K, value V, evict func(K, V)) bool {
- // Ensure safe
- m.write_check()
-
- // Look for existing elem
- elem, ok := m.hmap[key]
- if ok {
- return false
- }
-
- if m.list.len >= m.size {
- // We're at capacity, sir!
- // Pop current tail elem
- elem = m.list.PopTail()
-
- if evict != nil {
- // Pass to evict hook
- evict(elem.K, elem.V)
- }
-
- // Delete key from map
- delete(m.hmap, elem.K)
- } else {
- // Allocate elem
- elem = m.alloc()
- }
-
- // Set elem
- elem.K = key
- elem.V = value
-
- // Add element map entry
- m.hmap[key] = elem
-
- // Push to front of list
- m.list.PushFront(elem)
- return true
-}
-
-// Set will ensure that given key-value pair exists in the map, by either adding new or updating existing, pushing them to the front of the map. Evicts old at maximum capacity.
-func (m *LRUMap[K, V]) Set(key K, value V) {
- m.SetWithHook(key, value, nil)
-}
-
-// SetWithHook performs .Set() but passing any evicted entry to given hook function.
-func (m *LRUMap[K, V]) SetWithHook(key K, value V, evict func(K, V)) {
- // Ensure safe
- m.write_check()
-
- // Look for existing elem
- elem, ok := m.hmap[key]
-
- if ok {
- // Unlink elem from list
- m.list.Unlink(elem)
-
- // Update existing
- elem.V = value
- } else {
- if m.list.len >= m.size {
- // We're at capacity, sir!
- // Pop current tail elem
- elem = m.list.PopTail()
-
- if evict != nil {
- // Pass to evict hook
- evict(elem.K, elem.V)
- }
-
- // Delete key from map
- delete(m.hmap, elem.K)
- } else {
- // Allocate elem
- elem = m.alloc()
- }
-
- // Set elem
- elem.K = key
- elem.V = value
-
- // Add element map entry
- m.hmap[key] = elem
- }
-
- // Push to front of list
- m.list.PushFront(elem)
-}
-
-// Cap returns the maximum capacity of this LRU map.
-func (m *LRUMap[K, V]) Cap() int {
- return m.size
-}
-
-// Format implements fmt.Formatter, allowing performant string formatting of map.
-func (m *LRUMap[K, V]) Format(state fmt.State, verb rune) {
- m.format(reflect.TypeOf(m), state, verb)
-}
diff --git a/vendor/codeberg.org/gruf/go-maps/ordered.go b/vendor/codeberg.org/gruf/go-maps/ordered.go
deleted file mode 100644
index ca8ebe8a0..000000000
--- a/vendor/codeberg.org/gruf/go-maps/ordered.go
+++ /dev/null
@@ -1,159 +0,0 @@
-package maps
-
-import (
- "fmt"
- "reflect"
-)
-
-// OrderedMap provides a hashmap implementation that tracks the order in which keys are added.
-type OrderedMap[K comparable, V any] struct {
- ordered[K, V]
-}
-
-// NewOrdered returns a new instance of LRUMap with given initializing length and maximum capacity.
-func NewOrdered[K comparable, V any](len int) *OrderedMap[K, V] {
- m := new(OrderedMap[K, V])
- m.Init(len)
- return m
-}
-
-// Init will initialize this map with initial length.
-func (m *OrderedMap[K, V]) Init(len int) {
- if m.pool != nil {
- panic("ordered map already initialized")
- }
- m.ordered.hmap = make(map[K]*elem[K, V], len)
- m.ordered.pool = allocElems[K, V](len)
-}
-
-// Get will fetch value for given key from map. Returns false if not found.
-func (m *OrderedMap[K, V]) Get(key K) (V, bool) {
- if elem, ok := m.hmap[key]; ok {
- return elem.V, true
- }
- var z V // zero value
- return z, false
-}
-
-// Add will add the given key-value pair to the map, returns false if already exists.
-func (m *OrderedMap[K, V]) Add(key K, value V) bool {
- // Ensure safe
- m.write_check()
-
- // Look for existing elem
- elem, ok := m.hmap[key]
- if ok {
- return false
- }
-
- // Allocate elem
- elem = m.alloc()
- elem.K = key
- elem.V = value
-
- // Add element map entry
- m.hmap[key] = elem
-
- // Push to back of list
- m.list.PushBack(elem)
- return true
-}
-
-// Set will ensure that given key-value pair exists in the map, by either adding new or updating existing.
-func (m *OrderedMap[K, V]) Set(key K, value V) {
- // Ensure safe
- m.write_check()
-
- // Look for existing elem
- elem, ok := m.hmap[key]
-
- if ok {
- // Update existing
- elem.V = value
- } else {
- // Allocate elem
- elem = m.alloc()
- elem.K = key
- elem.V = value
-
- // Add element map entry
- m.hmap[key] = elem
-
- // Push to back of list
- m.list.PushBack(elem)
- }
-}
-
-// Index returns the key-value pair at index from map. Returns false if index out of range.
-func (m *OrderedMap[K, V]) Index(idx int) (K, V, bool) {
- if idx < 0 || idx >= m.list.len {
- var (
- zk K
- zv V
- ) // zero values
- return zk, zv, false
- }
- elem := m.list.Index(idx)
- return elem.K, elem.V, true
-}
-
-// Push will insert the given key-value pair at index in the map. Panics if index out of range.
-func (m *OrderedMap[K, V]) Push(idx int, key K, value V) {
- // Check index within bounds of map
- if idx < 0 || idx >= m.list.len {
- panic("index out of bounds")
- }
-
- // Ensure safe
- m.write_check()
-
- // Get element at index
- next := m.list.Index(idx)
-
- // Allocate new elem
- elem := m.alloc()
- elem.K = key
- elem.V = value
-
- // Add element map entry
- m.hmap[key] = elem
-
- // Move next forward
- elem.next = next
- elem.prev = next.prev
-
- // Link up elem in chain
- next.prev.next = elem
- next.prev = elem
-}
-
-// Pop will remove and return the key-value pair at index in the map. Panics if index out of range.
-func (m *OrderedMap[K, V]) Pop(idx int) (K, V) {
- // Check index within bounds of map
- if idx < 0 || idx >= m.list.len {
- panic("index out of bounds")
- }
-
- // Ensure safe
- m.write_check()
-
- // Get element at index
- elem := m.list.Index(idx)
-
- // Unlink elem from list
- m.list.Unlink(elem)
-
- // Get elem values
- k := elem.K
- v := elem.V
-
- // Release to pool
- m.free(elem)
-
- return k, v
-}
-
-// Format implements fmt.Formatter, allowing performant string formatting of map.
-func (m *OrderedMap[K, V]) Format(state fmt.State, verb rune) {
- m.format(reflect.TypeOf(m), state, verb)
-}
diff --git a/vendor/codeberg.org/gruf/go-mempool/LICENSE b/vendor/codeberg.org/gruf/go-mempool/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-mempool/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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-mempool/README.md b/vendor/codeberg.org/gruf/go-mempool/README.md
deleted file mode 100644
index 1acc23d26..000000000
--- a/vendor/codeberg.org/gruf/go-mempool/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-mempool
-
-very simple memory pool implementation
diff --git a/vendor/codeberg.org/gruf/go-mempool/pool.go b/vendor/codeberg.org/gruf/go-mempool/pool.go
deleted file mode 100644
index 5bb80234c..000000000
--- a/vendor/codeberg.org/gruf/go-mempool/pool.go
+++ /dev/null
@@ -1,139 +0,0 @@
-package mempool
-
-import (
- "sync"
- "sync/atomic"
- "unsafe"
-
- "golang.org/x/sys/cpu"
-)
-
-// Pool provides a form of SimplePool
-// with the addition of concurrency safety.
-type Pool[T any] struct {
- UnsafePool
-
- // New is an optionally provided
- // allocator used when no value
- // is available for use in pool.
- New func() T
-
- // Reset is an optionally provided
- // value resetting function called
- // on passed value to Put().
- Reset func(T) bool
-}
-
-func NewPool[T any](new func() T, reset func(T) bool, check func(current, victim int) bool) Pool[T] {
- return Pool[T]{
- New: new,
- Reset: reset,
- UnsafePool: NewUnsafePool(check),
- }
-}
-
-func (p *Pool[T]) Get() T {
- if ptr := p.UnsafePool.Get(); ptr != nil {
- return *(*T)(ptr)
- }
- var t T
- if p.New != nil {
- t = p.New()
- }
- return t
-}
-
-func (p *Pool[T]) Put(t T) {
- if p.Reset != nil && !p.Reset(t) {
- return
- }
- ptr := unsafe.Pointer(&t)
- p.UnsafePool.Put(ptr)
-}
-
-// UnsafePool provides a form of UnsafeSimplePool
-// with the addition of concurrency safety.
-type UnsafePool struct {
- internal
- _ [cache_line_size - unsafe.Sizeof(internal{})%cache_line_size]byte
-}
-
-func NewUnsafePool(check func(current, victim int) bool) UnsafePool {
- return UnsafePool{internal: internal{
- pool: UnsafeSimplePool{Check: check},
- }}
-}
-
-const (
- // current platform integer size.
- int_size = 32 << (^uint(0) >> 63)
-
- // platform CPU cache line size to avoid false sharing.
- cache_line_size = unsafe.Sizeof(cpu.CacheLinePad{})
-)
-
-type internal struct {
- // fast-access ring-buffer of
- // pointers accessible by index.
- //
- // if Go ever exposes goroutine IDs
- // to us we can make this a lot faster.
- ring [int_size / 4]unsafe.Pointer
- index atomic.Uint64
-
- // underlying pool and
- // slow mutex protection.
- pool UnsafeSimplePool
- mutex sync.Mutex
-}
-
-func (p *internal) Check(fn func(current, victim int) bool) func(current, victim int) bool {
- p.mutex.Lock()
- if fn == nil {
- if p.pool.Check == nil {
- fn = defaultCheck
- } else {
- fn = p.pool.Check
- }
- } else {
- p.pool.Check = fn
- }
- p.mutex.Unlock()
- return fn
-}
-
-func (p *internal) Get() unsafe.Pointer {
- if ptr := atomic.SwapPointer(&p.ring[p.index.Load()%uint64(cap(p.ring))], nil); ptr != nil {
- p.index.Add(^uint64(0)) // i.e. -1
- return ptr
- }
- p.mutex.Lock()
- ptr := p.pool.Get()
- p.mutex.Unlock()
- return ptr
-}
-
-func (p *internal) Put(ptr unsafe.Pointer) {
- if atomic.CompareAndSwapPointer(&p.ring[p.index.Add(1)%uint64(cap(p.ring))], nil, ptr) {
- return
- }
- p.mutex.Lock()
- p.pool.Put(ptr)
- p.mutex.Unlock()
-}
-
-func (p *internal) GC() {
- for i := range p.ring {
- atomic.StorePointer(&p.ring[i], nil)
- }
- p.mutex.Lock()
- p.pool.GC()
- p.mutex.Unlock()
-}
-
-func (p *internal) Size() int {
- p.mutex.Lock()
- sz := p.pool.Size()
- p.mutex.Unlock()
- return sz
-}
diff --git a/vendor/codeberg.org/gruf/go-mempool/simple.go b/vendor/codeberg.org/gruf/go-mempool/simple.go
deleted file mode 100644
index c9f459890..000000000
--- a/vendor/codeberg.org/gruf/go-mempool/simple.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package mempool
-
-import (
- "unsafe"
-)
-
-// SimplePool provides a type-safe form
-// of UnsafePool using generics.
-//
-// Note it is NOT safe for concurrent
-// use, you must protect it yourself!
-type SimplePool[T any] struct {
- UnsafeSimplePool
-
- // New is an optionally provided
- // allocator used when no value
- // is available for use in pool.
- New func() T
-
- // Reset is an optionally provided
- // value resetting function called
- // on passed value to Put().
- Reset func(T) bool
-}
-
-func (p *SimplePool[T]) Get() T {
- if ptr := p.UnsafeSimplePool.Get(); ptr != nil {
- return *(*T)(ptr)
- }
- var t T
- if p.New != nil {
- t = p.New()
- }
- return t
-}
-
-func (p *SimplePool[T]) Put(t T) {
- if p.Reset != nil && !p.Reset(t) {
- return
- }
- ptr := unsafe.Pointer(&t)
- p.UnsafeSimplePool.Put(ptr)
-}
-
-// UnsafeSimplePool provides an incredibly
-// simple memory pool implementation
-// that stores ptrs to memory values,
-// and regularly flushes internal pool
-// structures according to CheckGC().
-//
-// Note it is NOT safe for concurrent
-// use, you must protect it yourself!
-type UnsafeSimplePool struct {
-
- // Check determines how often to flush
- // internal pools based on underlying
- // current and victim pool sizes. It gets
- // called on every pool Put() operation.
- //
- // A flush will start a new current
- // pool, make victim the old current,
- // and drop the existing victim pool.
- Check func(current, victim int) bool
-
- current []unsafe.Pointer
- victim []unsafe.Pointer
-}
-
-func (p *UnsafeSimplePool) Get() unsafe.Pointer {
- // First try current list.
- if len(p.current) > 0 {
- ptr := p.current[len(p.current)-1]
- p.current = p.current[:len(p.current)-1]
- return ptr
- }
-
- // Fallback to victim.
- if len(p.victim) > 0 {
- ptr := p.victim[len(p.victim)-1]
- p.victim = p.victim[:len(p.victim)-1]
- return ptr
- }
-
- return nil
-}
-
-func (p *UnsafeSimplePool) Put(ptr unsafe.Pointer) {
- p.current = append(p.current, ptr)
-
- // Get GC check func.
- if p.Check == nil {
- p.Check = defaultCheck
- }
-
- if p.Check(len(p.current), len(p.victim)) {
- p.GC() // garbage collection time!
- }
-}
-
-func (p *UnsafeSimplePool) GC() {
- p.victim = p.current
- p.current = nil
-}
-
-func (p *UnsafeSimplePool) Size() int {
- return len(p.current) + len(p.victim)
-}
-
-func defaultCheck(current, victim int) bool {
- return current-victim > 128 || victim > 256
-}
diff --git a/vendor/codeberg.org/gruf/go-mmap/LICENSE b/vendor/codeberg.org/gruf/go-mmap/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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-mmap/README.md b/vendor/codeberg.org/gruf/go-mmap/README.md
deleted file mode 100644
index 76fc5fccd..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-mmap
-
-Optimized large file reads in Go \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-mmap/copy_fill_stat.sh b/vendor/codeberg.org/gruf/go-mmap/copy_fill_stat.sh
deleted file mode 100644
index 5babab154..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/copy_fill_stat.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-set -e
-
-for file in "$(go env GOROOT)"/src/os/stat_{linux,netbsd,openbsd,freebsd,darwin}.go; do
- cp "$file" .
- name="$(basename "$file")"
- sed -i "./${name}" -E -e 's|package os|package mmap|' \
- -e 's|internal/filepathlite|path|' \
- -e 's|filepathlite|path|g' \
- -e 's| FileMode| os.FileMode|g' \
- -e 's| Mode| os.Mode|g' \
- -e 's| FileInfo| os.FileInfo|g'
- gofmt -w "./${name}"; goimports -w "./${name}"
-done
diff --git a/vendor/codeberg.org/gruf/go-mmap/fs.go b/vendor/codeberg.org/gruf/go-mmap/fs.go
deleted file mode 100644
index 743523259..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/fs.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package mmap
-
-import (
- "io/fs"
- "syscall"
- "time"
-)
-
-type fileStat struct {
- name string
- size int64
- mode fs.FileMode
- modTime time.Time
- sys syscall.Stat_t
-}
-
-func (fs *fileStat) Name() string { return fs.name }
-func (fs *fileStat) Size() int64 { return fs.size }
-func (fs *fileStat) IsDir() bool { return fs.mode.IsDir() }
-func (fs *fileStat) Mode() fs.FileMode { return fs.mode }
-func (fs *fileStat) ModTime() time.Time { return fs.modTime }
-func (fs *fileStat) Sys() any { return &fs.sys }
-
-// open is a simple wrapper around syscall.Open().
-func open(filepath string, mode int, perm uint32) (fd int, err error) {
- err = retryOnEINTR(func() (err error) {
- fd, err = syscall.Open(filepath, mode, perm)
- return
- })
- return
-}
-
-// stat is a simple wrapper around syscall.Stat().
-func stat(filepath string) (*fileStat, error) {
- var stat fileStat
- err := retryOnEINTR(func() error {
- return syscall.Stat(filepath, &stat.sys)
- })
- if err != nil {
- return nil, err
- }
- fillFileStatFromSys(&stat, filepath)
- return &stat, nil
-}
-
-// mmap is a simple wrapper around syscall.Mmap().
-func mmap(fd int, offset int64, length int, prot int, flags int) (b []byte, err error) {
- err = retryOnEINTR(func() error {
- b, err = syscall.Mmap(fd, offset, length, prot, flags)
- return err
- })
- return
-}
-
-// munmap is a simple wrapper around syscall.Munmap().
-func munmap(b []byte) error {
- return retryOnEINTR(func() error {
- return syscall.Munmap(b)
- })
-}
-
-// close_ is a simple wrapper around syscall.Close().
-func close_(fd int) error {
- return retryOnEINTR(func() error {
- return syscall.Close(fd)
- })
-}
-
-// 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
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-mmap/mmap.go b/vendor/codeberg.org/gruf/go-mmap/mmap.go
deleted file mode 100644
index 797ed3e73..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/mmap.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package mmap
-
-import (
- "errors"
- "io"
- "io/fs"
- "runtime"
- "syscall"
-)
-
-// MmapFile maps file at path into memory using syscall.mmap(),
-// and returns a protected MmapReader{} for accessing the mapped data.
-// Note that the mapped memory is not concurrency safe (other than
-// concurrent ReadAt() calls). Any other calls made concurrently to
-// Read() or Close() (including ReadAt()) require protection.
-func MmapFile(path string) (*MmappedFile, error) {
-
- // Stat file information.
- stat, err := stat(path)
- if err != nil {
- return nil, err
- }
-
- // Mmap file into memory.
- return openMmap(path, stat)
-}
-
-func openMmap(path string, stat *fileStat) (*MmappedFile, error) {
- if stat.Size() <= 0 {
- // Empty file, no-op read.
- return &MmappedFile{}, nil
- }
-
- // Check file data size is accessible.
- if stat.Size() != int64(int(stat.Size())) {
- return nil, errors.New("file is too large")
- }
-
- // Open file at path for read-only access.
- fd, err := open(path, syscall.O_RDONLY, 0)
- if err != nil {
- return nil, err
- }
-
- // Map this file into memory as slice.
- mem, err := mmap(fd, 0, int(stat.Size()),
- syscall.PROT_READ, syscall.MAP_PRIVATE)
-
- // Done with file.
- _ = close_(fd)
-
- if err != nil {
- return nil, err
- }
-
- // Return as wrapped reader type.
- return newMmapReader(mem, stat), nil
-}
-
-// newMmapReader wraps a mapped memory slice in an
-// MmappedFile{}, also setting a GC finalizer function.
-func newMmapReader(mem []byte, stat *fileStat) *MmappedFile {
- r := &MmappedFile{b: mem, s: stat}
- runtime.SetFinalizer(r, (*MmappedFile).Close)
- return r
-}
-
-type MmappedFile struct {
- b []byte // mapped memory
- n int // read index
- s *fileStat // file info
-}
-
-func (r *MmappedFile) Name() string {
- return r.s.name
-}
-
-func (r *MmappedFile) Stat() (fs.FileInfo, error) {
- return r.s, nil
-}
-
-func (r *MmappedFile) Read(b []byte) (n int, err error) {
- if r.n >= len(r.b) {
- return 0, io.EOF
- }
- n = copy(b, r.b[r.n:])
- r.n += n
- return
-}
-
-func (r *MmappedFile) ReadAt(b []byte, off int64) (n int, err error) {
- if off > int64(len(r.b)) {
- return 0, io.EOF
- }
- n = copy(b, r.b[off:])
- return n, nil
-}
-
-func (r *MmappedFile) WriteTo(w io.Writer) (int64, error) {
- if r.n >= len(r.b) {
- return 0, io.EOF
- }
- n, err := w.Write(r.b[r.n:])
- r.n += n
- return int64(n), err
-}
-
-func (r *MmappedFile) Seek(off int64, whence int) (int64, error) {
- var n int
- switch whence {
- case io.SeekCurrent:
- n = r.n + int(off)
- case io.SeekStart:
- n = 0 + int(off)
- case io.SeekEnd:
- n = len(r.b) + int(off)
- default:
- return 0, errors.New("invalid argument")
- }
- if n < 0 || n > len(r.b) {
- return 0, errors.New("invalid argument")
- }
- r.n = n
- return int64(n), nil
-}
-
-func (r *MmappedFile) Len() int {
- return len(r.b) - r.n
-}
-
-func (r *MmappedFile) Size() int64 {
- return int64(len(r.b))
-}
-
-func (r *MmappedFile) Close() error {
- if b := r.b; b != nil {
- r.b = nil
- runtime.SetFinalizer(r, nil)
- return munmap(b)
- }
- return nil
-}
diff --git a/vendor/codeberg.org/gruf/go-mmap/open.go b/vendor/codeberg.org/gruf/go-mmap/open.go
deleted file mode 100644
index c12a091d3..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/open.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package mmap
-
-import (
- "io"
- "io/fs"
- "os"
- "runtime"
- "syscall"
-)
-
-// MmapThreshold defines the threshold file size (in bytes) for which
-// a call to OpenRead() will deem as big enough for a file to be worth
-// opening using an `mmap` syscall. This is a runtime initialized number
-// based on the number of available CPUs as in concurrent conditions Go
-// can make optimizations for blocking `read` syscalls which scales with
-// the number of available goroutines it can have running at once.
-var MmapThreshold = int64(runtime.NumCPU() * syscall.Getpagesize())
-
-// FileReader defines the base interface
-// of a readable file, whether accessed
-// via `read` or `mmap` syscalls.
-type FileReader interface {
- fs.File
- io.ReaderAt
- io.WriterTo
- io.Seeker
- Name() string
-}
-
-// Threshold is a receiving type for OpenRead()
-// that allows defining a custom MmapThreshold.
-type Threshold struct{ At int64 }
-
-// OpenRead: see mmap.OpenRead().
-func (t Threshold) OpenRead(path string) (FileReader, error) {
- stat, err := stat(path)
- if err != nil {
- return nil, err
- }
- if stat.Size() >= t.At {
- return openMmap(path, stat)
- } else {
- return os.OpenFile(path, syscall.O_RDONLY, 0)
- }
-}
-
-// OpenRead will open the file as read only (erroring if it does
-// not already exist). If the file at path is beyond 'MmapThreshold'
-// it will be opened for reads using an `mmap` syscall, by calling
-// MmappedRead(path). Else, it will be opened using os.OpenFile().
-//
-// Please note that the reader returned by this function is not
-// guaranteed to be concurrency-safe. Calls returned by os.OpenFile()
-// follow the usual standard library concurrency guarantees, but the
-// reader returned by MmappedRead() provides no concurrent protection.
-//
-// Also note that this may not always be faster! If the file you need
-// to open will be immediately drained to another file, TCP or Unix
-// connection, then the standard library will used optimized syscalls.
-func OpenRead(path string) (FileReader, error) {
- return Threshold{MmapThreshold}.OpenRead(path)
-}
diff --git a/vendor/codeberg.org/gruf/go-mmap/stat_darwin.go b/vendor/codeberg.org/gruf/go-mmap/stat_darwin.go
deleted file mode 100644
index 3075e94e9..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/stat_darwin.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mmap
-
-import (
- "os"
- "path"
- "syscall"
- "time"
-)
-
-func fillFileStatFromSys(fs *fileStat, name string) {
- fs.name = path.Base(name)
- fs.size = fs.sys.Size
- fs.modTime = time.Unix(fs.sys.Mtimespec.Unix())
- fs.mode = os.FileMode(fs.sys.Mode & 0777)
- switch fs.sys.Mode & syscall.S_IFMT {
- case syscall.S_IFBLK, syscall.S_IFWHT:
- fs.mode |= os.ModeDevice
- case syscall.S_IFCHR:
- fs.mode |= os.ModeDevice | os.ModeCharDevice
- case syscall.S_IFDIR:
- fs.mode |= os.ModeDir
- case syscall.S_IFIFO:
- fs.mode |= os.ModeNamedPipe
- case syscall.S_IFLNK:
- fs.mode |= os.ModeSymlink
- case syscall.S_IFREG:
- // nothing to do
- case syscall.S_IFSOCK:
- fs.mode |= os.ModeSocket
- }
- if fs.sys.Mode&syscall.S_ISGID != 0 {
- fs.mode |= os.ModeSetgid
- }
- if fs.sys.Mode&syscall.S_ISUID != 0 {
- fs.mode |= os.ModeSetuid
- }
- if fs.sys.Mode&syscall.S_ISVTX != 0 {
- fs.mode |= os.ModeSticky
- }
-}
-
-// For testing.
-func atime(fi os.FileInfo) time.Time {
- return time.Unix(fi.Sys().(*syscall.Stat_t).Atimespec.Unix())
-}
diff --git a/vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go b/vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go
deleted file mode 100644
index 271ca30e8..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mmap
-
-import (
- "os"
- "path"
- "syscall"
- "time"
-)
-
-func fillFileStatFromSys(fs *fileStat, name string) {
- fs.name = path.Base(name)
- fs.size = fs.sys.Size
- fs.modTime = time.Unix(fs.sys.Mtimespec.Unix())
- fs.mode = os.FileMode(fs.sys.Mode & 0777)
- switch fs.sys.Mode & syscall.S_IFMT {
- case syscall.S_IFBLK:
- fs.mode |= os.ModeDevice
- case syscall.S_IFCHR:
- fs.mode |= os.ModeDevice | os.ModeCharDevice
- case syscall.S_IFDIR:
- fs.mode |= os.ModeDir
- case syscall.S_IFIFO:
- fs.mode |= os.ModeNamedPipe
- case syscall.S_IFLNK:
- fs.mode |= os.ModeSymlink
- case syscall.S_IFREG:
- // nothing to do
- case syscall.S_IFSOCK:
- fs.mode |= os.ModeSocket
- }
- if fs.sys.Mode&syscall.S_ISGID != 0 {
- fs.mode |= os.ModeSetgid
- }
- if fs.sys.Mode&syscall.S_ISUID != 0 {
- fs.mode |= os.ModeSetuid
- }
- if fs.sys.Mode&syscall.S_ISVTX != 0 {
- fs.mode |= os.ModeSticky
- }
-}
-
-// For testing.
-func atime(fi os.FileInfo) time.Time {
- return time.Unix(fi.Sys().(*syscall.Stat_t).Atimespec.Unix())
-}
diff --git a/vendor/codeberg.org/gruf/go-mmap/stat_linux.go b/vendor/codeberg.org/gruf/go-mmap/stat_linux.go
deleted file mode 100644
index 4f4ebc164..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/stat_linux.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mmap
-
-import (
- "os"
- "path"
- "syscall"
- "time"
-)
-
-func fillFileStatFromSys(fs *fileStat, name string) {
- fs.name = path.Base(name)
- fs.size = fs.sys.Size
- fs.modTime = time.Unix(fs.sys.Mtim.Unix())
- fs.mode = os.FileMode(fs.sys.Mode & 0777)
- switch fs.sys.Mode & syscall.S_IFMT {
- case syscall.S_IFBLK:
- fs.mode |= os.ModeDevice
- case syscall.S_IFCHR:
- fs.mode |= os.ModeDevice | os.ModeCharDevice
- case syscall.S_IFDIR:
- fs.mode |= os.ModeDir
- case syscall.S_IFIFO:
- fs.mode |= os.ModeNamedPipe
- case syscall.S_IFLNK:
- fs.mode |= os.ModeSymlink
- case syscall.S_IFREG:
- // nothing to do
- case syscall.S_IFSOCK:
- fs.mode |= os.ModeSocket
- }
- if fs.sys.Mode&syscall.S_ISGID != 0 {
- fs.mode |= os.ModeSetgid
- }
- if fs.sys.Mode&syscall.S_ISUID != 0 {
- fs.mode |= os.ModeSetuid
- }
- if fs.sys.Mode&syscall.S_ISVTX != 0 {
- fs.mode |= os.ModeSticky
- }
-}
-
-// For testing.
-func atime(fi os.FileInfo) time.Time {
- return time.Unix(fi.Sys().(*syscall.Stat_t).Atim.Unix())
-}
diff --git a/vendor/codeberg.org/gruf/go-mmap/stat_netbsd.go b/vendor/codeberg.org/gruf/go-mmap/stat_netbsd.go
deleted file mode 100644
index 271ca30e8..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/stat_netbsd.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mmap
-
-import (
- "os"
- "path"
- "syscall"
- "time"
-)
-
-func fillFileStatFromSys(fs *fileStat, name string) {
- fs.name = path.Base(name)
- fs.size = fs.sys.Size
- fs.modTime = time.Unix(fs.sys.Mtimespec.Unix())
- fs.mode = os.FileMode(fs.sys.Mode & 0777)
- switch fs.sys.Mode & syscall.S_IFMT {
- case syscall.S_IFBLK:
- fs.mode |= os.ModeDevice
- case syscall.S_IFCHR:
- fs.mode |= os.ModeDevice | os.ModeCharDevice
- case syscall.S_IFDIR:
- fs.mode |= os.ModeDir
- case syscall.S_IFIFO:
- fs.mode |= os.ModeNamedPipe
- case syscall.S_IFLNK:
- fs.mode |= os.ModeSymlink
- case syscall.S_IFREG:
- // nothing to do
- case syscall.S_IFSOCK:
- fs.mode |= os.ModeSocket
- }
- if fs.sys.Mode&syscall.S_ISGID != 0 {
- fs.mode |= os.ModeSetgid
- }
- if fs.sys.Mode&syscall.S_ISUID != 0 {
- fs.mode |= os.ModeSetuid
- }
- if fs.sys.Mode&syscall.S_ISVTX != 0 {
- fs.mode |= os.ModeSticky
- }
-}
-
-// For testing.
-func atime(fi os.FileInfo) time.Time {
- return time.Unix(fi.Sys().(*syscall.Stat_t).Atimespec.Unix())
-}
diff --git a/vendor/codeberg.org/gruf/go-mmap/stat_openbsd.go b/vendor/codeberg.org/gruf/go-mmap/stat_openbsd.go
deleted file mode 100644
index 4f4ebc164..000000000
--- a/vendor/codeberg.org/gruf/go-mmap/stat_openbsd.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mmap
-
-import (
- "os"
- "path"
- "syscall"
- "time"
-)
-
-func fillFileStatFromSys(fs *fileStat, name string) {
- fs.name = path.Base(name)
- fs.size = fs.sys.Size
- fs.modTime = time.Unix(fs.sys.Mtim.Unix())
- fs.mode = os.FileMode(fs.sys.Mode & 0777)
- switch fs.sys.Mode & syscall.S_IFMT {
- case syscall.S_IFBLK:
- fs.mode |= os.ModeDevice
- case syscall.S_IFCHR:
- fs.mode |= os.ModeDevice | os.ModeCharDevice
- case syscall.S_IFDIR:
- fs.mode |= os.ModeDir
- case syscall.S_IFIFO:
- fs.mode |= os.ModeNamedPipe
- case syscall.S_IFLNK:
- fs.mode |= os.ModeSymlink
- case syscall.S_IFREG:
- // nothing to do
- case syscall.S_IFSOCK:
- fs.mode |= os.ModeSocket
- }
- if fs.sys.Mode&syscall.S_ISGID != 0 {
- fs.mode |= os.ModeSetgid
- }
- if fs.sys.Mode&syscall.S_ISUID != 0 {
- fs.mode |= os.ModeSetuid
- }
- if fs.sys.Mode&syscall.S_ISVTX != 0 {
- fs.mode |= os.ModeSticky
- }
-}
-
-// For testing.
-func atime(fi os.FileInfo) time.Time {
- return time.Unix(fi.Sys().(*syscall.Stat_t).Atim.Unix())
-}
diff --git a/vendor/codeberg.org/gruf/go-mutexes/LICENSE b/vendor/codeberg.org/gruf/go-mutexes/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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/cond.go b/vendor/codeberg.org/gruf/go-mutexes/cond.go
deleted file mode 100644
index 3d7f21126..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/cond.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package mutexes
-
-import (
- "sync"
-)
-
-// Cond is similar to a sync.Cond{}, but
-// it encompasses the Mutex{} within itself.
-type Cond struct {
- c sync.Cond
- sync.Mutex
-}
-
-// See: sync.Cond{}.Wait().
-func (c *Cond) Wait() {
- if c.c.L == nil {
- c.c.L = &c.Mutex
- }
- c.c.Wait()
-}
-
-// See: sync.Cond{}.Signal().
-func (c *Cond) Signal() {
- if c.c.L == nil {
- c.c.L = &c.Mutex
- }
- c.c.Signal()
-}
-
-// See: sync.Cond{}.Broadcast().
-func (c *Cond) Broadcast() {
- if c.c.L == nil {
- c.c.L = &c.Mutex
- }
- c.c.Broadcast()
-}
-
-// RWCond is similar to a sync.Cond{}, but
-// it encompasses the RWMutex{} within itself.
-type RWCond struct {
- c sync.Cond
- sync.RWMutex
-}
-
-// See: sync.Cond{}.Wait().
-func (c *RWCond) Wait() {
- if c.c.L == nil {
- c.c.L = &c.RWMutex
- }
- c.c.Wait()
-}
-
-// See: sync.Cond{}.Signal().
-func (c *RWCond) Signal() {
- if c.c.L == nil {
- c.c.L = &c.RWMutex
- }
- c.c.Signal()
-}
-
-// See: sync.Cond{}.Broadcast().
-func (c *RWCond) Broadcast() {
- if c.c.L == nil {
- c.c.L = &c.RWMutex
- }
- c.c.Broadcast()
-}
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/hash_map.go b/vendor/codeberg.org/gruf/go-mutexes/hash_map.go
deleted file mode 100644
index a177133b5..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/hash_map.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package mutexes
-
-type hashmap struct {
- m map[string]*rwmutex
- n int
-}
-
-func (m *hashmap) init(cap int) {
- m.m = make(map[string]*rwmutex, cap)
- m.n = cap
-}
-
-func (m *hashmap) Get(key string) *rwmutex { return m.m[key] }
-
-func (m *hashmap) Put(key string, mu *rwmutex) {
- m.m[key] = mu
- if n := len(m.m); n > m.n {
- m.n = n
- }
-}
-
-func (m *hashmap) Delete(key string) {
- delete(m.m, key)
-}
-
-func (m *hashmap) Compact() {
- // Noop when hashmap size
- // is too small to matter.
- if m.n < 2048 {
- return
- }
-
- // Difference between maximum map
- // size and the current map size.
- diff := m.n - len(m.m)
-
- // Maximum load factor before
- // runtime allocates new hmap:
- // maxLoad = 13 / 16
- //
- // So we apply the inverse/2, once
- // $maxLoad/2 % of hmap is empty we
- // compact the map to drop buckets.
- if 2*16*diff > m.n*13 {
-
- // Create new map only as big as required.
- m2 := make(map[string]*rwmutex, len(m.m))
- for k, v := range m.m {
- m2[k] = v
- }
-
- // Set new.
- m.m = m2
- m.n = len(m2)
- }
-}
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 e8c4d0058..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/map.go
+++ /dev/null
@@ -1,210 +0,0 @@
-package mutexes
-
-import (
- "sync"
- "unsafe"
-
- "codeberg.org/gruf/go-mempool"
-)
-
-const (
- // possible lock types.
- lockTypeRead = uint8(1) << 0
- lockTypeWrite = uint8(1) << 1
-)
-
-// MutexMap is a structure that allows read / write locking
-// per key, performing as you'd expect a map[string]*RWMutex
-// to perform, without you needing to worry about deadlocks
-// between competing read / write locks and the map's own mutex.
-// It uses memory pooling for the internal "mutex" (ish) types
-// and performs self-eviction of keys.
-//
-// Under the hood this is achieved using a single mutex for the
-// map, state tracking for individual keys, and some sync.Cond{}
-// like structures for sleeping / awaking awaiting goroutines.
-type MutexMap struct {
- mapmu sync.Mutex
- mumap hashmap
- mupool mempool.UnsafeSimplePool
-}
-
-// checkInit ensures MutexMap is initialized (UNSAFE).
-func (mm *MutexMap) checkInit() {
- if mm.mumap.m == nil {
- mm.mumap.init(0)
- }
-}
-
-// Lock acquires a write lock on key in map, returning unlock function.
-func (mm *MutexMap) Lock(key string) func() {
- return mm.lock(key, lockTypeWrite)
-}
-
-// RLock acquires a read lock on key in map, returning runlock function.
-func (mm *MutexMap) RLock(key string) func() {
- return mm.lock(key, lockTypeRead)
-}
-
-func (mm *MutexMap) lock(key string, lt uint8) func() {
- // Perform first map lock
- // and check initialization
- // OUTSIDE the main loop.
- mm.mapmu.Lock()
- mm.checkInit()
-
- for {
- // Check map for mutex.
- mu := mm.mumap.Get(key)
-
- if mu == nil {
- // Allocate mutex.
- mu = mm.acquire()
- mm.mumap.Put(key, mu)
- }
-
- if !mu.Lock(lt) {
- // Wait on mutex unlock, after
- // immediately relocking map mu.
- mu.WaitRelock()
- continue
- }
-
- // Done with map.
- mm.mapmu.Unlock()
-
- // Return mutex unlock function.
- return func() { mm.unlock(key, mu) }
- }
-}
-
-func (mm *MutexMap) unlock(key string, mu *rwmutex) {
- // Get map lock.
- mm.mapmu.Lock()
-
- // Unlock mutex.
- if !mu.Unlock() {
-
- // Fast path. Mutex still
- // used so no map change.
- mm.mapmu.Unlock()
- return
- }
-
- // Mutex fully unlocked
- // with zero waiters. Self
- // evict and release it.
- mm.mumap.Delete(key)
- mm.release(mu)
-
- // Check if compaction
- // needed.
- mm.mumap.Compact()
-
- // Done with map.
- mm.mapmu.Unlock()
-}
-
-// acquire will acquire mutex from memory pool, or alloc new.
-func (mm *MutexMap) acquire() *rwmutex {
- if ptr := mm.mupool.Get(); ptr != nil {
- return (*rwmutex)(ptr)
- }
- mu := new(rwmutex)
- mu.c.L = &mm.mapmu
- return mu
-}
-
-// release will release given mutex to memory pool.
-func (mm *MutexMap) release(mu *rwmutex) {
- ptr := unsafe.Pointer(mu)
- mm.mupool.Put(ptr)
-}
-
-// rwmutex represents a RW mutex when used correctly within
-// a MapMutex. It should ONLY be access when protected by
-// the outer map lock, except for the 'notifyList' which is
-// a runtime internal structure borrowed from the sync.Cond{}.
-//
-// this functions very similarly to a sync.Cond{}, but with
-// lock state tracking, and returning on 'Broadcast()' whether
-// any goroutines were actually awoken. it also has a less
-// confusing API than sync.Cond{} with the outer locking
-// mechanism we use, otherwise all Cond{}.L would reference
-// the same outer map mutex.
-type rwmutex struct {
- c sync.Cond // 'trigger' mechanism
- l int32 // no. locks
- t uint8 // lock type
-}
-
-// Lock will lock the mutex for given lock type, in the
-// sense that it will update the internal state tracker
-// accordingly. Return value is true on successful lock.
-func (mu *rwmutex) Lock(lt uint8) bool {
- switch mu.t {
- case lockTypeRead:
- // already read locked,
- // only permit more reads.
- if lt != lockTypeRead {
- return false
- }
-
- case lockTypeWrite:
- // already write locked,
- // no other locks allowed.
- return false
-
- default:
- // Fully unlocked,
- // set incoming type.
- mu.t = lt
- }
-
- // Update
- // count.
- mu.l++
-
- return true
-}
-
-// Unlock will unlock the mutex, in the sense that it
-// will update the internal state tracker accordingly.
-// On totally unlocked state, it will awaken all
-// sleeping goroutines waiting on this mutex.
-func (mu *rwmutex) Unlock() bool {
- switch mu.l--; {
- case mu.l == 0:
- // Fully
- // unlock.
- mu.t = 0
-
- // Awake all blocked goroutines and check
- // for change in the last notified ticket.
- before := syncCond_last_ticket(&mu.c)
- mu.c.Broadcast() // awakes all blocked!
- after := syncCond_last_ticket(&mu.c)
-
- // If ticket changed, this indicates
- // AT LEAST one goroutine was awoken.
- //
- // (before != after) => (waiters > 0)
- // (before == after) => (waiters = 0)
- return (before == after)
-
- case mu.l < 0:
- panic("BUG: negative lock count")
- case mu.t == lockTypeWrite:
- panic("BUG: multiple write locks")
- }
-
- // i.e. mutex still
- // locked by others.
- return false
-}
-
-// WaitRelock expects a mutex to be passed in, already in the
-// locked state. It incr the notifyList waiter count before
-// unlocking the outer mutex and blocking on notifyList wait.
-// On awake it will decr wait count and relock outer mutex.
-func (mu *rwmutex) WaitRelock() { mu.c.Wait() }
diff --git a/vendor/codeberg.org/gruf/go-mutexes/map_unsafe.go b/vendor/codeberg.org/gruf/go-mutexes/map_unsafe.go
deleted file mode 100644
index 829b2597f..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/map_unsafe.go
+++ /dev/null
@@ -1,41 +0,0 @@
-//go:build go1.22 && !go1.26
-
-package mutexes
-
-import (
- "sync"
- "sync/atomic"
- "unsafe"
-)
-
-// syncCond_last_ticket is an unsafe function that returns
-// the ticket of the last awoken / notified goroutine by a
-// a sync.Cond{}. it relies on expected memory layout.
-func syncCond_last_ticket(c *sync.Cond) uint32 {
-
- // NOTE: must remain in
- // sync with runtime.notifyList{}.
- //
- // goexperiment.staticlockranking
- // does change it slightly, but
- // this does not alter the first
- // 2 fields which are all we need.
- type notifyList struct {
- _ uint32
- notify uint32
- // ... other fields
- }
-
- // NOTE: must remain in
- // sync with sync.Cond{}.
- type syncCond struct {
- _ struct{}
- L sync.Locker
- n notifyList
- // ... other fields
- }
-
- // This field must be atomcially accessed.
- cptr := (*syncCond)(unsafe.Pointer(c))
- return atomic.LoadUint32(&cptr.n.notify)
-}
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 e00444b64..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package mutexes
-
-import (
- "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
- }
-
- // Start timer to call fn.
- t := time.AfterFunc(d, fn)
-
- // Wrap unlock to stop mutex timer.
- return func() { t.Stop(); unlock() }
-}
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 e02dcab22..000000000
--- a/vendor/codeberg.org/gruf/go-runners/context.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package runners
-
-import (
- "context"
- "sync/atomic"
- "time"
-)
-
-// closedctx is an always closed context.
-var closedctx = func() context.Context {
- ctx := make(chan struct{})
- close(ctx)
- return CancelCtx(ctx)
-}()
-
-// Closed returns an always closed context.
-func Closed() context.Context {
- return closedctx
-}
-
-// CtxWithCancel returns a new context.Context impl with cancel.
-func CtxWithCancel() (context.Context, context.CancelFunc) {
- var once atomic.Uint32
- ctx := make(chan struct{})
- return CancelCtx(ctx), func() {
- if once.CompareAndSwap(0, 1) {
- 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
-}
-
-func (ctx CancelCtx) String() string {
- var state string
- select {
- case <-ctx:
- state = "closed"
- default:
- state = "open"
- }
- return "CancelCtx{state:" + state + "}"
-}
-
-func (ctx CancelCtx) GoString() string {
- return "runners." + ctx.String()
-}
diff --git a/vendor/codeberg.org/gruf/go-runners/pointer.go b/vendor/codeberg.org/gruf/go-runners/pointer.go
deleted file mode 100644
index cc139309f..000000000
--- a/vendor/codeberg.org/gruf/go-runners/pointer.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package runners
-
-import (
- "sync/atomic"
- "unsafe"
-)
-
-// atomic_pointer wraps an unsafe.Pointer with
-// receiver methods for their atomic counterparts.
-type atomic_pointer struct{ p unsafe.Pointer }
-
-func (p *atomic_pointer) Load() unsafe.Pointer {
- return atomic.LoadPointer(&p.p)
-}
-
-func (p *atomic_pointer) Store(ptr unsafe.Pointer) {
- atomic.StorePointer(&p.p, ptr)
-}
-
-func (p *atomic_pointer) CAS(old, new unsafe.Pointer) bool {
- return atomic.CompareAndSwapPointer(&p.p, old, new)
-}
diff --git a/vendor/codeberg.org/gruf/go-runners/process.go b/vendor/codeberg.org/gruf/go-runners/process.go
deleted file mode 100644
index 3feeff258..000000000
--- a/vendor/codeberg.org/gruf/go-runners/process.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package runners
-
-import (
- "fmt"
- "unsafe"
-
- "sync"
-)
-
-// Processor acts similarly to a sync.Once object, except that it is reusable. After
-// the first call to Process(), any further calls before this first has returned will
-// block until the first call has returned, and return the same error. This ensures
-// that only a single instance of it is ever running at any one time.
-type Processor struct{ p atomic_pointer }
-
-// Process will process the given function if first-call, else blocking until
-// the first function has returned, returning the same error result.
-func (p *Processor) Process(proc func() error) (err error) {
- var i *proc_instance
-
- for {
- // Attempt to load existing instance.
- ptr := (*proc_instance)(p.p.Load())
- if ptr != nil {
-
- // Wait on existing.
- ptr.wait.Wait()
- err = ptr.err
- return
- }
-
- if i == nil {
- // Allocate instance.
- i = new(proc_instance)
- i.wait.Add(1)
- }
-
- // Try to acquire start slot by
- // setting ptr to *our* instance.
- if p.p.CAS(nil, unsafe.Pointer(i)) {
- defer func() {
- if r := recover(); r != nil {
- if i.err != nil {
- rOld := r // wrap the panic so we don't lose existing returned error
- r = fmt.Errorf("panic occured after error %q: %v", i.err.Error(), rOld)
- }
-
- // Catch panics and wrap as error return.
- i.err = fmt.Errorf("caught panic: %v", r)
- }
-
- // Set return.
- err = i.err
-
- // Release the
- // goroutines.
- i.wait.Done()
-
- // Free processor.
- p.p.Store(nil)
- }()
-
- // Run func.
- i.err = proc()
- return
- }
- }
-}
-
-type proc_instance struct {
- wait sync.WaitGroup
- err error
-}
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 fe41807f9..000000000
--- a/vendor/codeberg.org/gruf/go-runners/service.go
+++ /dev/null
@@ -1,222 +0,0 @@
-package runners
-
-import (
- "context"
- "sync"
- "sync/atomic"
- "unsafe"
-)
-
-// 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{ p atomic_pointer }
-
-// Run will run the supplied function until completion, using 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)) (ok bool) {
- var ptr *svc_instance
-
- // Attempt to start.
- ptr, ok = svc.start()
- if !ok {
- return
- }
-
- // Run given function.
- defer svc.on_done(ptr)
- fn(CancelCtx(ptr.done))
- return
-}
-
-// GoRun will run the supplied function until completion in a goroutine, using given context to
-// propagate cancel. Immediately returns boolean indicating success, or that service is already running.
-func (svc *Service) GoRun(fn func(context.Context)) (ok bool) {
- var ptr *svc_instance
-
- // Attempt to start.
- ptr, ok = svc.start()
- if !ok {
- return
- }
-
- go func() {
- // Run given function.
- defer svc.on_done(ptr)
- fn(CancelCtx(ptr.done))
- }()
-
- return
-}
-
-// RunWait is functionally the same as .Run(), but blocks until the first instance of .Run() returns.
-func (svc *Service) RunWait(fn func(context.Context)) (ok bool) {
- var ptr *svc_instance
-
- // Attempt to start.
- ptr, ok = svc.start()
- if !ok {
- <-ptr.done
- return
- }
-
- // Run given function.
- defer svc.on_done(ptr)
- fn(CancelCtx(ptr.done))
- return
-}
-
-// GoRunWait is functionally the same as .RunWait(), but blocks until the first instance of RunWait() returns.
-func (svc *Service) GoRunWait(fn func(context.Context)) (ok bool) {
- var ptr *svc_instance
-
- // Attempt to start.
- ptr, ok = svc.start()
- if !ok {
- <-ptr.done
- return
- }
-
- go func() {
- // Run given function.
- defer svc.on_done(ptr)
- fn(CancelCtx(ptr.done))
- }()
-
- return
-}
-
-// 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 {
- return svc.must_get().stop()
-}
-
-// Running returns if Service is running (i.e. NOT fully stopped, but may be *stopping*).
-func (svc *Service) Running() bool {
- return svc.must_get().running()
-}
-
-// 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{} {
- return svc.must_get().done
-}
-
-func (svc *Service) start() (*svc_instance, bool) {
- ptr := svc.must_get()
- return ptr, ptr.start()
-}
-
-func (svc *Service) on_done(ptr *svc_instance) {
- // Ensure stopped.
- ptr.stop_private()
-
- // Free service.
- svc.p.Store(nil)
-}
-
-func (svc *Service) must_get() *svc_instance {
- var newptr *svc_instance
-
- for {
- // Try to load existing instance.
- ptr := (*svc_instance)(svc.p.Load())
- if ptr != nil {
- return ptr
- }
-
- if newptr == nil {
- // Allocate new instance.
- newptr = new(svc_instance)
- newptr.done = make(chan struct{})
- }
-
- // Attempt to acquire slot by setting our ptr.
- if !svc.p.CAS(nil, unsafe.Pointer(newptr)) {
- continue
- }
-
- return newptr
- }
-}
-
-type svc_instance struct {
- wait sync.WaitGroup
- done chan struct{}
- state atomic.Uint32
-}
-
-const (
- started_bit = uint32(1) << 0
- stopping_bit = uint32(1) << 1
- finished_bit = uint32(1) << 2
-)
-
-func (i *svc_instance) start() (ok bool) {
- // Acquire start by setting 'started' bit.
- switch old := i.state.Or(started_bit); {
-
- case old&finished_bit != 0:
- // Already finished.
-
- case old&started_bit == 0:
- // Successfully started!
- i.wait.Add(1)
- ok = true
- }
-
- return
-}
-
-// NOTE: MAY ONLY BE CALLED BY STARTING GOROUTINE.
-func (i *svc_instance) stop_private() {
- // Attempt set both stopping and finished bits.
- old := i.state.Or(stopping_bit | finished_bit)
-
- // Only if we weren't already
- // stopping do we close channel.
- if old&stopping_bit == 0 {
- close(i.done)
- }
-
- // Release
- // waiters.
- i.wait.Done()
-}
-
-func (i *svc_instance) stop() (ok bool) {
- // Attempt to set the 'stopping' bit.
- switch old := i.state.Or(stopping_bit); {
-
- case old&finished_bit != 0:
- // Already finished.
- return
-
- case old&started_bit == 0:
- // This was never started
- // to begin with, just mark
- // as fully finished here.
- _ = i.state.Or(finished_bit)
- return
-
- case old&stopping_bit == 0:
- // We succesfully stopped
- // instance, close channel.
- close(i.done)
- ok = true
- }
-
- // Wait on stop.
- i.wait.Wait()
- return
-}
-
-// running returns whether service was started and
-// is not yet finished. that indicates that it may
-// have been started and not yet stopped, or that
-// it was started, stopped and not yet returned.
-func (i *svc_instance) running() bool {
- val := i.state.Load()
- return val&started_bit != 0 &&
- val&finished_bit == 0
-}
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 0a9439577..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 AMD Ryzen 7 7840u): 2ms precision with 95% tolerance.
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 f3bd869d2..000000000
--- a/vendor/codeberg.org/gruf/go-sched/job.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package sched
-
-import (
- "reflect"
- "strconv"
- "strings"
- "sync/atomic"
- "time"
- "unsafe"
-)
-
-// 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 atomic_time
- timing Timing
- call func(time.Time)
-}
-
-// 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,
- }
-
- 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.id != 0 {
- // Cannot update scheduled job
- panic("job already scheduled")
- }
-
- 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
-}
-
-// 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) { 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()
-}
-
-type atomic_time struct{ p unsafe.Pointer }
-
-func (t *atomic_time) Load() time.Time {
- if p := atomic.LoadPointer(&t.p); p != nil {
- return *(*time.Time)(p)
- }
- return zerotime
-}
-
-func (t *atomic_time) Store(v time.Time) {
- atomic.StorePointer(&t.p, unsafe.Pointer(&v))
-}
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 9ab5b8bc8..000000000
--- a/vendor/codeberg.org/gruf/go-sched/scheduler.go
+++ /dev/null
@@ -1,343 +0,0 @@
-package sched
-
-import (
- "context"
- "sort"
- "sync"
- "sync/atomic"
- "time"
- "unsafe"
-
- "codeberg.org/gruf/go-runners"
-)
-
-// Precision is the maximum time we can
-// offer scheduler run-time precision down to.
-const Precision = 2 * time.Millisecond
-
-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 {
- svc runners.Service // svc manages the main scheduler routine
- jobs []*Job // jobs is a list of tracked Jobs to be executed
- jch atomic_channel // jch accepts either Jobs or job IDs to notify new/removed jobs
- jid atomic.Uint64 // jid is used to iteratively generate unique IDs for jobs
-}
-
-// 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 {
- var wait sync.WaitGroup
-
- // Use waiter to synchronize between started
- // goroutine and ourselves, to ensure that
- // we don't return before Scheduler init'd.
- wait.Add(1)
-
- ok := sch.svc.GoRun(func(ctx context.Context) {
- // Prepare new channel.
- ch := new(channel)
- ch.ctx = ctx.Done()
- ch.ch = make(chan interface{})
- sch.jch.Store(ch)
-
- // Release
- // start fn
- wait.Done()
-
- // Main loop
- sch.run(ch)
- })
-
- if ok {
- // Wait on
- // goroutine
- wait.Wait()
- } else {
- // Release
- wait.Done()
- }
-
- return ok
-}
-
-// 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 (i.e. NOT stopped / stopping).
-func (sch *Scheduler) Running() bool {
- return sch.svc.Running()
-}
-
-// Done returns a channel that's closed when Scheduler.Stop() is called.
-func (sch *Scheduler) Done() <-chan struct{} {
- return sch.svc.Done()
-}
-
-// Schedule will add provided Job to the Scheduler, returning a cancel function.
-func (sch *Scheduler) Schedule(job *Job) (cancel func()) {
- if job == nil {
- panic("nil job")
- }
-
- // Load job channel.
- ch := sch.jch.Load()
- if ch == nil {
- panic("not running")
- }
-
- // Calculate next job ID.
- job.id = sch.jid.Add(1)
-
- // Pass job
- // to channel.
- if !ch.w(job) {
- panic("not running")
- }
-
- // Return cancel function for job
- return func() { ch.w(job.id) }
-}
-
-// run is the main scheduler run routine, which runs for as long as ctx is valid.
-func (sch *Scheduler) run(ch *channel) {
- defer ch.close()
- if ch == nil {
- panic("nil channel")
- } else if sch == nil {
- panic("nil scheduler")
- }
-
- var (
- // now stores the current time, and will only be
- // set when the timer channel is set to be the
- // 'alwaysticks' channel. this allows minimizing
- // the number of calls required to time.Now().
- now time.Time
-
- // 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 always / never ticks).
- 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
- }
- }
- )
-
- // Create a stopped timer.
- timer = time.NewTimer(1)
- <-timer.C
-
- for {
- // Reset timer state.
- timerset = false
-
- if len(sch.jobs) > 0 {
- // Get now time.
- now = time.Now()
-
- // Sort by next occurring.
- sort.Sort(byNext(sch.jobs))
-
- // 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.
- if until := next.Sub(now); until <= Precision/1e3 {
-
- // This job is behind,
- // set to always tick.
- tch = alwaysticks
- } else {
-
- // Reset timer to period.
- timer.Reset(until)
- timerset = true
- tch = timer.C
- }
- } else {
-
- // Unset timer
- tch = neverticks
- }
-
- select {
- // Scheduler stopped
- case <-ch.done():
- stopdrain()
- return
-
- // Timer ticked,
- // run scheduled.
- case t, ok := <-tch:
- if !ok {
- // 'alwaysticks' returns zero
- // times, BUT 'now' will have
- // been set during above sort.
- t = now
- }
- sch.schedule(t)
-
- // Received update,
- // handle job/id.
- case v := <-ch.r():
- 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 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
- }
-
- // Run the job.
- go job.Run(now)
-
- // Update the next call time.
- next := job.timing.Next(now)
- job.next.Store(next)
-
- 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]
-}
-
-// atomic_channel wraps a *channel{} with atomic store / load.
-type atomic_channel struct{ p unsafe.Pointer }
-
-func (c *atomic_channel) Load() *channel {
- if p := atomic.LoadPointer(&c.p); p != nil {
- return (*channel)(p)
- }
- return nil
-}
-
-func (c *atomic_channel) Store(v *channel) {
- atomic.StorePointer(&c.p, unsafe.Pointer(v))
-}
-
-// channel wraps both a context done
-// channel and a generic interface channel
-// to support safe writing to an underlying
-// channel that correctly fails after close.
-type channel struct {
- ctx <-chan struct{}
- ch chan interface{}
-}
-
-// done returns internal context channel.
-func (ch *channel) done() <-chan struct{} {
- return ch.ctx
-}
-
-// r returns internal channel for read.
-func (ch *channel) r() chan interface{} {
- return ch.ch
-}
-
-// w writes 'v' to channel, or returns false if closed.
-func (ch *channel) w(v interface{}) bool {
- select {
- case <-ch.ctx:
- return false
- case ch.ch <- v:
- return true
- }
-}
-
-// close closes underlying channel.
-func (ch *channel) close() {
- close(ch.ch)
-}
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 cb9b4925a..000000000
--- a/vendor/codeberg.org/gruf/go-sched/timing.go
+++ /dev/null
@@ -1,99 +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-split/LICENSE b/vendor/codeberg.org/gruf/go-split/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-split/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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-split/README.md b/vendor/codeberg.org/gruf/go-split/README.md
deleted file mode 100644
index 6c9368864..000000000
--- a/vendor/codeberg.org/gruf/go-split/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-split
-
-Performant string splitting and joining by comma, taking quotes into account. Useful for user supplied input e.g. CLI args
diff --git a/vendor/codeberg.org/gruf/go-split/join.go b/vendor/codeberg.org/gruf/go-split/join.go
deleted file mode 100644
index f506d969e..000000000
--- a/vendor/codeberg.org/gruf/go-split/join.go
+++ /dev/null
@@ -1,112 +0,0 @@
-package split
-
-import (
- "strconv"
- "time"
- "unsafe"
-
- "codeberg.org/gruf/go-bytesize"
-)
-
-// joinFunc will join given slice of elements, using the passed function to append each element at index
-// from the slice, forming a combined comma-space separated string. Passed size is for buffer preallocation.
-func JoinFunc[T any](slice []T, each func(buf []byte, value T) []byte, size int) string {
-
- // Move nil check
- // outside main loop.
- if each == nil {
- panic("nil func")
- }
-
- // Catch easiest case
- if len(slice) == 0 {
- return ""
- }
-
- // Preallocate string buffer (size + commas)
- buf := make([]byte, 0, size+len(slice)-1)
-
- for _, value := range slice {
- // Append each item
- buf = each(buf, value)
- buf = append(buf, ',', ' ')
- }
-
- // Drop final comma-space
- buf = buf[:len(buf)-2]
-
- // Directly cast buf to string
- data := unsafe.SliceData(buf)
- return unsafe.String(data, len(buf))
-}
-
-// JoinStrings will pass string slice to JoinFunc(), quoting where
-// necessary and combining into a single comma-space separated string.
-func JoinStrings[String ~string](slice []String) string {
- var size int
- for _, str := range slice {
- size += len(str)
- }
- return JoinFunc(slice, func(buf []byte, value String) []byte {
- return appendQuote(buf, string(value))
- }, size)
-}
-
-// JoinBools will pass bool slice to JoinFunc(), formatting
-// and combining into a single comma-space separated string.
-func JoinBools[Bool ~bool](slice []Bool) string {
- return JoinFunc(slice, func(buf []byte, value Bool) []byte {
- return strconv.AppendBool(buf, bool(value))
- }, len(slice)*5 /* len("false") */)
-}
-
-// JoinInts will pass signed integer slice to JoinFunc(), formatting
-// and combining into a single comma-space separated string.
-func JoinInts[Int Signed](slice []Int) string {
- return JoinFunc(slice, func(buf []byte, value Int) []byte {
- return strconv.AppendInt(buf, int64(value), 10)
- }, len(slice)*20) // max signed int str len
-}
-
-// JoinUints will pass unsigned integer slice to JoinFunc(),
-// formatting and combining into a single comma-space separated string.
-func JoinUints[Uint Unsigned](slice []Uint) string {
- return JoinFunc(slice, func(buf []byte, value Uint) []byte {
- return strconv.AppendUint(buf, uint64(value), 10)
- }, len(slice)*20) // max unsigned int str len
-}
-
-// JoinFloats will pass float slice to JoinFunc(), formatting
-// and combining into a single comma-space separated string.
-func JoinFloats[Float_ Float](slice []Float_) string {
- bits := int(unsafe.Sizeof(Float_(0)) * 8) // param type bits
- return JoinFunc(slice, func(buf []byte, value Float_) []byte {
- return strconv.AppendFloat(buf, float64(value), 'g', -1, bits)
- }, len(slice)*20) // max signed int str len (it's a good guesstimate)
-}
-
-// JoinSizes will pass byte size slice to JoinFunc(), formatting
-// and combining into a single comma-space separated string.
-func JoinSizes(slice []bytesize.Size) string {
- const iecLen = 7 // max IEC string length
- return JoinFunc(slice, func(buf []byte, value bytesize.Size) []byte {
- return value.AppendFormatIEC(buf)
- }, len(slice)*iecLen)
-}
-
-// JoinDurations will pass duration slice to JoinFunc(), formatting
-// and combining into a single comma-space separated string.
-func JoinDurations(slice []time.Duration) string {
- const durLen = 10 // max duration string length
- return JoinFunc(slice, func(buf []byte, value time.Duration) []byte {
- return append(buf, value.String()...)
- }, len(slice)*durLen)
-}
-
-// JoinTimes will pass time slice to JoinFunc(), formatting
-// and combining into a single comma-space separated string.
-func JoinTimes(slice []time.Time, format string) string {
- return JoinFunc(slice, func(buf []byte, value time.Time) []byte {
- return value.AppendFormat(buf, format)
- }, len(slice)*len(format))
-}
diff --git a/vendor/codeberg.org/gruf/go-split/join_util.go b/vendor/codeberg.org/gruf/go-split/join_util.go
deleted file mode 100644
index e517fe908..000000000
--- a/vendor/codeberg.org/gruf/go-split/join_util.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package split
-
-import (
- "strconv"
- "strings"
-)
-
-// singleTermLine: beyond a certain length of string, all of the
-// extra checks to handle quoting/not-quoting add a significant
-// amount of extra processing time. Quoting in this manner only really
-// effects readability on a single line, so a max string length that
-// encompasses the maximum number of columns on *most* terminals was
-// selected. This was chosen using the metric that 1080p is one of the
-// most common display resolutions, and that a relatively small font size
-// of 7 requires ~ 223 columns. So 256 should be >= $COLUMNS (fullscreen)
-// in 99% of usecases (these figures all pulled out of my ass).
-const singleTermLine = 256
-
-// appendQuote will append 'str' to 'buf', double quoting and escaping if needed.
-func appendQuote(buf []byte, str string) []byte {
- switch {
- case len(str) > singleTermLine || !strconv.CanBackquote(str):
- // Append quoted and escaped string
- return strconv.AppendQuote(buf, str)
-
- case (strings.IndexByte(str, '"') != -1):
- // Double quote and escape string
- buf = append(buf, '"')
- buf = appendEscape(buf, str)
- buf = append(buf, '"')
- return buf
-
- case (strings.IndexByte(str, ',') != -1):
- // Double quote this string as-is
- buf = append(buf, '"')
- buf = append(buf, str...)
- buf = append(buf, '"')
- return buf
-
- default:
- // Append string as-is
- return append(buf, str...)
- }
-}
-
-// appendEscape will append 'str' to 'buf' and escape any double quotes.
-func appendEscape(buf []byte, str string) []byte {
- var delim bool
- for i := range str {
- switch {
- case str[i] == '\\' && !delim:
- // Set delim flag
- delim = true
-
- case str[i] == '"' && !delim:
- // Append escaped double quote
- buf = append(buf, `\"`...)
-
- case delim:
- // Append skipped slash
- buf = append(buf, `\`...)
- delim = false
- fallthrough
-
- default:
- // Append char as-is
- buf = append(buf, str[i])
- }
- }
- return buf
-}
diff --git a/vendor/codeberg.org/gruf/go-split/split.go b/vendor/codeberg.org/gruf/go-split/split.go
deleted file mode 100644
index 3f55d7bc6..000000000
--- a/vendor/codeberg.org/gruf/go-split/split.go
+++ /dev/null
@@ -1,187 +0,0 @@
-package split
-
-import (
- "strconv"
- "time"
- "unsafe"
-
- "codeberg.org/gruf/go-bytesize"
-)
-
-// Signed defines a signed
-// integer generic type parameter.
-type Signed interface {
- ~int | ~int8 | ~int16 | ~int32 | ~int64
-}
-
-// Unsigned defines an unsigned
-// integer generic type paramter.
-type Unsigned interface {
- ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
-}
-
-// Float defines a float-type generic parameter.
-type Float interface{ ~float32 | ~float64 }
-
-// SplitFunc will split input string on commas, taking into account string quoting
-// and stripping extra whitespace, passing each split to the given function hook.
-func SplitFunc(str string, fn func(string) error) error {
- return (&Splitter{}).SplitFunc(str, fn)
-}
-
-// SplitStrings will pass string input to SplitFunc(), compiling a slice of strings.
-func SplitStrings[String ~string](str string) ([]String, error) {
- var slice []String
-
- // Simply append each split string to slice
- if err := SplitFunc(str, func(s string) error {
- slice = append(slice, String(s))
- return nil
- }); err != nil {
- return nil, err
- }
-
- return slice, nil
-}
-
-// SplitBools will pass string input to SplitFunc(), parsing and compiling a slice of bools.
-func SplitBools[Bool ~bool](str string) ([]Bool, error) {
- var slice []Bool
-
- // Parse each bool split from input string
- if err := SplitFunc(str, func(s string) error {
- b, err := strconv.ParseBool(s)
- if err != nil {
- return err
- }
- slice = append(slice, Bool(b))
- return nil
- }); err != nil {
- return nil, err
- }
-
- return slice, nil
-}
-
-// SplitInts will pass string input to SplitFunc(), parsing and compiling a slice of signed integers.
-func SplitInts[Int Signed](str string) ([]Int, error) {
- // Determine bits from param type size
- bits := int(unsafe.Sizeof(Int(0)) * 8)
-
- var slice []Int
-
- // Parse each int split from input string
- if err := SplitFunc(str, func(s string) error {
- i, err := strconv.ParseInt(s, 10, bits)
- if err != nil {
- return err
- }
- slice = append(slice, Int(i))
- return nil
- }); err != nil {
- return nil, err
- }
-
- return slice, nil
-}
-
-// SplitUints will pass string input to SplitFunc(), parsing and compiling a slice of unsigned integers.
-func SplitUints[Uint Unsigned](str string) ([]Uint, error) {
- // Determine bits from param type size
- bits := int(unsafe.Sizeof(Uint(0)) * 8)
-
- var slice []Uint
-
- // Parse each uint split from input string
- if err := SplitFunc(str, func(s string) error {
- u, err := strconv.ParseUint(s, 10, bits)
- if err != nil {
- return err
- }
- slice = append(slice, Uint(u))
- return nil
- }); err != nil {
- return nil, err
- }
-
- return slice, nil
-}
-
-// SplitFloats will pass string input to SplitFunc(), parsing and compiling a slice of floats.
-func SplitFloats[Float_ Float](str string) ([]Float_, error) {
- // Determine bits from param type size
- bits := int(unsafe.Sizeof(Float_(0)) * 8)
-
- var slice []Float_
-
- // Parse each float split from input string
- if err := SplitFunc(str, func(s string) error {
- f, err := strconv.ParseFloat(s, bits)
- if err != nil {
- return err
- }
- slice = append(slice, Float_(f))
- return nil
- }); err != nil {
- return nil, err
- }
-
- return slice, nil
-}
-
-// SplitSizes will pass string input to SplitFunc(), parsing and compiling a slice of byte sizes.
-func SplitSizes(str string) ([]bytesize.Size, error) {
- var slice []bytesize.Size
-
- // Parse each size split from input string
- if err := SplitFunc(str, func(s string) error {
- sz, err := bytesize.ParseSize(s)
- if err != nil {
- return err
- }
- slice = append(slice, sz)
- return nil
- }); err != nil {
- return nil, err
- }
-
- return slice, nil
-}
-
-// SplitDurations will pass string input to SplitFunc(), parsing and compiling a slice of durations.
-func SplitDurations(str string) ([]time.Duration, error) {
- var slice []time.Duration
-
- // Parse each duration split from input string
- if err := SplitFunc(str, func(s string) error {
- d, err := time.ParseDuration(s)
- if err != nil {
- return err
- }
- slice = append(slice, d)
- return nil
- }); err != nil {
- return nil, err
- }
-
- return slice, nil
-}
-
-// SplitTimes will pass string input to SplitFunc(), parsing and compiling a slice of times.
-func SplitTimes(str string, format string) ([]time.Time, error) {
- var slice []time.Time
-
- // Parse each time split from input string
- if err := SplitFunc(str, func(s string) error {
- t, err := time.Parse(s, format)
- if err != nil {
- return err
- }
- slice = append(slice, t)
- return nil
- }); err != nil {
- return nil, err
- }
-
- return slice, nil
-}
diff --git a/vendor/codeberg.org/gruf/go-split/splitter.go b/vendor/codeberg.org/gruf/go-split/splitter.go
deleted file mode 100644
index e87cd8454..000000000
--- a/vendor/codeberg.org/gruf/go-split/splitter.go
+++ /dev/null
@@ -1,204 +0,0 @@
-package split
-
-import (
- "errors"
- "strings"
- "unicode"
- "unicode/utf8"
-)
-
-// Splitter holds onto a byte buffer for use in minimising allocations during SplitFunc().
-type Splitter struct{ B []byte }
-
-// SplitFunc will split input string on commas, taking into account string quoting and
-// stripping extra whitespace, passing each split to the given function hook.
-func (s *Splitter) SplitFunc(str string, fn func(string) error) error {
- for {
- // Reset buffer
- s.B = s.B[0:0]
-
- // Trim leading space
- str = trimLeadingSpace(str)
-
- if len(str) < 1 {
- // Reached end
- return nil
- }
-
- switch {
- // Single / double quoted
- case str[0] == '\'', str[0] == '"':
- // Calculate next string elem
- i := 1 + s.next(str[1:], str[0])
- if i == 0 /* i.e. if .next() returned -1 */ {
- return errors.New("missing end quote")
- }
-
- // Pass next element to callback func
- if err := fn(string(s.B)); err != nil {
- return err
- }
-
- // Reslice + trim leading space
- str = trimLeadingSpace(str[i+1:])
-
- if len(str) < 1 {
- // reached end
- return nil
- }
-
- if str[0] != ',' {
- // malformed element without comma after quote
- return errors.New("missing comma separator")
- }
-
- // Skip comma
- str = str[1:]
-
- // Empty segment
- case str[0] == ',':
- str = str[1:]
-
- // No quoting
- default:
- // Calculate next string elem
- i := s.next(str, ',')
-
- switch i {
- // Reached end
- case -1:
- // we know len > 0
-
- // Pass to callback
- return fn(string(s.B))
-
- // Empty elem
- case 0:
- str = str[1:]
-
- // Non-zero elem
- default:
- // Pass next element to callback
- if err := fn(string(s.B)); err != nil {
- return err
- }
-
- // Skip past eleme
- str = str[i+1:]
- }
- }
- }
-}
-
-// next will build the next string element in s.B up to non-delimited instance of c,
-// returning number of characters iterated, or -1 if the end of the string was reached.
-func (s *Splitter) next(str string, c byte) int {
- var delims int
-
- // Guarantee buf large enough
- if len(str) > cap(s.B)-len(s.B) {
- nb := make([]byte, 2*cap(s.B)+len(str))
- _ = copy(nb, s.B)
- s.B = nb[:len(s.B)]
- }
-
- for i := 0; i < len(str); i++ {
- // Increment delims
- if str[i] == '\\' {
- delims++
- continue
- }
-
- if str[i] == c {
- var count int
-
- if count = delims / 2; count > 0 {
- // Add backslashes to buffer
- slashes := backslashes(count)
- s.B = append(s.B, slashes...)
- }
-
- // Reached delim'd char
- if delims-count == 0 {
- return i
- }
- } else if delims > 0 {
- // Add backslashes to buffer
- slashes := backslashes(delims)
- s.B = append(s.B, slashes...)
- }
-
- // Write byte to buffer
- s.B = append(s.B, str[i])
-
- // Reset count
- delims = 0
- }
-
- return -1
-}
-
-// asciiSpace is a lookup table of ascii space chars (see: strings.asciiSet).
-var asciiSpace = func() (as [8]uint32) {
- as['\t'/32] |= 1 << ('\t' % 32)
- as['\n'/32] |= 1 << ('\n' % 32)
- as['\v'/32] |= 1 << ('\v' % 32)
- as['\f'/32] |= 1 << ('\f' % 32)
- as['\r'/32] |= 1 << ('\r' % 32)
- as[' '/32] |= 1 << (' ' % 32)
- return
-}()
-
-// trimLeadingSpace trims the leading space from a string.
-func trimLeadingSpace(str string) string {
- var start int
-
- for ; start < len(str); start++ {
- // If beyond ascii range, trim using slower rune check.
- if str[start] >= utf8.RuneSelf {
- return trimLeadingSpaceSlow(str[start:])
- }
-
- // Ascii character
- char := str[start]
-
- // This is first non-space ASCII, trim up to here
- if (asciiSpace[char/32] & (1 << (char % 32))) == 0 {
- break
- }
- }
-
- return str[start:]
-}
-
-// trimLeadingSpaceSlow trims leading space using the slower unicode.IsSpace check.
-func trimLeadingSpaceSlow(str string) string {
- for i, r := range str {
- if !unicode.IsSpace(r) {
- return str[i:]
- }
- }
- return str
-}
-
-// backslashes will return a string of backslashes of given length.
-func backslashes(count int) string {
- const backslashes = `\\\\\\\\\\\\\\\\\\\\`
-
- // Fast-path, use string const
- if count < len(backslashes) {
- return backslashes[:count]
- }
-
- // Slow-path, build custom string
- return backslashSlow(count)
-}
-
-// backslashSlow will build a string of backslashes of custom length.
-func backslashSlow(count int) string {
- var buf strings.Builder
- for i := 0; i < count; i++ {
- buf.WriteByte('\\')
- }
- return buf.String()
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/LICENSE b/vendor/codeberg.org/gruf/go-storage/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-storage/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-storage/README.md b/vendor/codeberg.org/gruf/go-storage/README.md
deleted file mode 100644
index 430b43467..000000000
--- a/vendor/codeberg.org/gruf/go-storage/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# go-storage
-
-A simple library providing various storage implementations with a simple read-write-stat interface.
-
-Supports: on-disk, memory, S3. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-storage/block.archived b/vendor/codeberg.org/gruf/go-storage/block.archived
deleted file mode 100644
index 11a757211..000000000
--- a/vendor/codeberg.org/gruf/go-storage/block.archived
+++ /dev/null
@@ -1,887 +0,0 @@
-package storage
-
-import (
- "bytes"
- "context"
- "crypto/sha256"
- "fmt"
- "io"
- "io/fs"
- "os"
- "strings"
- "sync"
- "sync/atomic"
- "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-iotools"
- "codeberg.org/gruf/go-pools"
- "codeberg.org/gruf/go-store/v2/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.
- 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 <= 0 {
- cfg.BlockSize = DefaultBlockConfig.BlockSize
- }
-
- // Assume 0 buf size == use default
- if cfg.WriteBufSize <= 0 {
- 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, new_error("path is file")
- }
-
- // 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(ctx context.Context) error {
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return err
- }
-
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- nodes := map[string]*node{}
-
- // Walk nodes dir for entries
- err := walkDir(pb, st.nodePath, func(npath string, fsentry fs.DirEntry) error {
- // Only deal with regular files
- if !fsentry.Type().IsRegular() {
- return nil
- }
-
- // Get joined node path name
- npath = pb.Join(npath, fsentry.Name())
-
- // Attempt to open RO file
- file, err := open(npath, defaultFileROFlags)
- if err != nil {
- return err
- }
- 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 {
- return err
- }
-
- // Append to nodes slice
- nodes[fsentry.Name()] = &node
- return nil
- })
-
- // Handle errors (though nodePath may not have been created yet)
- if err != nil && !os.IsNotExist(err) {
- return err
- }
-
- // Walk blocks dir for entries
- err = walkDir(pb, st.blockPath, func(bpath string, fsentry fs.DirEntry) error {
- // Only deal with regular files
- if !fsentry.Type().IsRegular() {
- return nil
- }
-
- 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 nil
- }
-
- // Get joined block path name
- bpath = pb.Join(bpath, fsentry.Name())
-
- // Remove this unused block path
- return os.Remove(bpath)
- })
-
- // Handle errors (though blockPath may not have been created yet)
- if err != nil && !os.IsNotExist(err) {
- return err
- }
-
- // 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(ctx context.Context, key string) ([]byte, error) {
- // Get stream reader for key
- rc, err := st.ReadStream(ctx, 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(ctx context.Context, key string) (io.ReadCloser, error) {
- // Get node file path for key
- npath, err := st.nodePathForKey(key)
- if err != nil {
- return nil, err
- }
-
- // Check if open
- if st.lock.Closed() {
- return nil, ErrClosed
- }
-
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return nil, err
- }
-
- // Attempt to open RO file
- file, err := open(npath, defaultFileROFlags)
- if err != nil {
- return nil, errSwapNotFound(err)
- }
- defer file.Close()
-
- // Acquire hash buffer for writes
- hbuf := st.bufpool.Get()
- defer st.bufpool.Put(hbuf)
-
- var node node
-
- // Write file contents to node
- _, err = st.cppool.Copy(
- &nodeWriter{
- node: &node,
- buf: hbuf,
- },
- file,
- )
- if err != nil {
- return nil, err
- }
-
- // Prepare block reader and return
- return iotools.NopReadCloser(&blockReader{
- storage: st,
- node: &node,
- }), nil
-}
-
-// readBlock reads the block with hash (key) from the filesystem.
-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(new_error("corrupted node"), err)
- }
- defer file.Close()
-
- // Wrap the file in a compressor
- cFile, err := st.config.Compression.Reader(file)
- if err != nil {
- return nil, wrap(new_error("corrupted node"), err)
- }
- defer cFile.Close()
-
- // Read the entire file
- return io.ReadAll(cFile)
-}
-
-// WriteBytes implements Storage.WriteBytes().
-func (st *BlockStorage) WriteBytes(ctx context.Context, key string, value []byte) (int, error) {
- n, err := st.WriteStream(ctx, key, bytes.NewReader(value))
- return int(n), err
-}
-
-// WriteStream implements Storage.WriteStream().
-func (st *BlockStorage) WriteStream(ctx context.Context, key string, r io.Reader) (int64, error) {
- // Get node file path for key
- npath, err := st.nodePathForKey(key)
- if err != nil {
- return 0, err
- }
-
- // Check if open
- if st.lock.Closed() {
- return 0, ErrClosed
- }
-
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return 0, err
- }
-
- // Check if this exists
- ok, err := stat(key)
- if err != nil {
- return 0, err
- }
-
- // Check if we allow overwrites
- if ok && !st.config.Overwrite {
- return 0, ErrAlreadyExists
- }
-
- // Ensure nodes dir (and any leading up to) exists
- err = os.MkdirAll(st.nodePath, defaultDirPerms)
- if err != nil {
- return 0, err
- }
-
- // Ensure blocks dir (and any leading up to) exists
- err = os.MkdirAll(st.blockPath, defaultDirPerms)
- if err != nil {
- return 0, err
- }
-
- var node node
- var total atomic.Int64
-
- // 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 0, 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 0, 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
- n, err := st.writeBlock(sum, buf.B[:n])
- if err != nil {
- onceErr.Store(err)
- return
- }
-
- // Increment total.
- total.Add(int64(n))
- }()
-
- // Break at end
- if atEOF {
- break loop
- }
- }
-
- // Wait, check errors
- wg.Wait()
- if onceErr.IsSet() {
- return 0, onceErr.Load()
- }
-
- // If no hashes created, return
- if len(node.hashes) < 1 {
- return 0, new_error("no hashes written")
- }
-
- // 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 0, 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}, buf.B)
- return total.Load(), err
-}
-
-// writeBlock writes the block with hash and supplied value to the filesystem.
-func (st *BlockStorage) writeBlock(hash string, value []byte) (int, 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 0, err
- }
- defer file.Close()
-
- // Wrap the file in a compressor
- cFile, err := st.config.Compression.Writer(file)
- if err != nil {
- return 0, err
- }
- defer cFile.Close()
-
- // Write value to file
- return cFile.Write(value)
-}
-
-// 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(ctx context.Context, key string) (bool, error) {
- // Get node file path for key
- kpath, err := st.nodePathForKey(key)
- if err != nil {
- return false, err
- }
-
- // Check if open
- if st.lock.Closed() {
- return false, ErrClosed
- }
-
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return false, err
- }
-
- // Check for file on disk
- return stat(kpath)
-}
-
-// Remove implements Storage.Remove().
-func (st *BlockStorage) Remove(ctx context.Context, key string) error {
- // Get node file path for key
- kpath, err := st.nodePathForKey(key)
- if err != nil {
- return err
- }
-
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return err
- }
-
- // 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(ctx context.Context, opts WalkKeysOptions) error {
- // Check if open
- if st.lock.Closed() {
- return ErrClosed
- }
-
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return err
- }
-
- // Acquire path builder
- pb := util.GetPathBuilder()
- defer util.PutPathBuilder(pb)
-
- // Walk dir for entries
- return walkDir(pb, st.nodePath, func(npath string, fsentry fs.DirEntry) error {
- if !fsentry.Type().IsRegular() {
- // Only deal with regular files
- return nil
- }
-
- // Perform provided walk function
- return opts.WalkFn(ctx, Entry{
- Key: fsentry.Name(),
- Size: -1,
- })
- })
-}
-
-// 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)
-
- // 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 {
- 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:]...)
- return true
- }
-
- // Continue iter
- i++
- }
- return false
-}
-
-// 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, new_error("invalid node")
- }
-
- // 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, new_error("invalid node")
- }
-
- // 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-storage/block_test.archived b/vendor/codeberg.org/gruf/go-storage/block_test.archived
deleted file mode 100644
index 8436f067f..000000000
--- a/vendor/codeberg.org/gruf/go-storage/block_test.archived
+++ /dev/null
@@ -1,38 +0,0 @@
-package storage_test
-
-import (
- "os"
- "testing"
-
- "codeberg.org/gruf/go-store/v2/storage"
-)
-
-func TestBlockStorage(t *testing.T) {
- // Set test path, defer deleting it
- testPath := "blockstorage.test"
- t.Cleanup(func() {
- os.RemoveAll(testPath)
- })
-
- // Open new blockstorage instance
- st, err := storage.OpenBlock(testPath, nil)
- if err != nil {
- t.Fatalf("Failed opening storage: %v", err)
- }
-
- // Attempt multi open of same instance
- _, err = storage.OpenBlock(testPath, nil)
- if err == nil {
- t.Fatal("Successfully opened a locked storage instance")
- }
-
- // Run the storage tests
- testStorage(t, st)
-
- // Test reopen storage path
- st, err = storage.OpenBlock(testPath, nil)
- if err != nil {
- t.Fatalf("Failed opening storage: %v", err)
- }
- st.Close()
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/disk/disk.go b/vendor/codeberg.org/gruf/go-storage/disk/disk.go
deleted file mode 100644
index b11346503..000000000
--- a/vendor/codeberg.org/gruf/go-storage/disk/disk.go
+++ /dev/null
@@ -1,467 +0,0 @@
-package disk
-
-import (
- "bytes"
- "context"
- "errors"
- "io"
- "io/fs"
- "os"
- "path"
- "strings"
- "syscall"
-
- "codeberg.org/gruf/go-fastcopy"
- "codeberg.org/gruf/go-fastpath/v2"
- "codeberg.org/gruf/go-storage"
- "codeberg.org/gruf/go-storage/internal"
-)
-
-// ensure DiskStorage conforms to storage.Storage.
-var _ storage.Storage = (*DiskStorage)(nil)
-
-// DefaultConfig returns the default DiskStorage configuration.
-func DefaultConfig() Config {
- return defaultConfig
-}
-
-// immutable default configuration.
-var defaultConfig = Config{
- OpenRead: OpenArgs{syscall.O_RDONLY, 0o644},
- OpenWrite: OpenArgs{syscall.O_CREAT | syscall.O_WRONLY, 0o644},
- MkdirPerms: 0o755,
- WriteBufSize: 4096,
-}
-
-// OpenArgs defines args passed
-// in a syscall.Open() operation.
-type OpenArgs struct {
- Flags int
- Perms uint32
-}
-
-// Config defines options to be
-// used when opening a DiskStorage.
-type Config struct {
-
- // OpenRead are the arguments passed
- // to syscall.Open() when opening a
- // file for read operations.
- OpenRead OpenArgs
-
- // OpenWrite are the arguments passed
- // to syscall.Open() when opening a
- // file for write operations.
- OpenWrite OpenArgs
-
- // MkdirPerms are the permissions used
- // when creating necessary sub-dirs in
- // a storage key with slashes.
- MkdirPerms uint32
-
- // WriteBufSize is the buffer size
- // to use when writing file streams.
- WriteBufSize int
-}
-
-// getDiskConfig returns valid (and owned!) Config for given ptr.
-func getDiskConfig(cfg *Config) Config {
- if cfg == nil {
- // use defaults.
- return defaultConfig
- }
-
- // Ensure non-zero syscall args.
- if cfg.OpenRead.Flags == 0 {
- cfg.OpenRead.Flags = defaultConfig.OpenRead.Flags
- }
- if cfg.OpenRead.Perms == 0 {
- cfg.OpenRead.Perms = defaultConfig.OpenRead.Perms
- }
- if cfg.OpenWrite.Flags == 0 {
- cfg.OpenWrite.Flags = defaultConfig.OpenWrite.Flags
- }
- if cfg.OpenWrite.Perms == 0 {
- cfg.OpenWrite.Perms = defaultConfig.OpenWrite.Perms
- }
- if cfg.MkdirPerms == 0 {
- cfg.MkdirPerms = defaultConfig.MkdirPerms
- }
-
- // Ensure valid write buf.
- if cfg.WriteBufSize <= 0 {
- cfg.WriteBufSize = defaultConfig.WriteBufSize
- }
-
- return Config{
- OpenRead: cfg.OpenRead,
- OpenWrite: cfg.OpenWrite,
- MkdirPerms: cfg.MkdirPerms,
- WriteBufSize: cfg.WriteBufSize,
- }
-}
-
-// DiskStorage is a Storage implementation
-// that stores directly to a filesystem.
-type DiskStorage struct {
- path string // path is the root path of this store
- pool fastcopy.CopyPool // pool is the prepared io copier with buffer pool
- cfg Config // cfg is the supplied configuration for this store
-}
-
-// Open opens a DiskStorage instance for given folder path and configuration.
-func Open(path string, cfg *Config) (*DiskStorage, error) {
- // Check + set config defaults.
- config := getDiskConfig(cfg)
-
- // Clean provided storage path, ensure
- // final '/' to help with path trimming.
- pb := internal.GetPathBuilder()
- path = pb.Clean(path) + "/"
- internal.PutPathBuilder(pb)
-
- // Ensure directories up-to path exist.
- perms := fs.FileMode(config.MkdirPerms)
- err := os.MkdirAll(path, perms)
- if err != nil {
- return nil, err
- }
-
- // Prepare DiskStorage.
- st := &DiskStorage{
- path: path,
- cfg: config,
- }
-
- // Set fastcopy pool buffer size.
- st.pool.Buffer(config.WriteBufSize)
-
- return st, nil
-}
-
-// Clean: implements Storage.Clean().
-func (st *DiskStorage) Clean(ctx context.Context) error {
- // Check context still valid.
- if err := ctx.Err(); err != nil {
- return err
- }
-
- // Clean unused directories.
- return cleanDirs(st.path, OpenArgs{
- Flags: syscall.O_RDONLY,
- })
-}
-
-// ReadBytes: implements Storage.ReadBytes().
-func (st *DiskStorage) ReadBytes(ctx context.Context, key string) ([]byte, error) {
- // Get stream reader for key
- rc, err := st.ReadStream(ctx, key)
- if err != nil {
- return nil, err
- }
-
- // Read all data to memory.
- data, err := io.ReadAll(rc)
- if err != nil {
- _ = rc.Close()
- return nil, err
- }
-
- // Close storage stream reader.
- if err := rc.Close(); err != nil {
- return nil, err
- }
-
- return data, nil
-}
-
-// ReadStream: implements Storage.ReadStream().
-func (st *DiskStorage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error) {
- // Generate file path for key.
- kpath, err := st.Filepath(key)
- if err != nil {
- return nil, err
- }
-
- // Check context still valid.
- if err := ctx.Err(); err != nil {
- return nil, err
- }
-
- // Attempt to open file with read args.
- file, err := open(kpath, st.cfg.OpenRead)
- if err != nil {
-
- if err == syscall.ENOENT {
- // Translate not-found errors and wrap with key.
- err = internal.ErrWithKey(storage.ErrNotFound, key)
- }
-
- return nil, err
- }
-
- return file, nil
-}
-
-// WriteBytes: implements Storage.WriteBytes().
-func (st *DiskStorage) WriteBytes(ctx context.Context, key string, value []byte) (int, error) {
- n, err := st.WriteStream(ctx, key, bytes.NewReader(value))
- return int(n), err
-}
-
-// WriteStream: implements Storage.WriteStream().
-func (st *DiskStorage) WriteStream(ctx context.Context, key string, stream io.Reader) (int64, error) {
- // Acquire path builder buffer.
- pb := internal.GetPathBuilder()
-
- // Generate the file path for given key.
- kpath, subdir, err := st.filepath(pb, key)
- if err != nil {
- return 0, err
- }
-
- // Done with path buffer.
- internal.PutPathBuilder(pb)
-
- // Check context still valid.
- if err := ctx.Err(); err != nil {
- return 0, err
- }
-
- if subdir {
- // Get dir of key path.
- dir := path.Dir(kpath)
-
- // Note that subdir will only be set if
- // the transformed key (without base path)
- // contains any slashes. This is not a
- // definitive check, but it allows us to
- // skip a syscall if mkdirall not needed!
- perms := fs.FileMode(st.cfg.MkdirPerms)
- err = os.MkdirAll(dir, perms)
- if err != nil {
- return 0, err
- }
- }
-
- // Attempt to open file with write args.
- file, err := open(kpath, st.cfg.OpenWrite)
- if err != nil {
-
- if st.cfg.OpenWrite.Flags&syscall.O_EXCL != 0 &&
- err == syscall.EEXIST {
- // Translate already exists errors and wrap with key.
- err = internal.ErrWithKey(storage.ErrAlreadyExists, key)
- }
-
- return 0, err
- }
-
- // Copy provided stream to file interface.
- n, err := st.pool.Copy(file, stream)
- if err != nil {
- _ = file.Close()
- return n, err
- }
-
- // Finally, close file.
- return n, file.Close()
-}
-
-// Stat implements Storage.Stat().
-func (st *DiskStorage) Stat(ctx context.Context, key string) (*storage.Entry, error) {
- // Generate file path for key.
- kpath, err := st.Filepath(key)
- if err != nil {
- return nil, err
- }
-
- // Check context still valid.
- if err := ctx.Err(); err != nil {
- return nil, err
- }
-
- // Stat file on disk.
- stat, err := stat(kpath)
- if stat == nil {
- return nil, err
- }
-
- return &storage.Entry{
- Key: key,
- Size: stat.Size,
- }, nil
-}
-
-// Remove implements Storage.Remove().
-func (st *DiskStorage) Remove(ctx context.Context, key string) error {
- // Generate file path for key.
- kpath, err := st.Filepath(key)
- if err != nil {
- return err
- }
-
- // Check context still valid.
- if err := ctx.Err(); err != nil {
- return err
- }
-
- // Stat file on disk.
- stat, err := stat(kpath)
- if err != nil {
- return err
- }
-
- // Not-found (or handled
- // as) error situations.
- if stat == nil {
- return internal.ErrWithKey(storage.ErrNotFound, key)
- } else if stat.Mode&syscall.S_IFREG == 0 {
- err := errors.New("storage/disk: not a regular file")
- return internal.ErrWithKey(err, key)
- }
-
- // Remove at path (we know this is file).
- if err := unlink(kpath); err != nil {
-
- if err == syscall.ENOENT {
- // Translate not-found errors and wrap with key.
- err = internal.ErrWithKey(storage.ErrNotFound, key)
- }
-
- return err
- }
-
- return nil
-}
-
-// WalkKeys implements Storage.WalkKeys().
-func (st *DiskStorage) WalkKeys(ctx context.Context, opts storage.WalkKeysOpts) error {
- if opts.Step == nil {
- panic("nil step fn")
- }
-
- // Check context still valid.
- if err := ctx.Err(); err != nil {
- return err
- }
-
- // Acquire path builder for walk.
- pb := internal.GetPathBuilder()
- defer internal.PutPathBuilder(pb)
-
- // Dir to walk.
- dir := st.path
-
- if opts.Prefix != "" {
- // Convert key prefix to one of our storage filepaths.
- pathprefix, subdir, err := st.filepath(pb, opts.Prefix)
- if err != nil {
- return internal.ErrWithMsg(err, "prefix error")
- }
-
- if subdir {
- // Note that subdir will only be set if
- // the transformed key (without base path)
- // contains any slashes. This is not a
- // definitive check, but it allows us to
- // update the directory we walk in case
- // it might narrow search parameters!
- dir = path.Dir(pathprefix)
- }
-
- // Set updated storage
- // path prefix in opts.
- opts.Prefix = pathprefix
- }
-
- // Only need to open dirs as read-only.
- args := OpenArgs{Flags: syscall.O_RDONLY}
-
- return walkDir(pb, dir, args, func(kpath string, fsentry fs.DirEntry) error {
- if !fsentry.Type().IsRegular() {
- // Ignore anything but
- // regular file types.
- return nil
- }
-
- // Get full item path (without root).
- kpath = pb.Join(kpath, fsentry.Name())
-
- // Perform a fast filter check against storage path prefix (if set).
- if opts.Prefix != "" && !strings.HasPrefix(kpath, opts.Prefix) {
- return nil // ignore
- }
-
- // Storage key without base.
- key := kpath[len(st.path):]
-
- // Ignore filtered keys.
- if opts.Filter != nil &&
- !opts.Filter(key) {
- return nil // ignore
- }
-
- // Load file info. This should already
- // be loaded due to the underlying call
- // to os.File{}.ReadDir() populating them.
- info, err := fsentry.Info()
- if err != nil {
- return err
- }
-
- // Perform provided walk function
- return opts.Step(storage.Entry{
- Key: key,
- Size: info.Size(),
- })
- })
-}
-
-// Filepath checks and returns a formatted Filepath for given key.
-func (st *DiskStorage) Filepath(key string) (path string, err error) {
- pb := internal.GetPathBuilder()
- path, _, err = st.filepath(pb, key)
- internal.PutPathBuilder(pb)
- return
-}
-
-// filepath performs the "meat" of Filepath(), returning also if path *may* be a subdir of base.
-func (st *DiskStorage) filepath(pb *fastpath.Builder, key string) (path string, subdir bool, err error) {
- // Fast check for whether this may be a
- // sub-directory. This is not a definitive
- // check, it's only for a fastpath check.
- subdir = strings.ContainsRune(key, '/')
-
- // Build from base.
- pb.Append(st.path)
- pb.Append(key)
-
- // Take COPY of bytes.
- path = string(pb.B)
-
- // Check for dir traversal outside base.
- if isDirTraversal(st.path, path) {
- err = internal.ErrWithKey(storage.ErrInvalidKey, key)
- }
-
- return
-}
-
-// 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-storage/disk/fs.go b/vendor/codeberg.org/gruf/go-storage/disk/fs.go
deleted file mode 100644
index 606d8fb0f..000000000
--- a/vendor/codeberg.org/gruf/go-storage/disk/fs.go
+++ /dev/null
@@ -1,206 +0,0 @@
-package disk
-
-import (
- "errors"
- "fmt"
- "io/fs"
- "os"
- "syscall"
-
- "codeberg.org/gruf/go-fastpath/v2"
- "codeberg.org/gruf/go-storage/internal"
-)
-
-// NOTE:
-// These functions are for opening storage files,
-// not necessarily for e.g. initial setup (OpenFile)
-
-// walkDir traverses the dir tree of the supplied path, performing the supplied walkFn on each entry
-func walkDir(pb *fastpath.Builder, path string, args OpenArgs, walkFn func(string, fs.DirEntry) error) error {
- // Read directory entries at path.
- entries, err := readDir(path, args)
- if err != nil {
- return err
- }
-
- // frame represents a directory entry
- // walk-loop snapshot, taken when a sub
- // directory requiring iteration is found
- type frame struct {
- path string
- entries []fs.DirEntry
- }
-
- // stack contains a list of held snapshot
- // frames, representing unfinished upper
- // layers of a directory structure yet to
- // be traversed.
- var stack []frame
-
-outer:
- for {
- if len(entries) == 0 {
- if len(stack) == 0 {
- // Reached end
- break outer
- }
-
- // Pop frame from stack
- frame := stack[len(stack)-1]
- stack = stack[:len(stack)-1]
-
- // Update loop vars
- entries = frame.entries
- path = frame.path
- }
-
- for len(entries) > 0 {
- // Pop next entry from queue
- entry := entries[0]
- entries = entries[1:]
-
- // Pass to provided walk function
- if err := walkFn(path, entry); err != nil {
- return err
- }
-
- if entry.IsDir() {
- // Push current frame to stack
- stack = append(stack, frame{
- path: path,
- entries: entries,
- })
-
- // Update current directory path
- path = pb.Join(path, entry.Name())
-
- // Read next directory entries
- next, err := readDir(path, args)
- if err != nil {
- return err
- }
-
- // Set next entries
- entries = next
-
- continue outer
- }
- }
- }
-
- return nil
-}
-
-// cleanDirs traverses the dir tree of the supplied path, removing any folders with zero children
-func cleanDirs(path string, args OpenArgs) error {
- pb := internal.GetPathBuilder()
- err := cleanDir(pb, path, args, true)
- internal.PutPathBuilder(pb)
- return err
-}
-
-// cleanDir performs the actual dir cleaning logic for the above top-level version.
-func cleanDir(pb *fastpath.Builder, path string, args OpenArgs, top bool) error {
- // Get directory entries at path.
- entries, err := readDir(path, args)
- if err != nil {
- return err
- }
-
- // If no entries, delete dir.
- if !top && len(entries) == 0 {
- return rmdir(path)
- }
-
- var errs []error
-
- // Iterate all directory entries.
- for _, entry := range entries {
-
- if entry.IsDir() {
- // Calculate directory path.
- dir := pb.Join(path, entry.Name())
-
- // Recursively clean sub-directory entries, adding errs.
- if err := cleanDir(pb, dir, args, false); err != nil {
- err = fmt.Errorf("error(s) cleaning subdir %s: %w", dir, err)
- errs = append(errs, err)
- }
- }
- }
-
- // Return combined errors.
- return errors.Join(errs...)
-}
-
-// readDir will open file at path, read the unsorted list of entries, then close.
-func readDir(path string, args OpenArgs) ([]fs.DirEntry, error) {
- // Open directory at path.
- file, err := open(path, args)
- if err != nil {
- return nil, err
- }
-
- // Read ALL directory entries.
- entries, err := file.ReadDir(-1)
-
- // Done with file
- _ = file.Close()
-
- return entries, err
-}
-
-// open is a simple wrapper around syscall.Open().
-func open(path string, args OpenArgs) (*os.File, error) {
- var fd int
- err := retryOnEINTR(func() (err error) {
- fd, err = syscall.Open(path, args.Flags, args.Perms)
- return
- })
- if err != nil {
- return nil, err
- }
- return os.NewFile(uintptr(fd), path), nil
-}
-
-// stat is a simple wrapper around syscall.Stat().
-func stat(path string) (*syscall.Stat_t, error) {
- var stat syscall.Stat_t
- err := retryOnEINTR(func() error {
- return syscall.Stat(path, &stat)
- })
- if err != nil {
- if err == syscall.ENOENT {
- // not-found is no error
- err = nil
- }
- return nil, err
- }
- return &stat, nil
-}
-
-// unlink is a simple wrapper around syscall.Unlink().
-func unlink(path string) error {
- return retryOnEINTR(func() error {
- return syscall.Unlink(path)
- })
-}
-
-// rmdir is a simple wrapper around syscall.Rmdir().
-func rmdir(path string) error {
- return retryOnEINTR(func() error {
- return syscall.Rmdir(path)
- })
-}
-
-// 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
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/errors.go b/vendor/codeberg.org/gruf/go-storage/errors.go
deleted file mode 100644
index 1dd847011..000000000
--- a/vendor/codeberg.org/gruf/go-storage/errors.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package storage
-
-import (
- "errors"
-)
-
-var (
- // ErrNotFound is the error returned when a key cannot be found in storage
- ErrNotFound = errors.New("storage: key not found")
-
- // ErrAlreadyExist is the error returned when a key already exists in storage
- ErrAlreadyExists = errors.New("storage: key already exists")
-
- // ErrInvalidkey is the error returned when an invalid key is passed to storage
- ErrInvalidKey = errors.New("storage: invalid key")
-)
diff --git a/vendor/codeberg.org/gruf/go-storage/internal/errors.go b/vendor/codeberg.org/gruf/go-storage/internal/errors.go
deleted file mode 100644
index 6b10a8c90..000000000
--- a/vendor/codeberg.org/gruf/go-storage/internal/errors.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package internal
-
-func ErrWithKey(err error, key string) error {
- return &errorWithKey{key: key, err: err}
-}
-
-type errorWithKey struct {
- key string
- err error
-}
-
-func (err *errorWithKey) Error() string {
- return err.err.Error() + ": " + err.key
-}
-
-func (err *errorWithKey) Unwrap() error {
- return err.err
-}
-
-func ErrWithMsg(err error, msg string) error {
- return &errorWithMsg{msg: msg, err: err}
-}
-
-type errorWithMsg struct {
- msg string
- err error
-}
-
-func (err *errorWithMsg) Error() string {
- return err.msg + ": " + err.err.Error()
-}
-
-func (err *errorWithMsg) Unwrap() error {
- return err.err
-}
-
-func WrapErr(inner, outer error) error {
- return &wrappedError{inner: inner, outer: outer}
-}
-
-type wrappedError struct {
- inner error
- outer error
-}
-
-func (err *wrappedError) Is(other error) bool {
- return err.inner == other || err.outer == other
-}
-
-func (err *wrappedError) Error() string {
- return err.inner.Error() + ": " + err.outer.Error()
-}
-
-func (err *wrappedError) Unwrap() []error {
- return []error{err.inner, err.outer}
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/internal/path.go b/vendor/codeberg.org/gruf/go-storage/internal/path.go
deleted file mode 100644
index cd1c219bf..000000000
--- a/vendor/codeberg.org/gruf/go-storage/internal/path.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package internal
-
-import (
- "sync"
-
- "codeberg.org/gruf/go-fastpath/v2"
-)
-
-var pathBuilderPool sync.Pool
-
-func GetPathBuilder() *fastpath.Builder {
- v := pathBuilderPool.Get()
- if v == nil {
- pb := new(fastpath.Builder)
- pb.B = make([]byte, 0, 512)
- v = pb
- }
- return v.(*fastpath.Builder)
-}
-
-func PutPathBuilder(pb *fastpath.Builder) {
- pb.Reset()
- pathBuilderPool.Put(pb)
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/memory/memory.go b/vendor/codeberg.org/gruf/go-storage/memory/memory.go
deleted file mode 100644
index db3199338..000000000
--- a/vendor/codeberg.org/gruf/go-storage/memory/memory.go
+++ /dev/null
@@ -1,252 +0,0 @@
-package memory
-
-import (
- "bytes"
- "context"
- "io"
- "strings"
- "sync"
-
- "codeberg.org/gruf/go-storage"
-
- "codeberg.org/gruf/go-storage/internal"
-)
-
-// ensure MemoryStorage conforms to storage.Storage.
-var _ storage.Storage = (*MemoryStorage)(nil)
-
-// 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
-}
-
-// Open opens a new MemoryStorage instance with internal map starting size.
-func Open(size int, overwrites bool) *MemoryStorage {
- return &MemoryStorage{
- ow: overwrites,
- fs: make(map[string][]byte, size),
- }
-}
-
-// Clean: implements Storage.Clean().
-func (st *MemoryStorage) Clean(ctx context.Context) error {
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return err
- }
-
- // Lock map.
- st.mu.Lock()
-
- // Resize map to only necessary size in-mem.
- fs := make(map[string][]byte, len(st.fs))
- for key, val := range st.fs {
- fs[key] = val
- }
- st.fs = fs
-
- // Done with lock.
- st.mu.Unlock()
-
- return nil
-}
-
-// ReadBytes: implements Storage.ReadBytes().
-func (st *MemoryStorage) ReadBytes(ctx context.Context, key string) ([]byte, error) {
- // Check context still valid.
- if err := ctx.Err(); err != nil {
- return nil, err
- }
-
- // Lock map.
- st.mu.Lock()
-
- // Check key in store.
- b, ok := st.fs[key]
- if ok {
-
- // COPY bytes.
- b = copyb(b)
- }
-
- // Done with lock.
- st.mu.Unlock()
-
- if !ok {
- return nil, internal.ErrWithKey(storage.ErrNotFound, key)
- }
-
- return b, nil
-}
-
-// ReadStream: implements Storage.ReadStream().
-func (st *MemoryStorage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error) {
- // Read value data from store.
- b, err := st.ReadBytes(ctx, key)
- if err != nil {
- return nil, err
- }
-
- // Wrap in readcloser.
- r := bytes.NewReader(b)
- return io.NopCloser(r), nil
-}
-
-// WriteBytes: implements Storage.WriteBytes().
-func (st *MemoryStorage) WriteBytes(ctx context.Context, key string, b []byte) (int, error) {
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return 0, err
- }
-
- // Lock map.
- st.mu.Lock()
-
- // Check key in store.
- _, ok := st.fs[key]
-
- if ok && !st.ow {
- // Done with lock.
- st.mu.Unlock()
-
- // Overwrites are disabled, return existing key error.
- return 0, internal.ErrWithKey(storage.ErrAlreadyExists, key)
- }
-
- // Write copy to store.
- st.fs[key] = copyb(b)
-
- // Done with lock.
- st.mu.Unlock()
-
- return len(b), nil
-}
-
-// WriteStream: implements Storage.WriteStream().
-func (st *MemoryStorage) WriteStream(ctx context.Context, key string, r io.Reader) (int64, error) {
- // Read all from reader.
- b, err := io.ReadAll(r)
- if err != nil {
- return 0, err
- }
-
- // Write in-memory data to store.
- n, err := st.WriteBytes(ctx, key, b)
- return int64(n), err
-}
-
-// Stat: implements Storage.Stat().
-func (st *MemoryStorage) Stat(ctx context.Context, key string) (*storage.Entry, error) {
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return nil, err
- }
-
- // Lock map.
- st.mu.Lock()
-
- // Check key in store.
- b, ok := st.fs[key]
-
- // Get entry size.
- sz := int64(len(b))
-
- // Done with lock.
- st.mu.Unlock()
-
- if !ok {
- return nil, nil
- }
-
- return &storage.Entry{
- Key: key,
- Size: sz,
- }, nil
-}
-
-// Remove: implements Storage.Remove().
-func (st *MemoryStorage) Remove(ctx context.Context, key string) error {
- // Check context still valid
- if err := ctx.Err(); err != nil {
- return err
- }
-
- // Lock map.
- st.mu.Lock()
-
- // Check key in store.
- _, ok := st.fs[key]
-
- if ok {
- // Delete store key.
- delete(st.fs, key)
- }
-
- // Done with lock.
- st.mu.Unlock()
-
- if !ok {
- return internal.ErrWithKey(storage.ErrNotFound, key)
- }
-
- return nil
-}
-
-// WalkKeys: implements Storage.WalkKeys().
-func (st *MemoryStorage) WalkKeys(ctx context.Context, opts storage.WalkKeysOpts) error {
- if opts.Step == nil {
- panic("nil step fn")
- }
-
- // Check context still valid.
- if err := ctx.Err(); err != nil {
- return err
- }
-
- var err error
-
- // Lock map.
- st.mu.Lock()
-
- // Ensure unlocked.
- defer st.mu.Unlock()
-
- // Range all key-vals in hash map.
- for key, val := range st.fs {
- // Check for filtered prefix.
- if opts.Prefix != "" &&
- !strings.HasPrefix(key, opts.Prefix) {
- continue // ignore
- }
-
- // Check for filtered key.
- if opts.Filter != nil &&
- !opts.Filter(key) {
- continue // ignore
- }
-
- // Pass to provided step func.
- err = opts.Step(storage.Entry{
- Key: key,
- Size: int64(len(val)),
- })
- if err != nil {
- return err
- }
- }
-
- return err
-}
-
-// copyb returns a copy of byte-slice b.
-func copyb(b []byte) []byte {
- if b == nil {
- return nil
- }
- p := make([]byte, len(b))
- _ = copy(p, b)
- return p
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/s3/cache.go b/vendor/codeberg.org/gruf/go-storage/s3/cache.go
deleted file mode 100644
index 37ff9f321..000000000
--- a/vendor/codeberg.org/gruf/go-storage/s3/cache.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package s3
-
-import (
- "time"
-
- "github.com/minio/minio-go/v7"
-)
-
-// EntryCache should provide a cache of
-// S3 object information for speeding up
-// Get(), Stat() and Remove() operations.
-type EntryCache interface {
-
- // Get should return 'found' = true when information is cached,
- // with 'info' optionally being nilable to allow caching errors.
- Get(key string) (info *CachedObjectInfo, found bool)
-
- // Put should cache the given information under key, with
- // nil CachedObjectInfo{} meaning a 'not found' response.
- Put(key string, info *CachedObjectInfo)
-}
-
-// CachedObjectInfo provides the minimum cacheable
-// set of S3 object information that may be returned
-// from a Get() or Stat() operation, or on Put().
-type CachedObjectInfo struct {
- Key string
- ETag string
- Size int64
- ContentType string
- LastModified time.Time
- VersionID string
-}
-
-// ToObjectInfo converts CachedObjectInfo to returnable minio.ObjectInfo.
-func (info *CachedObjectInfo) ToObjectInfo() minio.ObjectInfo {
- return minio.ObjectInfo{
- Key: info.Key,
- ETag: info.ETag,
- Size: info.Size,
- ContentType: info.ContentType,
- LastModified: info.LastModified,
- VersionID: info.VersionID,
- }
-}
-
-// cacheGet wraps cache.Get() operations to check if cache is nil.
-func cacheGet(cache EntryCache, key string) (*CachedObjectInfo, bool) {
- if cache != nil {
- return cache.Get(key)
- }
- return nil, false
-}
-
-// objectToCachedObjectInfo converts minio.ObjectInfo to CachedObjectInfo for caching.
-func objectToCachedObjectInfo(info minio.ObjectInfo) *CachedObjectInfo {
- return &CachedObjectInfo{
- Key: info.Key,
- ETag: info.ETag,
- Size: info.Size,
- ContentType: info.ContentType,
- LastModified: info.LastModified,
- VersionID: info.VersionID,
- }
-}
-
-// cacheObject wraps cache.Put() operations to check if cache is nil.
-func cacheObject(cache EntryCache, key string, info minio.ObjectInfo) {
- if cache != nil {
- cache.Put(key, objectToCachedObjectInfo(info))
- }
-}
-
-// cacheUpload wraps cache.Put() operations to check if cache is nil, uses ContentType from given opts.
-func cacheUpload(cache EntryCache, key string, info minio.UploadInfo, opts minio.PutObjectOptions) {
- if cache != nil {
- cache.Put(key, &CachedObjectInfo{
- Key: info.Key,
- ETag: info.ETag,
- Size: info.Size,
- ContentType: opts.ContentType,
- LastModified: info.LastModified,
- VersionID: info.VersionID,
- })
- }
-}
-
-// cacheNotFound wraps cache.Put() to check if cache is
-// nil, storing a nil entry (i.e. not found) in cache.
-func cacheNotFound(cache EntryCache, key string) {
- if cache != nil {
- cache.Put(key, nil)
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/s3/cache/cache.go b/vendor/codeberg.org/gruf/go-storage/s3/cache/cache.go
deleted file mode 100644
index ce8aeb63b..000000000
--- a/vendor/codeberg.org/gruf/go-storage/s3/cache/cache.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package cache
-
-import (
- "time"
-
- "codeberg.org/gruf/go-cache/v3/simple"
- "codeberg.org/gruf/go-cache/v3/ttl"
- "codeberg.org/gruf/go-storage/s3"
-)
-
-// check interface conformity.
-var _ s3.EntryCache = &EntryCache{}
-var _ s3.EntryCache = &EntryTTLCache{}
-
-// EntryCache provides a basic implementation
-// of an s3.EntryCache{}. Under the hood it is
-// a mutex locked ordered map with max capacity.
-type EntryCache struct {
- simple.Cache[string, *s3.CachedObjectInfo]
-}
-
-func New(len, cap int) *EntryCache {
- var cache EntryCache
- cache.Init(len, cap)
- return &cache
-}
-
-func (c *EntryCache) Put(key string, info *s3.CachedObjectInfo) {
- c.Cache.Set(key, info)
-}
-
-type EntryTTLCache struct {
- ttl.Cache[string, *s3.CachedObjectInfo]
-}
-
-func NewTTL(len, cap int, ttl time.Duration) *EntryTTLCache {
- var cache EntryTTLCache
- cache.Init(len, cap, ttl)
- return &cache
-}
-
-func (c *EntryTTLCache) Put(key string, info *s3.CachedObjectInfo) {
- c.Cache.Set(key, info)
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/s3/errors.go b/vendor/codeberg.org/gruf/go-storage/s3/errors.go
deleted file mode 100644
index 0b2d3be62..000000000
--- a/vendor/codeberg.org/gruf/go-storage/s3/errors.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package s3
-
-import (
- "strings"
-
- "codeberg.org/gruf/go-storage"
- "codeberg.org/gruf/go-storage/internal"
- "github.com/minio/minio-go/v7"
-)
-
-// CachedErrorResponse can be returned
-// when an S3 is configured with caching,
-// and the basic details of an error
-// response have been stored in the cache.
-type CachedErrorResponse struct {
- Code string
- Key string
-}
-
-func (err *CachedErrorResponse) Error() string {
- return "cached '" + err.Code + "' response for key:" + err.Key
-}
-
-func (err *CachedErrorResponse) Is(other error) bool {
- switch other {
- case storage.ErrNotFound:
- return err.Code == "NoSuchKey"
- case storage.ErrAlreadyExists:
- return err.Code == "Conflict"
- default:
- return false
- }
-}
-
-func isNotFoundError(err error) bool {
- errRsp, ok := err.(minio.ErrorResponse)
- return ok && errRsp.Code == "NoSuchKey"
-}
-
-func isConflictError(err error) bool {
- errRsp, ok := err.(minio.ErrorResponse)
- return ok && errRsp.Code == "Conflict"
-}
-
-func isObjectNameError(err error) bool {
- return strings.HasPrefix(err.Error(), "Object name ")
-}
-
-func cachedNotFoundError(key string) error {
- err := CachedErrorResponse{Code: "NoSuchKey", Key: key}
- return internal.WrapErr(&err, storage.ErrNotFound)
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/s3/s3.go b/vendor/codeberg.org/gruf/go-storage/s3/s3.go
deleted file mode 100644
index bf7eff02f..000000000
--- a/vendor/codeberg.org/gruf/go-storage/s3/s3.go
+++ /dev/null
@@ -1,597 +0,0 @@
-package s3
-
-import (
- "bytes"
- "context"
- "errors"
- "io"
- "net/http"
- "strings"
-
- "codeberg.org/gruf/go-storage"
- "codeberg.org/gruf/go-storage/internal"
- "github.com/minio/minio-go/v7"
- "github.com/minio/minio-go/v7/pkg/s3utils"
-)
-
-// ensure S3Storage conforms to storage.Storage.
-var _ storage.Storage = (*S3Storage)(nil)
-
-// ensure bytes.Reader conforms to ReaderSize.
-var _ ReaderSize = (*bytes.Reader)(nil)
-
-// ReaderSize is an extension of the io.Reader interface
-// that may be implemented by callers of WriteStream() in
-// order to improve performance. When the size is known it
-// is passed onto the underlying minio S3 library.
-type ReaderSize interface {
- io.Reader
- Size() int64
-}
-
-// DefaultConfig returns the default S3Storage configuration.
-func DefaultConfig() Config {
- return defaultConfig
-}
-
-// immutable default configuration.
-var defaultConfig = Config{
- CoreOpts: minio.Options{},
- PutChunkSize: 4 * 1024 * 1024, // 4MiB
- ListSize: 200,
-}
-
-// Config defines options to be used when opening an S3Storage,
-// mostly options for underlying S3 client library.
-type Config struct {
-
- // KeyPrefix allows specifying a
- // prefix applied to all S3 object
- // requests, e.g. allowing you to
- // partition a bucket by key prefix.
- KeyPrefix string
-
- // CoreOpts are S3 client options
- // passed during initialization.
- CoreOpts minio.Options
-
- // PutChunkSize is the chunk size (in bytes)
- // to use when sending a byte stream reader
- // of unknown size as a multi-part object.
- PutChunkSize int64
-
- // ListSize determines how many items
- // to include in each list request, made
- // during calls to .WalkKeys().
- ListSize int
-
- // Cache is an optional type that may be
- // provided to store simple entry information
- // to speed up Get() / Stat() operations.
- Cache EntryCache
-}
-
-// getS3Config returns valid (and owned!) Config for given ptr.
-func getS3Config(cfg *Config) Config {
- // See: https://docs.aws.amazon.com/AmazonS3/latest/userguide/qfacts.html
- const minChunkSz = 5 * 1024 * 1024
-
- if cfg == nil {
- // use defaults.
- return defaultConfig
- }
-
- // Ensure a minimum compat chunk size.
- if cfg.PutChunkSize <= minChunkSz {
- cfg.PutChunkSize = minChunkSz
- }
-
- // Ensure valid list size.
- if cfg.ListSize <= 0 {
- cfg.ListSize = 200
- }
-
- return Config{
- KeyPrefix: cfg.KeyPrefix,
- CoreOpts: cfg.CoreOpts,
- PutChunkSize: cfg.PutChunkSize,
- ListSize: cfg.ListSize,
- Cache: cfg.Cache,
- }
-}
-
-// S3Storage is a storage implementation that stores key-value
-// pairs in an S3 instance at given endpoint with bucket name.
-type S3Storage struct {
- client *minio.Core
- bucket string
- config Config
-}
-
-// Open opens a new S3Storage instance with given S3 endpoint URL, bucket name and configuration.
-func Open(endpoint string, bucket string, cfg *Config) (*S3Storage, error) {
- ctx := context.Background()
-
- // Check/set config defaults.
- config := getS3Config(cfg)
-
- // Validate configured key prefix (if any), handles case of an empty string.
- if err := s3utils.CheckValidObjectNamePrefix(config.KeyPrefix); err != nil {
- return nil, err
- }
-
- // Create new S3 client connection to given endpoint.
- client, err := minio.NewCore(endpoint, &config.CoreOpts)
- if err != nil {
- return nil, err
- }
-
- // Check that provided bucket actually exists.
- exists, err := client.BucketExists(ctx, bucket)
- if err != nil {
- return nil, err
- } else if !exists {
- return nil, errors.New("storage/s3: bucket does not exist")
- }
-
- return &S3Storage{
- client: client,
- bucket: bucket,
- config: config,
- }, nil
-}
-
-// Client: returns access to the underlying S3 client.
-func (st *S3Storage) Client() *minio.Core {
- return st.client
-}
-
-// Clean: implements Storage.Clean().
-func (st *S3Storage) Clean(ctx context.Context) error {
- return nil // nothing to do for S3
-}
-
-// ReadBytes: implements Storage.ReadBytes().
-func (st *S3Storage) ReadBytes(ctx context.Context, key string) ([]byte, error) {
-
- // Get stream reader for key.
- rc, err := st.ReadStream(ctx, key)
- if err != nil {
- return nil, err
- }
-
- // Read all data to memory.
- data, err := io.ReadAll(rc)
- if err != nil {
- _ = rc.Close()
- return nil, err
- }
-
- // Close storage stream reader.
- if err := rc.Close(); err != nil {
- return nil, err
- }
-
- return data, nil
-}
-
-// ReadStream: implements Storage.ReadStream().
-func (st *S3Storage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error) {
- rc, _, _, err := st.GetObject(ctx, key, minio.GetObjectOptions{})
- return rc, err
-}
-
-// GetObject wraps minio.Core{}.GetObject() to handle wrapping with our own storage library error types.
-func (st *S3Storage) GetObject(ctx context.Context, key string, opts minio.GetObjectOptions) (io.ReadCloser, minio.ObjectInfo, http.Header, error) {
-
- // Update given key with prefix.
- key = st.config.KeyPrefix + key
-
- // Check cache for possible known response.
- cinfo, ok := cacheGet(st.config.Cache, key)
- switch {
- case !ok:
- break
- case cinfo == nil:
- return nil, minio.ObjectInfo{}, nil, cachedNotFoundError(key)
- }
-
- // Query bucket for object data and info.
- rc, info, hdr, err := st.client.GetObject(
- ctx,
- st.bucket,
- key,
- opts,
- )
- if err != nil {
-
- if isNotFoundError(err) {
- // On 'not found', cache this resp.
- cacheNotFound(st.config.Cache, key)
-
- // Wrap not found errors as our not found type.
- err = internal.WrapErr(err, storage.ErrNotFound)
- } else if isObjectNameError(err) {
- // Wrap object name errors as our invalid key type.
- err = internal.WrapErr(err, storage.ErrInvalidKey)
- }
-
- } else {
-
- // On success, cache fetched obj info.
- cacheObject(st.config.Cache, key, info)
- }
-
- return rc, info, hdr, err
-}
-
-// WriteBytes: implements Storage.WriteBytes().
-func (st *S3Storage) WriteBytes(ctx context.Context, key string, value []byte) (int, error) {
- info, err := st.PutObject(ctx, key, bytes.NewReader(value), minio.PutObjectOptions{})
- return int(info.Size), err
-}
-
-// WriteStream: implements Storage.WriteStream().
-func (st *S3Storage) WriteStream(ctx context.Context, key string, r io.Reader) (int64, error) {
- info, err := st.PutObject(ctx, key, r, minio.PutObjectOptions{})
- return info.Size, err
-}
-
-// PutObject wraps minio.Core{}.PutObject() to handle wrapping with our own storage library error types, and in the case of an io.Reader
-// that does not implement ReaderSize{}, it will instead handle upload by using minio.Core{}.NewMultipartUpload() in chunks of PutChunkSize.
-func (st *S3Storage) PutObject(ctx context.Context, key string, r io.Reader, opts minio.PutObjectOptions) (minio.UploadInfo, error) {
-
- // Update given key with prefix.
- key = st.config.KeyPrefix + key
-
- if rs, ok := r.(ReaderSize); ok {
- // This reader supports providing us the size of
- // the encompassed data, allowing us to perform
- // a singular .PutObject() call with length.
- info, err := st.client.PutObject(
- ctx,
- st.bucket,
- key,
- r,
- rs.Size(),
- "",
- "",
- opts,
- )
- if err != nil {
-
- if isConflictError(err) {
- // Wrap conflict errors as our already exists type.
- err = internal.WrapErr(err, storage.ErrAlreadyExists)
- } else if isObjectNameError(err) {
- // Wrap object name errors as our invalid key type.
- err = internal.WrapErr(err, storage.ErrInvalidKey)
- }
-
- } else {
-
- // On success, cache uploaded object info.
- cacheUpload(st.config.Cache, key, info, opts)
- }
-
- return info, err
- }
-
- // Start a new multipart upload to get ID.
- uploadID, err := st.client.NewMultipartUpload(
- ctx,
- st.bucket,
- key,
- opts,
- )
- if err != nil {
-
- if isConflictError(err) {
- // Wrap conflict errors as our already exists type.
- err = internal.WrapErr(err, storage.ErrAlreadyExists)
- } else if isObjectNameError(err) {
- // Wrap object name errors as our invalid key type.
- err = internal.WrapErr(err, storage.ErrInvalidKey)
- }
-
- return minio.UploadInfo{}, err
- }
-
- var (
- total = int64(0)
- index = int(1) // parts index
- parts []minio.CompletePart
- chunk = make([]byte, st.config.PutChunkSize)
- rbuf = bytes.NewReader(nil)
- )
-
- // Note that we do not perform any kind of
- // memory pooling of the chunk buffers here.
- // Optimal chunking sizes for S3 writes are in
- // the orders of megabytes, so letting the GC
- // collect these ASAP is much preferred.
-
-loop:
- for done := false; !done; {
- // Read next chunk into byte buffer.
- n, err := io.ReadFull(r, chunk)
-
- switch err {
- // Successful read.
- case nil:
-
- // Reached end, buffer empty.
- case io.EOF:
- break loop
-
- // Reached end, but buffer not empty.
- case io.ErrUnexpectedEOF:
- done = true
-
- // All other errors.
- default:
- return minio.UploadInfo{}, err
- }
-
- // Reset byte reader.
- rbuf.Reset(chunk[:n])
-
- // Put this object chunk in S3 store.
- pt, err := st.client.PutObjectPart(
- ctx,
- st.bucket,
- key,
- uploadID,
- index,
- rbuf,
- int64(n),
- minio.PutObjectPartOptions{
- SSE: opts.ServerSideEncryption,
- DisableContentSha256: opts.DisableContentSha256,
- },
- )
- if err != nil {
- return minio.UploadInfo{}, err
- }
-
- // Append completed part to slice.
- parts = append(parts, minio.CompletePart{
- PartNumber: pt.PartNumber,
- ETag: pt.ETag,
- ChecksumCRC32: pt.ChecksumCRC32,
- ChecksumCRC32C: pt.ChecksumCRC32C,
- ChecksumSHA1: pt.ChecksumSHA1,
- ChecksumSHA256: pt.ChecksumSHA256,
- })
-
- // Update total.
- total += int64(n)
-
- // Iterate.
- index++
- }
-
- // Complete this multi-part upload operation
- info, err := st.client.CompleteMultipartUpload(
- ctx,
- st.bucket,
- key,
- uploadID,
- parts,
- opts,
- )
- if err != nil {
- return minio.UploadInfo{}, err
- }
-
- // Set correct size.
- info.Size = total
-
- // On success, cache uploaded object info.
- cacheUpload(st.config.Cache, key, info, opts)
-
- return info, nil
-}
-
-// Stat: implements Storage.Stat().
-func (st *S3Storage) Stat(ctx context.Context, key string) (*storage.Entry, error) {
- info, err := st.StatObject(ctx, key, minio.StatObjectOptions{})
- if err != nil {
- if errors.Is(err, storage.ErrNotFound) {
- err = nil // mask not-found errors
- }
- return nil, err
- }
- return &storage.Entry{
- Key: key,
- Size: info.Size,
- }, nil
-}
-
-// StatObject wraps minio.Core{}.StatObject() to handle wrapping with our own storage library error types.
-func (st *S3Storage) StatObject(ctx context.Context, key string, opts minio.StatObjectOptions) (minio.ObjectInfo, error) {
-
- // Update given key with prefix.
- key = st.config.KeyPrefix + key
-
- // Check cache for possible known response.
- cinfo, ok := cacheGet(st.config.Cache, key)
- switch {
- case !ok:
- break
- case cinfo == nil:
- return minio.ObjectInfo{}, cachedNotFoundError(key)
- default:
- return cinfo.ToObjectInfo(), nil
- }
-
- // Query bucket for object info.
- info, err := st.client.StatObject(
- ctx,
- st.bucket,
- key,
- opts,
- )
- if err != nil {
-
- if isNotFoundError(err) {
- // On 'not found', cache this resp.
- cacheNotFound(st.config.Cache, key)
-
- // Wrap not found errors as our not found type.
- err = internal.WrapErr(err, storage.ErrNotFound)
- } else if isObjectNameError(err) {
- // Wrap object name errors as our invalid key type.
- err = internal.WrapErr(err, storage.ErrInvalidKey)
- }
-
- } else {
-
- // On success, cache fetchedd obj info.
- cacheObject(st.config.Cache, key, info)
- }
-
- return info, err
-}
-
-// Remove: implements Storage.Remove().
-func (st *S3Storage) Remove(ctx context.Context, key string) error {
- _, err := st.StatObject(ctx, key, minio.StatObjectOptions{})
- if err != nil {
- return err
- }
- return st.RemoveObject(ctx, key, minio.RemoveObjectOptions{})
-}
-
-// RemoveObject wraps minio.Core{}.RemoveObject() to handle wrapping with our own storage library error types.
-func (st *S3Storage) RemoveObject(ctx context.Context, key string, opts minio.RemoveObjectOptions) error {
-
- // Update given key with prefix.
- key = st.config.KeyPrefix + key
-
- // Check cache for possible known response.
- cinfo, ok := cacheGet(st.config.Cache, key)
- switch {
- case !ok:
- break
- case cinfo == nil:
- return cachedNotFoundError(key)
- }
-
- // Remove object from S3 bucket
- err := st.client.RemoveObject(
- ctx,
- st.bucket,
- key,
- opts,
- )
-
- if err != nil {
-
- if isNotFoundError(err) {
- // On 'not found', cache this resp.
- cacheNotFound(st.config.Cache, key)
-
- // Wrap not found errors as our not found type.
- err = internal.WrapErr(err, storage.ErrNotFound)
- } else if isObjectNameError(err) {
- // Wrap object name errors as our invalid key type.
- err = internal.WrapErr(err, storage.ErrInvalidKey)
- }
-
- } else {
-
- // Removed! also cache as 'not found'.
- cacheNotFound(st.config.Cache, key)
- }
-
- return err
-}
-
-// WalkKeys: implements Storage.WalkKeys().
-func (st *S3Storage) WalkKeys(ctx context.Context, opts storage.WalkKeysOpts) error {
- if opts.Step == nil {
- panic("nil step fn")
- }
-
- // Step function called on each listed object.
- var step func(string, minio.ObjectInfo) error
-
- if st.config.Cache == nil {
- // No cache, simply pass straight through to opts.Step().
- step = func(key string, info minio.ObjectInfo) error {
- return opts.Step(storage.Entry{
- Key: key,
- Size: info.Size,
- })
- }
- } else {
- // Cache configured, store before passing to opts.Step().
- step = func(key string, info minio.ObjectInfo) error {
- st.config.Cache.Put(key, objectToCachedObjectInfo(info))
- return opts.Step(storage.Entry{
- Key: key,
- Size: info.Size,
- })
- }
- }
-
- // Update options prefix to include global prefix.
- opts.Prefix = st.config.KeyPrefix + opts.Prefix
-
- for prev, token := "", ""; ; {
- // List objects in bucket starting at marker.
- result, err := st.client.ListObjectsV2(
- st.bucket,
- opts.Prefix,
- prev,
- token,
- "",
- st.config.ListSize,
- )
- if err != nil {
- return err
- }
-
- // Iterate through list contents.
- //
- // Use different loops depending
- // on if filter func was provided,
- // to reduce loop operations.
- if opts.Filter != nil {
- for _, obj := range result.Contents {
- // Trim any global prefix from returned object key.
- key := strings.TrimPrefix(obj.Key, st.config.KeyPrefix)
-
- // Skip filtered keys.
- if opts.Filter(key) {
- continue
- }
-
- // Pass each object to step funcion.
- if err := step(key, obj); err != nil {
- return err
- }
- }
- } else {
- for _, obj := range result.Contents {
- // Trim any global prefix from returned object key.
- key := strings.TrimPrefix(obj.Key, st.config.KeyPrefix)
-
- // Pass each object to step funcion.
- if err := step(key, obj); err != nil {
- return err
- }
- }
- }
-
- // No token means we reached end of bucket.
- if result.NextContinuationToken == "" {
- return nil
- }
-
- // Set continue token and prev mark
- token = result.NextContinuationToken
- prev = result.StartAfter
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/storage.go b/vendor/codeberg.org/gruf/go-storage/storage.go
deleted file mode 100644
index b13f2d387..000000000
--- a/vendor/codeberg.org/gruf/go-storage/storage.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package storage
-
-import (
- "context"
- "io"
-)
-
-// Storage defines a means of accessing and storing
-// data to some abstracted underlying mechanism. Whether
-// that be in-memory, an on-disk filesystem or S3 bucket.
-type Storage interface {
-
- // ReadBytes returns the data located at key (e.g. filepath) in storage.
- ReadBytes(ctx context.Context, key string) ([]byte, error)
-
- // ReadStream returns an io.ReadCloser for the data at key (e.g. filepath) in storage.
- ReadStream(ctx context.Context, key string) (io.ReadCloser, error)
-
- // WriteBytes writes the supplied data at key (e.g. filepath) in storage.
- WriteBytes(ctx context.Context, key string, data []byte) (int, error)
-
- // WriteStream writes the supplied data stream at key (e.g. filepath) in storage.
- WriteStream(ctx context.Context, key string, stream io.Reader) (int64, error)
-
- // Stat returns details about key (e.g. filepath) in storage, nil indicates not found.
- Stat(ctx context.Context, key string) (*Entry, error)
-
- // Remove will remove data at key from storage.
- Remove(ctx context.Context, key string) error
-
- // Clean in simple terms performs a clean of underlying
- // storage mechanism. For memory implementations this may
- // compact the underlying hashmap, for disk filesystems
- // this may remove now-unused directories.
- Clean(ctx context.Context) error
-
- // WalkKeys walks available keys using opts in storage.
- WalkKeys(ctx context.Context, opts WalkKeysOpts) error
-}
-
-// Entry represents a key in a Storage{} implementation,
-// with any associated metadata that may have been set.
-type Entry struct {
-
- // Key is this entry's
- // unique storage key.
- Key string
-
- // Size is the size of
- // this entry in storage.
- Size int64
-}
-
-// WalkKeysOpts are arguments provided
-// to a storage WalkKeys() implementation.
-type WalkKeysOpts struct {
-
- // Prefix can be used to filter entries
- // by the given key prefix, for example
- // only those under a subdirectory. This
- // is preferred over Filter() function.
- Prefix string
-
- // Filter can be used to filter entries
- // by any custom metric before before they
- // are passed to Step() function. E.g.
- // filter storage entries by regexp.
- Filter func(string) bool
-
- // Step is called for each entry during
- // WalkKeys, error triggers early return.
- Step func(Entry) error
-}
diff --git a/vendor/codeberg.org/gruf/go-storage/test.sh b/vendor/codeberg.org/gruf/go-storage/test.sh
deleted file mode 100644
index 6eb18fa65..000000000
--- a/vendor/codeberg.org/gruf/go-storage/test.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-export \
- MINIO_ADDR='127.0.0.1:8080' \
- MINIO_BUCKET='test' \
- MINIO_ROOT_USER='root' \
- MINIO_ROOT_PASSWORD='password' \
- MINIO_PID=0 \
- S3_DIR=$(mktemp -d)
-
-# Drop the test S3 bucket and kill minio on exit
-trap 'rm -rf "$S3_DIR"; [ $MINIO_PID -ne 0 ] && kill -9 $MINIO_PID' EXIT
-
-# Create required S3 bucket dir
-mkdir -p "${S3_DIR}/${MINIO_BUCKET}"
-
-# Start the minio test S3 server instance
-minio server --address "$MINIO_ADDR" "$S3_DIR" & > /dev/null 2>&1
-MINIO_PID=$!; [ $? -ne 0 ] && {
- echo 'failed to start minio'
- exit 1
-}
-
-# Let server startup
-sleep 1
-
-# Run go-store tests
-go test ./... -v \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-structr/LICENSE b/vendor/codeberg.org/gruf/go-structr/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-structr/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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-structr/README.md b/vendor/codeberg.org/gruf/go-structr/README.md
deleted file mode 100644
index 2ea88faef..000000000
--- a/vendor/codeberg.org/gruf/go-structr/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# go-structr
-
-A library with a series of performant data types with automated struct value indexing. Indexing is supported via arbitrary combinations of fields, and in the case of the cache type, negative results (errors!) are also supported.
-
-Under the hood, go-structr maintains a hashmap per index, where each hashmap is keyed by serialized input key. This is handled by the incredibly performant serialization library [go-mangler/v2](https://codeberg.org/gruf/go-mangler), which at this point in time supports all concrete types, so feel free to index by by *almost* anything!
-
-See the [docs](https://pkg.go.dev/codeberg.org/gruf/go-structr) for more API information.
-
-## Notes
-
-This is a core underpinning of [GoToSocial](https://github.com/superseriousbusiness/gotosocial)'s performance. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-structr/cache.go b/vendor/codeberg.org/gruf/go-structr/cache.go
deleted file mode 100644
index 6ae6ff3ed..000000000
--- a/vendor/codeberg.org/gruf/go-structr/cache.go
+++ /dev/null
@@ -1,724 +0,0 @@
-package structr
-
-import (
- "context"
- "errors"
- "sync"
- "unsafe"
-)
-
-// DefaultIgnoreErr is the default function used to
-// ignore (i.e. not cache) incoming error results during
-// Load() calls. By default ignores context pkg errors.
-func DefaultIgnoreErr(err error) bool {
- return errors.Is(err, context.Canceled) ||
- errors.Is(err, context.DeadlineExceeded)
-}
-
-// CacheConfig defines config vars
-// for initializing a Cache{} type.
-type CacheConfig[StructType any] struct {
-
- // IgnoreErr defines which errors to
- // ignore (i.e. not cache) returned
- // from load function callback calls.
- // This may be left as nil, on which
- // DefaultIgnoreErr will be used.
- IgnoreErr func(error) bool
-
- // Copy provides a means of copying
- // cached values, to ensure returned values
- // do not share memory with those in cache.
- Copy func(StructType) StructType
-
- // Invalidate is called when cache values
- // (NOT errors) are invalidated, either
- // as the values passed to Put() / Store(),
- // or by the keys by calls to Invalidate().
- Invalidate func(StructType)
-
- // Indices defines indices to create
- // in the Cache for the receiving
- // generic struct type parameter.
- Indices []IndexConfig
-
- // MaxSize defines the maximum number
- // of items allowed in the Cache at
- // one time, before old items start
- // getting evicted.
- MaxSize int
-}
-
-// Cache provides a structure cache with automated
-// indexing and lookups by any initialization-defined
-// combination of fields. This also supports caching
-// of negative results (errors!) returned by LoadOne().
-type Cache[StructType any] struct {
-
- // hook functions.
- ignore func(error) bool
- copy func(StructType) StructType
- invalid func(StructType)
-
- // keeps track of all indexed items,
- // in order of last recently used (LRU).
- lru list
-
- // indices used in storing passed struct
- // types by user defined sets of fields.
- indices []Index
-
- // max cache size, imposes size
- // limit on the lru list in order
- // to evict old entries.
- maxSize int
-
- // protective mutex, guards:
- // - Cache{}.*
- // - Index{}.data
- mutex sync.Mutex
-}
-
-// Init initializes the cache with given configuration
-// including struct fields to index, and necessary fns.
-func (c *Cache[T]) Init(config CacheConfig[T]) {
- t := get_type_iter[T]()
-
- if len(config.Indices) == 0 {
- panic("no indices provided")
- }
-
- if config.IgnoreErr == nil {
- config.IgnoreErr = DefaultIgnoreErr
- }
-
- if config.Copy == nil {
- panic("copy function must be provided")
- }
-
- if config.MaxSize < 2 {
- panic("minimum cache size is 2 for LRU to work")
- }
-
- // Safely copy over
- // provided config.
- c.mutex.Lock()
- defer c.mutex.Unlock()
- c.indices = make([]Index, len(config.Indices))
- for i, cfg := range config.Indices {
- c.indices[i].ptr = unsafe.Pointer(c)
- c.indices[i].init(t, cfg, config.MaxSize)
- }
- c.ignore = config.IgnoreErr
- c.copy = config.Copy
- c.invalid = config.Invalidate
- c.maxSize = config.MaxSize
-}
-
-// Index selects index with given name from cache, else panics.
-func (c *Cache[T]) Index(name string) *Index {
- for i, idx := range c.indices {
- if idx.name == name {
- return &(c.indices[i])
- }
- }
- panic("unknown index: " + name)
-}
-
-// GetOne fetches value from cache stored under index, using precalculated index key.
-func (c *Cache[T]) GetOne(index *Index, key Key) (T, bool) {
- values := c.Get(index, key)
- if len(values) == 0 {
- var zero T
- return zero, false
- }
- return values[0], true
-}
-
-// Get fetches values from the cache stored under index, using precalculated index keys.
-func (c *Cache[T]) Get(index *Index, keys ...Key) []T {
- if index == nil {
- panic("no index given")
- } else if index.ptr != unsafe.Pointer(c) {
- panic("invalid index for cache")
- }
-
- // Preallocate expected ret slice.
- values := make([]T, 0, len(keys))
-
- // Acquire lock.
- c.mutex.Lock()
- defer c.mutex.Unlock()
-
- // Check cache init.
- if c.copy == nil {
- panic("not initialized")
- }
-
- for i := range keys {
- // Concatenate all *values* from cached items.
- index.get(keys[i].key, func(item *indexed_item) {
- if value, ok := item.data.(T); ok {
-
- // Append value COPY.
- value = c.copy(value)
- values = append(values, value)
-
- // Push to front of LRU list, USING
- // THE ITEM'S LRU ENTRY, NOT THE
- // INDEX KEY ENTRY. VERY IMPORTANT!!
- c.lru.move_front(&item.elem)
- }
- })
- }
-
- return values
-}
-
-// Put will insert the given values into cache,
-// calling any invalidate hook on each value.
-func (c *Cache[T]) Put(values ...T) {
- // Acquire lock.
- c.mutex.Lock()
-
- // Ensure mutex
- // gets unlocked.
- var unlocked bool
- defer func() {
- if !unlocked {
- c.mutex.Unlock()
- }
- }()
-
- // Check cache init.
- if c.copy == nil {
- panic("not initialized")
- }
-
- // Store all passed values.
- for i := range values {
- c.store_value(
- nil, "",
- values[i],
- )
- }
-
- // Get func ptrs.
- invalid := c.invalid
-
- // Done with lock.
- c.mutex.Unlock()
- unlocked = true
-
- if invalid != nil {
- // Pass all invalidated values
- // to given user hook (if set).
- for _, value := range values {
- invalid(value)
- }
- }
-}
-
-// LoadOneBy fetches one result from the cache stored under index, using precalculated index key.
-// In the case that no result is found, provided load callback will be used to hydrate the cache.
-func (c *Cache[T]) LoadOne(index *Index, key Key, load func() (T, error)) (T, error) {
- if index == nil {
- panic("no index given")
- } else if index.ptr != unsafe.Pointer(c) {
- panic("invalid index for cache")
- } else if !is_unique(index.flags) {
- panic("cannot get one by non-unique index")
- }
-
- var (
- // whether an item was found
- // (and so val / err are set).
- ok bool
-
- // separate value / error ptrs
- // as the item is liable to
- // change outside of lock.
- val T
- err error
- )
-
- // Acquire lock.
- c.mutex.Lock()
-
- // Ensure mutex
- // gets unlocked.
- var unlocked bool
- defer func() {
- if !unlocked {
- c.mutex.Unlock()
- }
- }()
-
- // Check init'd.
- if c.copy == nil ||
- c.ignore == nil {
- panic("not initialized")
- }
-
- // Get item indexed at key.
- item := index.get_one(key)
-
- if ok = (item != nil); ok {
- var is bool
-
- if val, is = item.data.(T); is {
- // Set value COPY.
- val = c.copy(val)
-
- // Push to front of LRU list, USING
- // THE ITEM'S LRU ENTRY, NOT THE
- // INDEX KEY ENTRY. VERY IMPORTANT!!
- c.lru.move_front(&item.elem)
-
- } else {
-
- // Attempt to return error.
- err, _ = item.data.(error)
- }
- }
-
- // Get func ptrs.
- ignore := c.ignore
-
- // Done with lock.
- c.mutex.Unlock()
- unlocked = true
-
- if ok {
- // item found!
- return val, err
- }
-
- // Load new result.
- val, err = load()
-
- // Check for ignored error types.
- if err != nil && ignore(err) {
- return val, err
- }
-
- // Acquire lock.
- c.mutex.Lock()
- unlocked = false
-
- // Index this new loaded item.
- // Note this handles copying of
- // the provided value, so it is
- // safe for us to return as-is.
- if err != nil {
- c.store_error(index, key.key, err)
- } else {
- c.store_value(index, key.key, val)
- }
-
- // Done with lock.
- c.mutex.Unlock()
- unlocked = true
-
- return val, err
-}
-
-// Load fetches values from the cache stored under index, using precalculated index keys. The cache will attempt to
-// results with values stored under keys, passing keys with uncached results to the provider load callback to further
-// hydrate the cache with missing results. Cached error results not included or returned by this function.
-func (c *Cache[T]) Load(index *Index, keys []Key, load func([]Key) ([]T, error)) ([]T, error) {
- if index == nil {
- panic("no index given")
- } else if index.ptr != unsafe.Pointer(c) {
- panic("invalid index for cache")
- }
-
- // Preallocate expected ret slice.
- values := make([]T, 0, len(keys))
-
- // Acquire lock.
- c.mutex.Lock()
-
- // Ensure mutex
- // gets unlocked.
- var unlocked bool
- defer func() {
- if !unlocked {
- c.mutex.Unlock()
- }
- }()
-
- // Check init'd.
- if c.copy == nil {
- panic("not initialized")
- }
-
- // Iterate keys and catch uncached.
- toLoad := make([]Key, 0, len(keys))
- for _, key := range keys {
-
- // Value length before
- // any below appends.
- before := len(values)
-
- // Concatenate all *values* from cached items.
- index.get(key.key, func(item *indexed_item) {
- if value, ok := item.data.(T); ok {
- // Append value COPY.
- value = c.copy(value)
- values = append(values, value)
-
- // Push to front of LRU list, USING
- // THE ITEM'S LRU ENTRY, NOT THE
- // INDEX KEY ENTRY. VERY IMPORTANT!!
- c.lru.move_front(&item.elem)
- }
- })
-
- // Only if values changed did
- // we actually find anything.
- if len(values) == before {
- toLoad = append(toLoad, key)
- }
- }
-
- // Done with lock.
- c.mutex.Unlock()
- unlocked = true
-
- if len(toLoad) == 0 {
- // We loaded everything!
- return values, nil
- }
-
- // Load uncached key values.
- uncached, err := load(toLoad)
- if err != nil {
- return nil, err
- }
-
- // Acquire lock.
- c.mutex.Lock()
- unlocked = false
-
- // Store all uncached values.
- for i := range uncached {
- c.store_value(
- nil, "",
- uncached[i],
- )
- }
-
- // Done with lock.
- c.mutex.Unlock()
- unlocked = true
-
- // Append uncached to return values.
- values = append(values, uncached...)
-
- return values, nil
-}
-
-// Store will call the given store callback, on non-error then
-// passing the provided value to the Put() function. On error
-// return the value is still passed to stored invalidate hook.
-func (c *Cache[T]) Store(value T, store func() error) error {
- // Store value.
- err := store()
- if err != nil {
-
- // Get func ptrs.
- c.mutex.Lock()
- invalid := c.invalid
- c.mutex.Unlock()
-
- // On error don't store
- // value, but still pass
- // to invalidate hook.
- if invalid != nil {
- invalid(value)
- }
-
- return err
- }
-
- // Store value.
- c.Put(value)
-
- return nil
-}
-
-// Invalidate invalidates all results stored under index keys.
-// Note that if set, this will call the invalidate hook on each.
-func (c *Cache[T]) Invalidate(index *Index, keys ...Key) {
- if index == nil {
- panic("no index given")
- } else if index.ptr != unsafe.Pointer(c) {
- panic("invalid index for cache")
- }
-
- // Acquire lock.
- c.mutex.Lock()
-
- // Preallocate expected ret slice.
- values := make([]T, 0, len(keys))
-
- for i := range keys {
- // Delete all items under key from index, collecting
- // value items and dropping them from all their indices.
- index.delete(keys[i].key, func(item *indexed_item) {
-
- if value, ok := item.data.(T); ok {
- // No need to copy, as item
- // being deleted from cache.
- values = append(values, value)
- }
-
- // Delete item.
- c.delete(item)
- })
- }
-
- // Get func ptrs.
- invalid := c.invalid
-
- // Done with lock.
- c.mutex.Unlock()
-
- if invalid != nil {
- // Pass all invalidated values
- // to given user hook (if set).
- for _, value := range values {
- invalid(value)
- }
- }
-}
-
-// Trim will truncate the cache to ensure it
-// stays within given percentage of MaxSize.
-func (c *Cache[T]) Trim(perc float64) {
-
- // Acquire lock.
- c.mutex.Lock()
-
- // Calculate number of cache items to drop.
- max := (perc / 100) * float64(c.maxSize)
- diff := c.lru.len - int(max)
- if diff <= 0 {
-
- // Trim not needed.
- c.mutex.Unlock()
- return
- }
-
- // Iterate over 'diff' items
- // from back (oldest) of cache.
- for i := 0; i < diff; i++ {
-
- // Get oldest LRU elem.
- oldest := c.lru.tail
- if oldest == nil {
-
- // reached
- // end.
- break
- }
-
- // Drop oldest item from cache.
- item := (*indexed_item)(oldest.data)
- c.delete(item)
- }
-
- // Compact index data stores.
- for _, idx := range c.indices {
- (&idx).data.Compact()
- }
-
- // Done with lock.
- c.mutex.Unlock()
-}
-
-// Clear empties the cache by calling .Trim(0).
-func (c *Cache[T]) Clear() { c.Trim(0) }
-
-// Len returns the current length of cache.
-func (c *Cache[T]) Len() int {
- c.mutex.Lock()
- l := c.lru.len
- c.mutex.Unlock()
- return l
-}
-
-// Debug returns debug stats about cache.
-func (c *Cache[T]) Debug() map[string]any {
- m := make(map[string]any, 2)
- c.mutex.Lock()
- m["lru"] = c.lru.len
- indices := make(map[string]any, len(c.indices))
- m["indices"] = indices
- for _, idx := range c.indices {
- var n uint64
- for _, l := range idx.data.m {
- n += uint64(l.len)
- }
- indices[idx.name] = n
- }
- c.mutex.Unlock()
- return m
-}
-
-// Cap returns the maximum capacity (size) of cache.
-func (c *Cache[T]) Cap() int {
- c.mutex.Lock()
- m := c.maxSize
- c.mutex.Unlock()
- return m
-}
-
-func (c *Cache[T]) store_value(index *Index, key string, value T) {
- // Alloc new index item.
- item := new_indexed_item()
- if cap(item.indexed) < len(c.indices) {
-
- // Preallocate item indices slice to prevent Go auto
- // allocating overlying large slices we don't need.
- item.indexed = make([]*index_entry, 0, len(c.indices))
- }
-
- // Create COPY of value.
- value = c.copy(value)
- item.data = value
-
- if index != nil {
- // Append item to index a key
- // was already generated for.
- evicted := index.append(key, item)
- if evicted != nil {
-
- // This item is no longer
- // indexed, remove from list.
- c.lru.remove(&evicted.elem)
- free_indexed_item(evicted)
- }
- }
-
- // Get ptr to value data.
- ptr := unsafe.Pointer(&value)
-
- // Acquire key buf.
- buf := new_buffer()
-
- for i := range c.indices {
- // Get current index ptr.
- idx := (&c.indices[i])
- if idx == index {
-
- // Already stored under
- // this index, ignore.
- continue
- }
-
- // Extract fields comprising index key.
- parts := extract_fields(ptr, idx.fields)
-
- // Calculate index key.
- key := idx.key(buf, parts)
- if key == "" {
- continue
- }
-
- // Append item to this index.
- evicted := idx.append(key, item)
- if evicted != nil {
-
- // This item is no longer
- // indexed, remove from list.
- c.lru.remove(&evicted.elem)
- free_indexed_item(evicted)
- }
- }
-
- // Done with buf.
- free_buffer(buf)
-
- if len(item.indexed) == 0 {
- // Item was not stored under
- // any index. Drop this item.
- free_indexed_item(item)
- return
- }
-
- // Add item to main lru list.
- c.lru.push_front(&item.elem)
-
- if c.lru.len > c.maxSize {
- // Cache has hit max size!
- // Drop the oldest element.
- ptr := c.lru.tail.data
- item := (*indexed_item)(ptr)
- c.delete(item)
- }
-}
-
-func (c *Cache[T]) store_error(index *Index, key string, err error) {
- if index == nil {
- // nothing we
- // can do here.
- return
- }
-
- // Alloc new index item.
- item := new_indexed_item()
- if cap(item.indexed) < len(c.indices) {
-
- // Preallocate item indices slice to prevent Go auto
- // allocating overlying large slices we don't need.
- item.indexed = make([]*index_entry, 0, len(c.indices))
- }
-
- // Set error val.
- item.data = err
-
- // Append item to index a key
- // was already generated for.
- evicted := index.append(key, item)
- if evicted != nil {
-
- // This item is no longer
- // indexed, remove from list.
- c.lru.remove(&evicted.elem)
- free_indexed_item(evicted)
- }
-
- // Add item to main lru list.
- c.lru.push_front(&item.elem)
-
- if c.lru.len > c.maxSize {
- // Cache has hit max size!
- // Drop the oldest element.
- ptr := c.lru.tail.data
- item := (*indexed_item)(ptr)
- c.delete(item)
- }
-}
-
-func (c *Cache[T]) delete(i *indexed_item) {
- for len(i.indexed) > 0 {
- // Pop last indexed entry from list.
- entry := i.indexed[len(i.indexed)-1]
- i.indexed[len(i.indexed)-1] = nil
- i.indexed = i.indexed[:len(i.indexed)-1]
-
- // Get entry's index.
- index := entry.index
-
- // Drop this index_entry.
- index.delete_entry(entry)
- }
-
- // Drop from lru list.
- c.lru.remove(&i.elem)
-
- // Free unused item.
- free_indexed_item(i)
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/index.go b/vendor/codeberg.org/gruf/go-structr/index.go
deleted file mode 100644
index d8469577d..000000000
--- a/vendor/codeberg.org/gruf/go-structr/index.go
+++ /dev/null
@@ -1,419 +0,0 @@
-package structr
-
-import (
- "os"
- "reflect"
- "strings"
- "unsafe"
-
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-mempool"
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// IndexConfig defines config variables
-// for initializing a struct index.
-type IndexConfig struct {
-
- // Fields should contain a comma-separated
- // list of struct fields used when generating
- // keys for this index. Nested fields should
- // be specified using periods. An example:
- // "Username,Favorites.Color"
- //
- // If a nested field encounters a nil pointer
- // along the way, e.g. "Favourites == nil", then
- // a zero value for "Favorites.Color" is used.
- //
- // Field types supported include any of those
- // supported by the `go-mangler/v2` library.
- Fields string
-
- // Multiple indicates whether to accept multiple
- // possible values for any single index key. The
- // default behaviour is to only accept one value
- // and overwrite existing on any write operation.
- Multiple bool
-
- // AllowZero indicates whether to accept zero
- // value fields in index keys. i.e. whether to
- // index structs for this set of field values
- // IF any one of those field values is the zero
- // value for that type. The default behaviour
- // is to skip indexing structs for this lookup
- // when any of the indexing fields are zero.
- AllowZero bool
-}
-
-// Index is an exposed Cache internal model, used to
-// extract struct keys, generate hash checksums for them
-// and store struct results by the init defined config.
-// This model is exposed to provide faster lookups in the
-// case that you would like to manually provide the used
-// index via the Cache.___By() series of functions, or
-// access the underlying index key generator.
-type Index struct {
-
- // ptr is a pointer to
- // the source type this
- // index is attached to.
- ptr unsafe.Pointer
-
- // name is the actual name of this
- // index, which is the unparsed
- // string value of contained fields.
- name string
-
- // backing data store of the index, containing
- // list{}s of index_entry{}s which each contain
- // the exact key each result is stored under.
- data hashmap
-
- // struct fields encompassed
- // by keys of this index.
- fields []struct_field
-
- // index flags:
- // - 1 << 0 = unique
- // - 1 << 1 = allow zero
- flags uint8
-}
-
-// Name returns the receiving Index name.
-func (i *Index) Name() string {
- return i.name
-}
-
-// init will initialize the cache with given type, config and capacity.
-func (i *Index) init(t xunsafe.TypeIter, cfg IndexConfig, cap int) {
- switch {
- // The only 2 types we support are
- // structs, and ptrs to a struct.
- case t.Type.Kind() == reflect.Struct:
- case t.Type.Kind() == reflect.Pointer &&
- t.Type.Elem().Kind() == reflect.Struct:
- default:
- panic("index only support struct{} and *struct{}")
- }
-
- // Set name from the raw
- // struct fields string.
- i.name = cfg.Fields
-
- // Set struct flags.
- if cfg.AllowZero {
- set_allow_zero(&i.flags)
- }
- if !cfg.Multiple {
- set_is_unique(&i.flags)
- }
-
- // Split to get containing struct fields.
- fields := strings.Split(cfg.Fields, ",")
-
- // Preallocate expected struct field slice.
- i.fields = make([]struct_field, len(fields))
- for x, name := range fields {
-
- // Split name to account for nesting.
- names := strings.Split(name, ".")
-
- // Look for struct field by names.
- i.fields[x], _ = find_field(t, names)
- }
-
- // Initialize store for
- // index_entry lists.
- i.data.Init(cap)
-}
-
-// get_one will fetch one indexed item under key.
-func (i *Index) get_one(key Key) *indexed_item {
- // Get list at hash.
- l := i.data.Get(key.key)
- if l == nil {
- return nil
- }
-
- // Extract entry from first list elem.
- entry := (*index_entry)(l.head.data)
-
- return entry.item
-}
-
-// get will fetch all indexed items under key, passing each to hook.
-func (i *Index) get(key string, hook func(*indexed_item)) {
- if hook == nil {
- panic("nil hook")
- }
-
- // Get list at hash.
- l := i.data.Get(key)
- if l == nil {
- return
- }
-
- // Iterate the list.
- for elem := l.head; //
- elem != nil; //
- {
- // Get next before
- // any modification.
- next := elem.next
-
- // Extract element entry + item.
- entry := (*index_entry)(elem.data)
- item := entry.item
-
- // Pass to hook.
- hook(item)
-
- // Set next.
- elem = next
- }
-}
-
-// key ...
-func (i *Index) key(buf *byteutil.Buffer, parts []unsafe.Pointer) string {
- if len(parts) != len(i.fields) {
- panic(assert("len(parts) = len(i.fields)"))
- }
- buf.B = buf.B[:0]
- if !allow_zero(i.flags) {
- for x, field := range i.fields {
- before := len(buf.B)
- buf.B = field.mangle(buf.B, parts[x])
- if string(buf.B[before:]) == field.zerostr {
- return ""
- }
- buf.B = append(buf.B, '.')
- }
- } else {
- for x, field := range i.fields {
- buf.B = field.mangle(buf.B, parts[x])
- buf.B = append(buf.B, '.')
- }
- }
- return string(buf.B)
-}
-
-// add will attempt to add given index entry to appropriate
-// doubly-linked-list in index hashmap. in the case of an
-// existing entry in a "unique" index, it will return false.
-func (i *Index) add(key string, item *indexed_item) bool {
- // Look for existing.
- l := i.data.Get(key)
-
- if l == nil {
-
- // Allocate new.
- l = new_list()
- i.data.Put(key, l)
-
- } else if is_unique(i.flags) {
-
- // Collision!
- return false
- }
-
- // Prepare new index entry.
- entry := new_index_entry()
- entry.item = item
- entry.key = key
- entry.index = i
-
- // Add ourselves to item's index tracker.
- item.indexed = append(item.indexed, entry)
-
- // Add entry to index list.
- l.push_front(&entry.elem)
- return true
-}
-
-// append will append the given index entry to appropriate
-// doubly-linked-list in index hashmap. this handles case of
-// overwriting "unique" index entries, and removes from given
-// outer linked-list in the case that it is no longer indexed.
-func (i *Index) append(key string, item *indexed_item) (evicted *indexed_item) {
- // Look for existing.
- l := i.data.Get(key)
-
- if l == nil {
-
- // Allocate new.
- l = new_list()
- i.data.Put(key, l)
-
- } else if is_unique(i.flags) {
-
- // Remove head.
- elem := l.head
- l.remove(elem)
-
- // Drop index from inner item,
- // catching the evicted item.
- e := (*index_entry)(elem.data)
- evicted = e.item
- evicted.drop_index(e)
-
- // Free unused entry.
- free_index_entry(e)
-
- if len(evicted.indexed) != 0 {
- // Evicted is still stored
- // under index, don't return.
- evicted = nil
- }
- }
-
- // Prepare new index entry.
- entry := new_index_entry()
- entry.item = item
- entry.key = key
- entry.index = i
-
- // Add ourselves to item's index tracker.
- item.indexed = append(item.indexed, entry)
-
- // Add entry to index list.
- l.push_front(&entry.elem)
- return
-}
-
-// delete will remove all indexed items under key, passing each to hook.
-func (i *Index) delete(key string, hook func(*indexed_item)) {
- if hook == nil {
- panic("nil hook")
- }
-
- // Get list at hash.
- l := i.data.Get(key)
- if l == nil {
- return
- }
-
- // Delete at hash.
- i.data.Delete(key)
-
- // Iterate the list.
- for elem := l.head; //
- elem != nil; //
- {
- // Get next before
- // any modification.
- next := elem.next
-
- // Remove elem.
- l.remove(elem)
-
- // Extract element entry + item.
- entry := (*index_entry)(elem.data)
- item := entry.item
-
- // Drop index from item.
- item.drop_index(entry)
-
- // Free now-unused entry.
- free_index_entry(entry)
-
- // Pass to hook.
- hook(item)
-
- // Set next.
- elem = next
- }
-
- // Release list.
- free_list(l)
-}
-
-// delete_entry deletes the given index entry.
-func (i *Index) delete_entry(entry *index_entry) {
- // Get list at hash sum.
- l := i.data.Get(entry.key)
- if l == nil {
- return
- }
-
- // Remove list entry.
- l.remove(&entry.elem)
-
- if l.len == 0 {
- // Remove entry from map.
- i.data.Delete(entry.key)
-
- // Release list.
- free_list(l)
- }
-
- // Drop this index from item.
- entry.item.drop_index(entry)
-}
-
-// index_entry represents a single entry
-// in an Index{}, where it will be accessible
-// by .key pointing to a containing list{}.
-type index_entry struct {
-
- // list elem that entry is stored
- // within, under containing index.
- // elem.data is ptr to index_entry.
- elem list_elem
-
- // index this is stored in.
- index *Index
-
- // underlying indexed item.
- item *indexed_item
-
- // raw cache key
- // for this entry.
- key string
-}
-
-var index_entry_pool mempool.UnsafePool
-
-// new_index_entry returns a new prepared index_entry.
-func new_index_entry() *index_entry {
- if ptr := index_entry_pool.Get(); ptr != nil {
- return (*index_entry)(ptr)
- }
- entry := new(index_entry)
- entry.elem.data = unsafe.Pointer(entry)
- return entry
-}
-
-// free_index_entry releases the index_entry.
-func free_index_entry(entry *index_entry) {
- if entry.elem.next != nil ||
- entry.elem.prev != nil {
- msg := assert("entry not in use")
- os.Stderr.WriteString(msg + "\n")
- return
- }
- entry.key = ""
- entry.index = nil
- entry.item = nil
- ptr := unsafe.Pointer(entry)
- index_entry_pool.Put(ptr)
-}
-
-func is_unique(f uint8) bool {
- const mask = uint8(1) << 0
- return f&mask != 0
-}
-
-func set_is_unique(f *uint8) {
- const mask = uint8(1) << 0
- (*f) |= mask
-}
-
-func allow_zero(f uint8) bool {
- const mask = uint8(1) << 1
- return f&mask != 0
-}
-
-func set_allow_zero(f *uint8) {
- const mask = uint8(1) << 1
- (*f) |= mask
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/item.go b/vendor/codeberg.org/gruf/go-structr/item.go
deleted file mode 100644
index 4c63b97c6..000000000
--- a/vendor/codeberg.org/gruf/go-structr/item.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package structr
-
-import (
- "os"
- "unsafe"
-
- "codeberg.org/gruf/go-mempool"
-)
-
-type indexed_item struct {
- // linked list elem this item
- // is stored in a main list.
- elem list_elem
-
- // cached data with type.
- data interface{}
-
- // indexed stores the indices
- // this item is stored under.
- indexed []*index_entry
-}
-
-var indexed_item_pool mempool.UnsafePool
-
-// new_indexed_item returns a new prepared indexed_item.
-func new_indexed_item() *indexed_item {
- if ptr := indexed_item_pool.Get(); ptr != nil {
- return (*indexed_item)(ptr)
- }
- item := new(indexed_item)
- item.elem.data = unsafe.Pointer(item)
- return item
-}
-
-// free_indexed_item releases the indexed_item.
-func free_indexed_item(item *indexed_item) {
- if len(item.indexed) > 0 ||
- item.elem.next != nil ||
- item.elem.prev != nil {
- msg := assert("item not in use")
- os.Stderr.WriteString(msg + "\n")
- return
- }
- item.data = nil
- ptr := unsafe.Pointer(item)
- indexed_item_pool.Put(ptr)
-}
-
-// drop_index will drop the given index entry from item's indexed.
-func (i *indexed_item) drop_index(entry *index_entry) {
- for x := 0; x < len(i.indexed); x++ {
- if i.indexed[x] != entry {
- // Prof. Obiwan:
- // this is not the index
- // we are looking for.
- continue
- }
-
- // Reslice index entries minus 'x'.
- _ = copy(i.indexed[x:], i.indexed[x+1:])
- i.indexed[len(i.indexed)-1] = nil
- i.indexed = i.indexed[:len(i.indexed)-1]
- break
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/key.go b/vendor/codeberg.org/gruf/go-structr/key.go
deleted file mode 100644
index ad591f8ac..000000000
--- a/vendor/codeberg.org/gruf/go-structr/key.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package structr
-
-import (
- "sync"
-
- "codeberg.org/gruf/go-byteutil"
- "codeberg.org/gruf/go-mangler/v2"
-)
-
-// Key represents one key to
-// lookup (potentially) stored
-// entries in an Index.
-type Key struct {
- key string
- raw []any
-}
-
-// MakeKey generates Key{} from given parts.
-func MakeKey(parts ...any) Key {
- buf := new_buffer()
- buf.B = mangler.AppendMulti(buf.B[:0], parts...)
- key := string(buf.B)
- free_buffer(buf)
- return Key{
- raw: parts,
- key: key,
- }
-}
-
-// MakeKeys generates []Key{} from given (multiple) parts.
-func MakeKeys(parts ...[]any) []Key {
- keys := make([]Key, len(parts))
- if len(keys) != len(parts) {
- panic(assert("BCE"))
- }
- buf := new_buffer()
- for x, parts := range parts {
- buf.B = mangler.AppendMulti(buf.B[:0], parts...)
- key := string(buf.B)
- keys[x] = Key{
- raw: parts,
- key: key,
- }
- }
- free_buffer(buf)
- return keys
-}
-
-// Key returns the underlying cache key string.
-// NOTE: this will not be log output friendly.
-func (k Key) Key() string {
- return k.key
-}
-
-// Equal returns whether keys are equal.
-func (k Key) Equal(o Key) bool {
- return (k.key == o.key)
-}
-
-// Value returns the raw slice of
-// values that comprise this Key.
-func (k Key) Values() []any {
- return k.raw
-}
-
-var buf_pool sync.Pool
-
-// new_buffer returns a new initialized byte buffer.
-func new_buffer() *byteutil.Buffer {
- v := buf_pool.Get()
- if v == nil {
- buf := new(byteutil.Buffer)
- buf.B = make([]byte, 0, 512)
- v = buf
- }
- return v.(*byteutil.Buffer)
-}
-
-// free_buffer releases the byte buffer.
-func free_buffer(buf *byteutil.Buffer) {
- if cap(buf.B) > int(^uint16(0)) {
- return // drop large bufs
- }
- buf_pool.Put(buf)
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/list.go b/vendor/codeberg.org/gruf/go-structr/list.go
deleted file mode 100644
index 1c931fd51..000000000
--- a/vendor/codeberg.org/gruf/go-structr/list.go
+++ /dev/null
@@ -1,185 +0,0 @@
-package structr
-
-import (
- "os"
- "unsafe"
-
- "codeberg.org/gruf/go-mempool"
-)
-
-// elem represents an elem
-// in a doubly-linked list.
-type list_elem struct {
- next *list_elem
- prev *list_elem
-
- // data is a ptr to the
- // value this linked list
- // element is embedded-in.
- data unsafe.Pointer
-}
-
-// list implements a doubly-linked list, where:
-// - head = index 0 (i.e. the front)
-// - tail = index n-1 (i.e. the back)
-type list struct {
- head *list_elem
- tail *list_elem
- len int
-}
-
-var list_pool mempool.UnsafePool
-
-// new_list returns a new prepared list.
-func new_list() *list {
- if ptr := list_pool.Get(); ptr != nil {
- return (*list)(ptr)
- }
- return new(list)
-}
-
-// free_list releases the list.
-func free_list(list *list) {
- if list.head != nil ||
- list.tail != nil ||
- list.len != 0 {
- msg := assert("list not in use")
- os.Stderr.WriteString(msg + "\n")
- return
- }
- ptr := unsafe.Pointer(list)
- list_pool.Put(ptr)
-}
-
-// push_front will push the given elem to front (head) of list.
-func (l *list) push_front(elem *list_elem) {
-
- // Set new head.
- oldHead := l.head
- l.head = elem
-
- if oldHead != nil {
- // Link to old head
- elem.next = oldHead
- oldHead.prev = elem
- } else {
- // First in list.
- l.tail = elem
- }
-
- // Incr
- // count
- l.len++
-}
-
-// push_back will push the given elem to back (tail) of list.
-func (l *list) push_back(elem *list_elem) {
-
- // Set new tail.
- oldTail := l.tail
- l.tail = elem
-
- if oldTail != nil {
- // Link to old tail
- elem.prev = oldTail
- oldTail.next = elem
- } else {
- // First in list.
- l.head = elem
- }
-
- // Incr
- // count
- l.len++
-}
-
-// move_front will move given elem to front (head) of list.
-// if it is already at front this call is a no-op.
-func (l *list) move_front(elem *list_elem) {
- if elem == l.head {
- return
- }
- l.remove(elem)
- l.push_front(elem)
-}
-
-// move_back will move given elem to back (tail) of list,
-// if it is already at back this call is a no-op.
-func (l *list) move_back(elem *list_elem) {
- if elem == l.tail {
- return
- }
- l.remove(elem)
- l.push_back(elem)
-}
-
-// insert will insert given element at given location in list.
-func (l *list) insert(elem *list_elem, at *list_elem) {
- if elem == at {
- return
- }
-
- // Set new 'next'.
- oldNext := at.next
- at.next = elem
-
- // Link to 'at'.
- elem.prev = at
-
- if oldNext == nil {
- // Set new tail
- l.tail = elem
- } else {
- // Link to 'prev'.
- oldNext.prev = elem
- elem.next = oldNext
- }
-
- // Incr
- // count
- l.len++
-}
-
-// remove will remove given elem from list.
-func (l *list) remove(elem *list_elem) {
- // Get linked elems.
- next := elem.next
- prev := elem.prev
-
- // Unset elem.
- elem.next = nil
- elem.prev = nil
-
- switch {
- case next == nil:
- if prev == nil {
- // next == nil && prev == nil
- //
- // elem is ONLY one in list.
- l.head = nil
- l.tail = nil
- } else {
- // next == nil && prev != nil
- //
- // elem is last in list.
- l.tail = prev
- prev.next = nil
- }
-
- case prev == nil:
- // next != nil && prev == nil
- //
- // elem is front in list.
- l.head = next
- next.prev = nil
-
- // elem in middle of list.
- default:
- next.prev = prev
- prev.next = next
- }
-
- // Decr
- // count
- l.len--
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/map.go b/vendor/codeberg.org/gruf/go-structr/map.go
deleted file mode 100644
index 6a718eae1..000000000
--- a/vendor/codeberg.org/gruf/go-structr/map.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package structr
-
-type hashmap struct {
- m map[string]*list
- n int
-}
-
-func (m *hashmap) Init(cap int) {
- m.m = make(map[string]*list, cap)
- m.n = cap
-}
-
-func (m *hashmap) Get(key string) *list {
- return m.m[key]
-}
-
-func (m *hashmap) Put(key string, list *list) {
- m.m[key] = list
- if n := len(m.m); n > m.n {
- m.n = n
- }
-}
-
-func (m *hashmap) Delete(key string) {
- delete(m.m, key)
-}
-
-func (m *hashmap) Compact() {
- // Noop when hashmap size
- // is too small to matter.
- if m.n < 2048 {
- return
- }
-
- // Difference between maximum map
- // size and the current map size.
- diff := m.n - len(m.m)
-
- // Maximum load factor before
- // runtime allocates new hmap:
- // maxLoad = 13 / 16
- //
- // So we apply the inverse/2, once
- // $maxLoad/2 % of hmap is empty we
- // compact the map to drop buckets.
- //
- // TODO: this is still a relatively
- // good approximation, but it has
- // changed a little with swiss maps.
- if 2*16*diff > m.n*13 {
-
- // Create new map only big as required.
- m2 := make(map[string]*list, len(m.m))
- for k, v := range m.m {
- m2[k] = v
- }
-
- // Set new.
- m.m = m2
- m.n = len(m2)
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/queue.go b/vendor/codeberg.org/gruf/go-structr/queue.go
deleted file mode 100644
index 674967d74..000000000
--- a/vendor/codeberg.org/gruf/go-structr/queue.go
+++ /dev/null
@@ -1,346 +0,0 @@
-package structr
-
-import (
- "sync"
- "unsafe"
-)
-
-// QueueConfig defines config vars
-// for initializing a struct queue.
-type QueueConfig[StructType any] struct {
-
- // Pop is called when queue values
- // are popped, during calls to any
- // of the Pop___() series of fns.
- Pop func(StructType)
-
- // Indices defines indices to create
- // in the Queue for the receiving
- // generic struct parameter type.
- Indices []IndexConfig
-}
-
-// Queue provides a structure model queue with
-// automated indexing and popping by any init
-// defined lookups of field combinations.
-type Queue[StructType any] struct {
-
- // hook functions.
- copy func(StructType) StructType
- pop func(StructType)
-
- // main underlying
- // struct item queue.
- queue list
-
- // indices used in storing passed struct
- // types by user defined sets of fields.
- indices []Index
-
- // protective mutex, guards:
- // - Queue{}.queue
- // - Index{}.data
- // - Queue{} hook fns
- mutex sync.Mutex
-}
-
-// Init initializes the queue with given configuration
-// including struct fields to index, and necessary fns.
-func (q *Queue[T]) Init(config QueueConfig[T]) {
- t := get_type_iter[T]()
-
- if len(config.Indices) == 0 {
- panic("no indices provided")
- }
-
- // Safely copy over
- // provided config.
- q.mutex.Lock()
- defer q.mutex.Unlock()
- q.indices = make([]Index, len(config.Indices))
- for i, cfg := range config.Indices {
- q.indices[i].ptr = unsafe.Pointer(q)
- q.indices[i].init(t, cfg, 0)
- }
- q.pop = config.Pop
-}
-
-// Index selects index with given name from queue, else panics.
-func (q *Queue[T]) Index(name string) *Index {
- for i, idx := range q.indices {
- if idx.name == name {
- return &(q.indices[i])
- }
- }
- panic("unknown index: " + name)
-}
-
-// PopFront pops the current value at front of the queue.
-func (q *Queue[T]) PopFront() (T, bool) {
- t := q.PopFrontN(1)
- if len(t) == 0 {
- var t T
- return t, false
- }
- return t[0], true
-}
-
-// PopBack pops the current value at back of the queue.
-func (q *Queue[T]) PopBack() (T, bool) {
- t := q.PopBackN(1)
- if len(t) == 0 {
- var t T
- return t, false
- }
- return t[0], true
-}
-
-// PopFrontN attempts to pop n values from front of the queue.
-func (q *Queue[T]) PopFrontN(n int) []T {
- return q.pop_n(n, func() *list_elem {
- return q.queue.head
- })
-}
-
-// PopBackN attempts to pop n values from back of the queue.
-func (q *Queue[T]) PopBackN(n int) []T {
- return q.pop_n(n, func() *list_elem {
- return q.queue.tail
- })
-}
-
-// Pop attempts to pop values from queue indexed under any of keys.
-func (q *Queue[T]) Pop(index *Index, keys ...Key) []T {
- if index == nil {
- panic("no index given")
- } else if index.ptr != unsafe.Pointer(q) {
- panic("invalid index for queue")
- }
-
- // Acquire lock.
- q.mutex.Lock()
-
- // Preallocate expected ret slice.
- values := make([]T, 0, len(keys))
-
- for i := range keys {
- // Delete all items under key from index, collecting
- // value items and dropping them from all their indices.
- index.delete(keys[i].key, func(item *indexed_item) {
-
- // Append deleted to values.
- value := item.data.(T)
- values = append(values, value)
-
- // Delete item.
- q.delete(item)
- })
- }
-
- // Get func ptrs.
- pop := q.pop
-
- // Done with lock.
- q.mutex.Unlock()
-
- if pop != nil {
- // Pass all popped values
- // to given user hook (if set).
- for _, value := range values {
- pop(value)
- }
- }
-
- return values
-}
-
-// PushFront pushes values to front of queue.
-func (q *Queue[T]) PushFront(values ...T) {
- q.mutex.Lock()
- for i := range values {
- item := q.index(values[i])
- q.queue.push_front(&item.elem)
- }
- q.mutex.Unlock()
-}
-
-// PushBack pushes values to back of queue.
-func (q *Queue[T]) PushBack(values ...T) {
- q.mutex.Lock()
- for i := range values {
- item := q.index(values[i])
- q.queue.push_back(&item.elem)
- }
- q.mutex.Unlock()
-}
-
-// MoveFront attempts to move values indexed under any of keys to the front of the queue.
-func (q *Queue[T]) MoveFront(index *Index, keys ...Key) {
- q.mutex.Lock()
- for i := range keys {
- index.get(keys[i].key, func(item *indexed_item) {
- q.queue.move_front(&item.elem)
- })
- }
- q.mutex.Unlock()
-}
-
-// MoveBack attempts to move values indexed under any of keys to the back of the queue.
-func (q *Queue[T]) MoveBack(index *Index, keys ...Key) {
- q.mutex.Lock()
- for i := range keys {
- index.get(keys[i].key, func(item *indexed_item) {
- q.queue.move_back(&item.elem)
- })
- }
- q.mutex.Unlock()
-}
-
-// Len returns the current length of queue.
-func (q *Queue[T]) Len() int {
- q.mutex.Lock()
- l := q.queue.len
- q.mutex.Unlock()
- return l
-}
-
-// Debug returns debug stats about queue.
-func (q *Queue[T]) Debug() map[string]any {
- m := make(map[string]any, 2)
- q.mutex.Lock()
- m["queue"] = q.queue.len
- indices := make(map[string]any, len(q.indices))
- m["indices"] = indices
- for _, idx := range q.indices {
- var n uint64
- for _, l := range idx.data.m {
- n += uint64(l.len)
- }
- indices[idx.name] = n
- }
- q.mutex.Unlock()
- return m
-}
-
-func (q *Queue[T]) pop_n(n int, next func() *list_elem) []T {
- if next == nil {
- panic("nil fn")
- }
-
- // Acquire lock.
- q.mutex.Lock()
-
- // Preallocate ret slice.
- values := make([]T, 0, n)
-
- // Iterate over 'n' items.
- for i := 0; i < n; i++ {
-
- // Get next elem.
- next := next()
- if next == nil {
-
- // reached
- // end.
- break
- }
-
- // Cast the indexed item from elem.
- item := (*indexed_item)(next.data)
-
- // Append deleted to values.
- value := item.data.(T)
- values = append(values, value)
-
- // Delete item.
- q.delete(item)
- }
-
- // Get func ptrs.
- pop := q.pop
-
- // Done with lock.
- q.mutex.Unlock()
-
- if pop != nil {
- // Pass all popped values
- // to given user hook (if set).
- for _, value := range values {
- pop(value)
- }
- }
-
- return values
-}
-
-func (q *Queue[T]) index(value T) *indexed_item {
- item := new_indexed_item()
- if cap(item.indexed) < len(q.indices) {
-
- // Preallocate item indices slice to prevent Go auto
- // allocating overlying large slices we don't need.
- item.indexed = make([]*index_entry, 0, len(q.indices))
- }
-
- // Set item value.
- item.data = value
-
- // Get ptr to value data.
- ptr := unsafe.Pointer(&value)
-
- // Acquire key buf.
- buf := new_buffer()
-
- for i := range q.indices {
- // Get current index ptr.
- idx := &(q.indices[i])
-
- // Extract fields comprising index key.
- parts := extract_fields(ptr, idx.fields)
-
- // Calculate index key.
- key := idx.key(buf, parts)
- if key == "" {
- continue
- }
-
- // Append item to this index.
- evicted := idx.append(key, item)
- if evicted != nil {
-
- // This item is no longer
- // indexed, remove from list.
- q.queue.remove(&evicted.elem)
- free_indexed_item(evicted)
- }
- }
-
- // Done with buf.
- free_buffer(buf)
-
- return item
-}
-
-func (q *Queue[T]) delete(i *indexed_item) {
- for len(i.indexed) > 0 {
- // Pop last indexed entry from list.
- entry := i.indexed[len(i.indexed)-1]
- i.indexed[len(i.indexed)-1] = nil
- i.indexed = i.indexed[:len(i.indexed)-1]
-
- // Get entry's index.
- index := entry.index
-
- // Drop this index_entry.
- index.delete_entry(entry)
-
- // Compact index map.
- index.data.Compact()
- }
-
- // Drop from queue list.
- q.queue.remove(&i.elem)
-
- // Free unused item.
- free_indexed_item(i)
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/queue_ctx.go b/vendor/codeberg.org/gruf/go-structr/queue_ctx.go
deleted file mode 100644
index 9a9c615e2..000000000
--- a/vendor/codeberg.org/gruf/go-structr/queue_ctx.go
+++ /dev/null
@@ -1,152 +0,0 @@
-package structr
-
-import (
- "context"
-)
-
-// QueueCtx is a context-aware form of Queue{}.
-type QueueCtx[StructType any] struct {
- ch chan struct{}
- Queue[StructType]
-}
-
-// PopFront pops the current value at front of the queue, else blocking on ctx.
-func (q *QueueCtx[T]) PopFront(ctx context.Context) (T, bool) {
- return q.pop(ctx, func() *list_elem {
- return q.queue.head
- })
-}
-
-// PopBack pops the current value at back of the queue, else blocking on ctx.
-func (q *QueueCtx[T]) PopBack(ctx context.Context) (T, bool) {
- return q.pop(ctx, func() *list_elem {
- return q.queue.tail
- })
-}
-
-// PushFront pushes values to front of queue.
-func (q *QueueCtx[T]) PushFront(values ...T) {
- q.mutex.Lock()
- for i := range values {
- item := q.index(values[i])
- q.queue.push_front(&item.elem)
- }
- if q.ch != nil {
- close(q.ch)
- q.ch = nil
- }
- q.mutex.Unlock()
-}
-
-// PushBack pushes values to back of queue.
-func (q *QueueCtx[T]) PushBack(values ...T) {
- q.mutex.Lock()
- for i := range values {
- item := q.index(values[i])
- q.queue.push_back(&item.elem)
- }
- if q.ch != nil {
- close(q.ch)
- q.ch = nil
- }
- q.mutex.Unlock()
-}
-
-// Wait returns a ptr to the current ctx channel,
-// this will block until next push to the queue.
-func (q *QueueCtx[T]) Wait() <-chan struct{} {
- q.mutex.Lock()
- if q.ch == nil {
- q.ch = make(chan struct{})
- }
- ctx := q.ch
- q.mutex.Unlock()
- return ctx
-}
-
-// Debug returns debug stats about queue.
-func (q *QueueCtx[T]) Debug() map[string]any {
- m := make(map[string]any)
- q.mutex.Lock()
- m["queue"] = q.queue.len
- indices := make(map[string]any)
- m["indices"] = indices
- for i := range q.indices {
- var n uint64
- for _, l := range q.indices[i].data.m {
- n += uint64(l.len)
- }
- indices[q.indices[i].name] = n
- }
- q.mutex.Unlock()
- return m
-}
-
-func (q *QueueCtx[T]) pop(ctx context.Context, next func() *list_elem) (T, bool) {
- if next == nil {
- panic("nil fn")
- } else if ctx == nil {
- panic("nil ctx")
- }
-
- // Acquire lock.
- q.mutex.Lock()
-
- var elem *list_elem
-
- for {
- // Get element.
- elem = next()
- if elem != nil {
- break
- }
-
- if q.ch == nil {
- // Allocate new ctx channel.
- q.ch = make(chan struct{})
- }
-
- // Get current
- // ch pointer.
- ch := q.ch
-
- // Unlock queue.
- q.mutex.Unlock()
-
- select {
- // Ctx cancelled.
- case <-ctx.Done():
- var z T
- return z, false
-
- // Pushed!
- case <-ch:
- }
-
- // Relock queue.
- q.mutex.Lock()
- }
-
- // Cast the indexed item from elem.
- item := (*indexed_item)(elem.data)
-
- // Extract item value.
- value := item.data.(T)
-
- // Delete item.
- q.delete(item)
-
- // Get func ptrs.
- pop := q.Queue.pop
-
- // Done with lock.
- q.mutex.Unlock()
-
- if pop != nil {
- // Pass to
- // user hook.
- pop(value)
- }
-
- return value, true
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/runtime.go b/vendor/codeberg.org/gruf/go-structr/runtime.go
deleted file mode 100644
index 508cd6e4c..000000000
--- a/vendor/codeberg.org/gruf/go-structr/runtime.go
+++ /dev/null
@@ -1,294 +0,0 @@
-package structr
-
-import (
- "fmt"
- "reflect"
- "runtime"
- "strings"
- "unicode"
- "unicode/utf8"
- "unsafe"
-
- "codeberg.org/gruf/go-mangler/v2"
- "codeberg.org/gruf/go-xunsafe"
-)
-
-// struct_field contains pre-prepared type
-// information about a struct's field member,
-// including memory offset and hash function.
-type struct_field struct {
-
- // struct field type mangling
- // (i.e. fast serializing) fn.
- mangle mangler.Mangler
-
- // zero value data, used when
- // nil encountered during ptr
- // offset following.
- zero unsafe.Pointer
-
- // mangled zero value string,
- // to check zero value keys.
- zerostr string
-
- // offsets defines whereabouts in
- // memory this field is located,
- // and after how many dereferences.
- offsets []next_offset
-}
-
-// next_offset defines a next offset location
-// in a struct_field, first by the number of
-// derefences required, then by offset from
-// that final memory location.
-type next_offset struct {
- derefs int
- offset uintptr
-}
-
-// get_type_iter returns a prepared xunsafe.TypeIter{} for generic parameter type,
-// with flagIndir specifically set as we always take a reference to value type.
-func get_type_iter[T any]() xunsafe.TypeIter {
- rtype := reflect.TypeOf((*T)(nil)).Elem()
- flags := xunsafe.Reflect_flag(xunsafe.Abi_Type_Kind(rtype))
- flags |= xunsafe.Reflect_flagIndir // always comes from unsafe ptr
- return xunsafe.ToTypeIter(rtype, flags)
-}
-
-// find_field will search for a struct field with given set of names,
-// where names is a len > 0 slice of names account for struct nesting.
-func find_field(t xunsafe.TypeIter, names []string) (sfield struct_field, ftype reflect.Type) {
- var (
- // is_exported returns whether name is exported
- // from a package; can be func or struct field.
- is_exported = func(name string) bool {
- r, _ := utf8.DecodeRuneInString(name)
- return unicode.IsUpper(r)
- }
-
- // pop_name pops the next name from
- // the provided slice of field names.
- pop_name = func() string {
- name := names[0]
- names = names[1:]
- if !is_exported(name) {
- panic(fmt.Sprintf("field is not exported: %s", name))
- }
- return name
- }
-
- // field is the iteratively searched
- // struct field value in below loop.
- field reflect.StructField
- )
-
- // Take reference
- // of parent iter.
- o := t
-
- for len(names) > 0 {
- // Pop next name.
- name := pop_name()
-
- var n int
- rtype := t.Type
- flags := t.Flag
-
- // Iteratively dereference pointer types.
- for rtype.Kind() == reflect.Pointer {
-
- // If this actual indirect memory,
- // increase dereferences counter.
- if flags&xunsafe.Reflect_flagIndir != 0 {
- n++
- }
-
- // Get next elem type.
- rtype = rtype.Elem()
-
- // Get next set of dereferenced element type flags.
- flags = xunsafe.ReflectPointerElemFlags(flags, rtype)
-
- // Update type iter info.
- t = t.Child(rtype, flags)
- }
-
- // Check for valid struct type.
- if rtype.Kind() != reflect.Struct {
- panic(fmt.Sprintf("field %s is not struct (or ptr-to): %s", rtype, name))
- }
-
- // Set offset info.
- var off next_offset
- off.derefs = n
-
- var ok bool
-
- // Look for the next field by name.
- field, ok = rtype.FieldByName(name)
- if !ok {
- panic(fmt.Sprintf("unknown field: %s", name))
- }
-
- // Set next offset value.
- off.offset = field.Offset
- sfield.offsets = append(sfield.offsets, off)
-
- // Calculate value flags, and set next nested field type.
- flags = xunsafe.ReflectStructFieldFlags(t.Flag, field.Type)
- t = t.Child(field.Type, flags)
- }
-
- // Set final field type.
- ftype = t.TypeInfo.Type
-
- // Get mangler from type info.
- sfield.mangle = mangler.Get(t)
-
- // Calculate zero value string.
- zptr := zero_value_ptr(o, sfield.offsets)
- zstr := string(sfield.mangle(nil, zptr))
- sfield.zerostr = zstr
- sfield.zero = zptr
-
- return
-}
-
-// zero_value iterates the type contained in TypeIter{} along the given
-// next_offset{} values, creating new ptrs where necessary, returning the
-// zero reflect.Value{} after fully iterating the next_offset{} slice.
-func zero_value(t xunsafe.TypeIter, offsets []next_offset) reflect.Value {
- v := reflect.New(t.Type).Elem()
- for _, offset := range offsets {
- for range offset.derefs {
- if v.IsNil() {
- new := reflect.New(v.Type().Elem())
- v.Set(new)
- }
- v = v.Elem()
- }
- for i := 0; i < v.NumField(); i++ {
- if v.Type().Field(i).Offset == offset.offset {
- v = v.Field(i)
- break
- }
- }
- }
- return v
-}
-
-// zero_value_ptr returns the unsafe pointer address of the result of zero_value().
-func zero_value_ptr(t xunsafe.TypeIter, offsets []next_offset) unsafe.Pointer {
- return zero_value(t, offsets).Addr().UnsafePointer()
-}
-
-// extract_fields extracts given structfields from the provided value type,
-// this is done using predetermined struct field memory offset locations.
-func extract_fields(ptr unsafe.Pointer, fields []struct_field) []unsafe.Pointer {
-
- // Prepare slice of field value pointers.
- ptrs := make([]unsafe.Pointer, len(fields))
- if len(ptrs) != len(fields) {
- panic(assert("BCE"))
- }
-
- for i, field := range fields {
- // loop scope.
- fptr := ptr
-
- for _, offset := range field.offsets {
- // Dereference any ptrs to offset.
- fptr = deref(fptr, offset.derefs)
- if fptr == nil {
- break
- }
-
- // Jump forward by offset to next ptr.
- fptr = unsafe.Pointer(uintptr(fptr) +
- offset.offset)
- }
-
- if fptr == nil {
- // Use zero value.
- fptr = field.zero
- }
-
- // Set field ptr.
- ptrs[i] = fptr
- }
-
- return ptrs
-}
-
-// pkey_field contains pre-prepared type
-// information about a primary key struct's
-// field member, including memory offset.
-type pkey_field struct {
-
- // zero value data, used when
- // nil encountered during ptr
- // offset following.
- zero unsafe.Pointer
-
- // offsets defines whereabouts in
- // memory this field is located.
- offsets []next_offset
-}
-
-// extract_pkey will extract a pointer from 'ptr', to
-// the primary key struct field defined by 'field'.
-func extract_pkey(ptr unsafe.Pointer, field pkey_field) unsafe.Pointer {
- for _, offset := range field.offsets {
-
- // Dereference any ptrs to offset.
- ptr = deref(ptr, offset.derefs)
- if ptr == nil {
- break
- }
-
- // Jump forward by offset to next ptr.
- ptr = unsafe.Pointer(uintptr(ptr) +
- offset.offset)
- }
-
- if ptr == nil {
- // Use zero value.
- ptr = field.zero
- }
-
- return ptr
-}
-
-// deref will dereference ptr 'n' times (or until nil).
-func deref(p unsafe.Pointer, n int) unsafe.Pointer {
- for ; n > 0; n-- {
- if p == nil {
- return nil
- }
- p = *(*unsafe.Pointer)(p)
- }
- return p
-}
-
-// assert can be called to indicated a block
-// of code should not be able to be reached,
-// it returns a BUG report with callsite.
-func assert(assert string) string {
- pcs := make([]uintptr, 1)
- _ = runtime.Callers(2, pcs)
- funcname := "go-structr" // by default use just our library name
- if frames := runtime.CallersFrames(pcs); frames != nil {
- frame, _ := frames.Next()
- funcname = frame.Function
- if i := strings.LastIndexByte(funcname, '/'); i != -1 {
- funcname = funcname[i+1:]
- }
- }
- var buf strings.Builder
- buf.Grow(32 + len(assert) + len(funcname))
- buf.WriteString("BUG: assertion \"")
- buf.WriteString(assert)
- buf.WriteString("\" failed in ")
- buf.WriteString(funcname)
- return buf.String()
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/timeline.go b/vendor/codeberg.org/gruf/go-structr/timeline.go
deleted file mode 100644
index e738a8228..000000000
--- a/vendor/codeberg.org/gruf/go-structr/timeline.go
+++ /dev/null
@@ -1,1197 +0,0 @@
-package structr
-
-import (
- "cmp"
- "os"
- "reflect"
- "slices"
- "strings"
- "sync"
- "sync/atomic"
- "unsafe"
-
- "codeberg.org/gruf/go-mempool"
-)
-
-// Direction defines a direction
-// to iterate entries in a Timeline.
-type Direction bool
-
-const (
- // Asc = ascending, i.e. bottom-up.
- Asc = Direction(true)
-
- // Desc = descending, i.e. top-down.
- Desc = Direction(false)
-)
-
-// TimelineConfig defines config vars for initializing a Timeline{}.
-type TimelineConfig[StructType any, PK cmp.Ordered] struct {
-
- // Copy provides a means of copying
- // timelined values, to ensure returned values
- // do not share memory with those in timeline.
- Copy func(StructType) StructType
-
- // Invalidate is called when timelined
- // values are invalidated, either as passed
- // to Insert(), or by calls to Invalidate().
- Invalidate func(StructType)
-
- // PKey defines the generic parameter StructType's
- // field to use as the primary key for this cache.
- // It must be ordered so that the timeline can
- // maintain correct sorting of inserted values.
- //
- // Field selection logic follows the same path as
- // with IndexConfig{}.Fields. Noting that in this
- // case only a single field is permitted, though
- // it may be nested, and as described above the
- // type must conform to cmp.Ordered.
- PKey IndexConfig
-
- // Indices defines indices to create
- // in the Timeline for the receiving
- // generic struct type parameter.
- Indices []IndexConfig
-}
-
-// Timeline provides an ordered-list like cache of structures,
-// with automated indexing and invalidation by any initialization
-// defined combination of fields. The list order is maintained
-// according to the configured struct primary key.
-type Timeline[StructType any, PK cmp.Ordered] struct {
-
- // hook functions.
- invalid func(StructType)
- copy func(StructType) StructType
-
- // main underlying
- // timeline list.
- //
- // where:
- // - head = top = largest
- // - tail = btm = smallest
- list list
-
- // contains struct field information of
- // the field used as the primary key for
- // this timeline. it can also be found
- // under indices[0]
- pkey pkey_field
-
- // indices used in storing passed struct
- // types by user defined sets of fields.
- indices []Index
-
- // atomically updated head
- // / tail primary key values.
- headPK unsafe.Pointer
- tailPK unsafe.Pointer
-
- // protective mutex, guards:
- // - Timeline{}.*
- // - Index{}.data
- mutex sync.Mutex
-}
-
-// Init initializes the timeline with given configuration
-// including struct fields to index, and necessary fns.
-func (t *Timeline[T, PK]) Init(config TimelineConfig[T, PK]) {
- ti := get_type_iter[T]()
-
- if len(config.Indices) == 0 {
- panic("no indices provided")
- }
-
- if config.Copy == nil {
- panic("copy function must be provided")
- }
-
- if strings.Contains(config.PKey.Fields, ",") {
- panic("primary key must contain only 1 field")
- }
-
- // Verify primary key parameter type is correct.
- names := strings.Split(config.PKey.Fields, ".")
- if _, ftype := find_field(ti, names); //
- ftype != reflect.TypeFor[PK]() {
- panic("primary key field path and generic parameter type do not match")
- }
-
- // Safely copy over
- // provided config.
- t.mutex.Lock()
- defer t.mutex.Unlock()
-
- // The first index is created from PKey,
- // other indices are created as expected.
- t.indices = make([]Index, len(config.Indices)+1)
- t.indices[0].ptr = unsafe.Pointer(t)
- t.indices[0].init(ti, config.PKey, 0)
- for i, cfg := range config.Indices {
- t.indices[i+1].ptr = unsafe.Pointer(t)
- t.indices[i+1].init(ti, cfg, 0)
- }
-
- // Extract pkey details from index.
- field := t.indices[0].fields[0]
- t.pkey = pkey_field{
- zero: field.zero,
- offsets: field.offsets,
- }
-
- // Copy over remaining.
- t.copy = config.Copy
- t.invalid = config.Invalidate
-}
-
-// Index selects index with given name from timeline, else panics.
-func (t *Timeline[T, PK]) Index(name string) *Index {
- for i, idx := range t.indices {
- if idx.name == name {
- return &(t.indices[i])
- }
- }
- panic("unknown index: " + name)
-}
-
-// Head returns the current head primary key.
-func (t *Timeline[T, PK]) Head() *PK {
- return (*PK)(atomic.LoadPointer(&t.headPK))
-}
-
-// Tail returns the current tail primary key.
-func (t *Timeline[T, PK]) Tail() *PK {
- return (*PK)(atomic.LoadPointer(&t.tailPK))
-}
-
-// Select allows you to retrieve a slice of values, in order, from the timeline.
-// This slice is defined by the minimum and maximum primary key parameters, up to
-// a given length in size. The direction in which you select will determine which
-// of the min / max primary key values is used as the *cursor* to begin the start
-// of the selection, and which is used as the *boundary* to mark the end, if set.
-// In either case, the length parameter is always optional.
-//
-// dir = Asc : cursors up from 'max' (required), with boundary 'min' (optional).
-// dir = Desc : cursors down from 'min' (required), with boundary 'max' (optional).
-func (t *Timeline[T, PK]) Select(min, max *PK, length *int, dir Direction) (values []T) {
-
- // Acquire lock.
- t.mutex.Lock()
-
- // Check init'd.
- if t.copy == nil {
- t.mutex.Unlock()
- panic("not initialized")
- }
-
- switch dir {
- case Asc:
- // Verify args.
- if min == nil {
- t.mutex.Unlock()
- panic("min must be provided when selecting asc")
- }
-
- // Select determined values ASCENDING.
- values = t.select_asc(*min, max, length)
-
- case Desc:
- // Verify args.
- if max == nil {
- t.mutex.Unlock()
- panic("max must be provided when selecting asc")
- }
-
- // Select determined values DESCENDING.
- values = t.select_desc(min, *max, length)
- }
-
- // Done with lock.
- t.mutex.Unlock()
-
- return values
-}
-
-// Insert will insert the given values into the timeline,
-// calling any set invalidate hook on each inserted value.
-// Returns current list length after performing inserts.
-func (t *Timeline[T, PK]) Insert(values ...T) int {
-
- // Acquire lock.
- t.mutex.Lock()
-
- // Check init'd.
- if t.copy == nil {
- t.mutex.Unlock()
- panic("not initialized")
- }
-
- // Allocate a slice of our value wrapping struct type.
- with_keys := make([]value_with_pk[T, PK], len(values))
- if len(with_keys) != len(values) {
- panic(assert("BCE"))
- }
-
- // Range the provided values.
- for i, value := range values {
-
- // Create our own copy
- // of value to work with.
- value = t.copy(value)
-
- // Take ptr to the value copy.
- vptr := unsafe.Pointer(&value)
-
- // Extract primary key from vptr.
- kptr := extract_pkey(vptr, t.pkey)
- pkey := *(*PK)(kptr)
-
- // Append wrapped value to slice with
- // the acquire pointers and primary key.
- with_keys[i] = value_with_pk[T, PK]{
- k: pkey,
- v: value,
-
- kptr: kptr,
- vptr: vptr,
- }
- }
-
- // BEFORE inserting the prepared slice of value copies w/ primary
- // keys, sort them by their primary key, descending. This permits
- // us to re-use the 'last' timeline position as next insert cursor.
- // Otherwise we would have to iterate from 'head' every single time.
- slices.SortFunc(with_keys, func(a, b value_with_pk[T, PK]) int {
- const k = +1
- switch {
- case a.k < b.k:
- return +k
- case b.k < a.k:
- return -k
- default:
- return 0
- }
- })
-
- var last *list_elem
-
- // Store each value in the timeline,
- // updating the last used list element
- // each time so we don't have to iter
- // down from head on every single store.
- for _, value := range with_keys {
- last = t.store_one(last, value)
- }
-
- // Get func ptrs.
- invalid := t.invalid
-
- // Get length AFTER
- // insert to return.
- len := t.list.len
-
- // Done with lock.
- t.mutex.Unlock()
-
- if invalid != nil {
- // Pass all invalidated values
- // to given user hook (if set).
- for _, value := range values {
- invalid(value)
- }
- }
-
- return len
-}
-
-// Invalidate invalidates all entries stored in index under given keys.
-// Note that if set, this will call the invalidate hook on each value.
-func (t *Timeline[T, PK]) Invalidate(index *Index, keys ...Key) {
- if index == nil {
- panic("no index given")
- } else if index.ptr != unsafe.Pointer(t) {
- panic("invalid index for timeline")
- }
-
- // Acquire lock.
- t.mutex.Lock()
-
- // Preallocate expected ret slice.
- values := make([]T, 0, len(keys))
-
- for i := range keys {
- // Delete all items under key from index, collecting
- // value items and dropping them from all their indices.
- index.delete(keys[i].key, func(item *indexed_item) {
-
- // Cast to *actual* timeline item.
- t_item := to_timeline_item(item)
-
- if value, ok := item.data.(T); ok {
- // No need to copy, as item
- // being deleted from cache.
- values = append(values, value)
- }
-
- // Delete item.
- t.delete(t_item)
- })
- }
-
- // Get func ptrs.
- invalid := t.invalid
-
- // Done with lock.
- t.mutex.Unlock()
-
- if invalid != nil {
- // Pass all invalidated values
- // to given user hook (if set).
- for _, value := range values {
- invalid(value)
- }
- }
-}
-
-// Range will range over all values in the timeline in given direction.
-// dir = Asc : ranges from the bottom-up.
-// dir = Desc : ranges from the top-down.
-//
-// Please note that the entire Timeline{} will be locked for the duration of the range
-// operation, i.e. from the beginning of the first yield call until the end of the last.
-func (t *Timeline[T, PK]) Range(dir Direction) func(yield func(index int, value T) bool) {
- return func(yield func(int, T) bool) {
- if t.copy == nil {
- panic("not initialized")
- } else if yield == nil {
- panic("nil func")
- }
-
- // Acquire lock.
- t.mutex.Lock()
- defer t.mutex.Unlock()
-
- var i int
- switch dir {
-
- case Asc:
- // Iterate through linked list from bottom (i.e. tail).
- for prev := t.list.tail; prev != nil; prev = prev.prev {
-
- // Extract item from list element.
- item := (*timeline_item)(prev.data)
-
- // Create copy of item value.
- value := t.copy(item.data.(T))
-
- // Pass to given function.
- if !yield(i, value) {
- break
- }
-
- // Iter
- i++
- }
-
- case Desc:
- // Iterate through linked list from top (i.e. head).
- for next := t.list.head; next != nil; next = next.next {
-
- // Extract item from list element.
- item := (*timeline_item)(next.data)
-
- // Create copy of item value.
- value := t.copy(item.data.(T))
-
- // Pass to given function.
- if !yield(i, value) {
- break
- }
-
- // Iter
- i++
- }
- }
- }
-}
-
-// RangeUnsafe is functionally similar to Range(), except it does not pass *copies* of
-// data. It allows you to operate on the data directly and modify it. As such it can also
-// be more performant to use this function, even for read-write operations.
-//
-// Please note that the entire Timeline{} will be locked for the duration of the range
-// operation, i.e. from the beginning of the first yield call until the end of the last.
-func (t *Timeline[T, PK]) RangeUnsafe(dir Direction) func(yield func(index int, value T) bool) {
- return func(yield func(int, T) bool) {
- if t.copy == nil {
- panic("not initialized")
- } else if yield == nil {
- panic("nil func")
- }
-
- // Acquire lock.
- t.mutex.Lock()
- defer t.mutex.Unlock()
-
- var i int
- switch dir {
-
- case Asc:
- // Iterate through linked list from bottom (i.e. tail).
- for prev := t.list.tail; prev != nil; prev = prev.prev {
-
- // Extract item from list element.
- item := (*timeline_item)(prev.data)
-
- // Pass to given function.
- if !yield(i, item.data.(T)) {
- break
- }
-
- // Iter
- i++
- }
-
- case Desc:
- // Iterate through linked list from top (i.e. head).
- for next := t.list.head; next != nil; next = next.next {
-
- // Extract item from list element.
- item := (*timeline_item)(next.data)
-
- // Pass to given function.
- if !yield(i, item.data.(T)) {
- break
- }
-
- // Iter
- i++
- }
- }
- }
-}
-
-// RangeKeys will iterate over all values for given keys in the given index.
-//
-// Please note that the entire Timeline{} will be locked for the duration of the range
-// operation, i.e. from the beginning of the first yield call until the end of the last.
-func (t *Timeline[T, PK]) RangeKeys(index *Index, keys ...Key) func(yield func(T) bool) {
- return func(yield func(T) bool) {
- if t.copy == nil {
- panic("not initialized")
- } else if index == nil {
- panic("no index given")
- } else if index.ptr != unsafe.Pointer(t) {
- panic("invalid index for timeline")
- } else if yield == nil {
- panic("nil func")
- }
-
- // Acquire lock.
- t.mutex.Lock()
- defer t.mutex.Unlock()
-
- for _, key := range keys {
- var done bool
-
- // Iterate over values in index under key.
- index.get(key.key, func(i *indexed_item) {
-
- // Cast to timeline_item type.
- item := to_timeline_item(i)
-
- // Create copy of item value.
- value := t.copy(item.data.(T))
-
- // Pass val to yield function.
- done = done || !yield(value)
- })
-
- if done {
- break
- }
- }
- }
-}
-
-// RangeKeysUnsafe is functionally similar to RangeKeys(), except it does not pass *copies*
-// of data. It allows you to operate on the data directly and modify it. As such it can also
-// be more performant to use this function, even for read-write operations.
-//
-// Please note that the entire Timeline{} will be locked for the duration of the range
-// operation, i.e. from the beginning of the first yield call until the end of the last.
-func (t *Timeline[T, PK]) RangeKeysUnsafe(index *Index, keys ...Key) func(yield func(T) bool) {
- return func(yield func(T) bool) {
- if t.copy == nil {
- panic("not initialized")
- } else if index == nil {
- panic("no index given")
- } else if index.ptr != unsafe.Pointer(t) {
- panic("invalid index for timeline")
- } else if yield == nil {
- panic("nil func")
- }
-
- // Acquire lock.
- t.mutex.Lock()
- defer t.mutex.Unlock()
-
- for _, key := range keys {
- var done bool
-
- // Iterate over values in index under key.
- index.get(key.key, func(i *indexed_item) {
-
- // Cast to timeline_item type.
- item := to_timeline_item(i)
-
- // Pass value data to yield function.
- done = done || !yield(item.data.(T))
- })
-
- if done {
- break
- }
- }
- }
-}
-
-// Trim will remove entries from the timeline in given
-// direction, ensuring timeline is no larger than 'max'.
-// If 'max' >= t.Len(), this function is a no-op.
-// dir = Asc : trims from the bottom-up.
-// dir = Desc : trims from the top-down.
-func (t *Timeline[T, PK]) Trim(max int, dir Direction) {
- // Acquire lock.
- t.mutex.Lock()
-
- // Calculate number to drop.
- diff := t.list.len - int(max)
- if diff <= 0 {
-
- // Trim not needed.
- t.mutex.Unlock()
- return
- }
-
- switch dir {
- case Asc:
- // Iterate over 'diff' items
- // from bottom of timeline list.
- for range diff {
-
- // Get bottom list elem.
- bottom := t.list.tail
- if bottom == nil {
-
- // Zero head + tail primary keys.
- atomic.StorePointer(&t.headPK, nil)
- atomic.StorePointer(&t.tailPK, nil)
-
- // reached
- // end.
- break
- }
-
- // Drop bottom-most item from timeline.
- item := (*timeline_item)(bottom.data)
- t.delete(item)
- }
-
- case Desc:
- // Iterate over 'diff' items
- // from top of timeline list.
- for range diff {
-
- // Get top list elem.
- top := t.list.head
- if top == nil {
-
- // Zero head + tail primary keys.
- atomic.StorePointer(&t.headPK, nil)
- atomic.StorePointer(&t.tailPK, nil)
-
- // reached
- // end.
- break
- }
-
- // Drop top-most item from timeline.
- item := (*timeline_item)(top.data)
- t.delete(item)
- }
- }
-
- // Compact index data stores.
- for _, idx := range t.indices {
- (&idx).data.Compact()
- }
-
- // Done with lock.
- t.mutex.Unlock()
-}
-
-// Clear empties the timeline by calling .TrimBottom(0, Down).
-func (t *Timeline[T, PK]) Clear() { t.Trim(0, Desc) }
-
-// Len returns the current length of cache.
-func (t *Timeline[T, PK]) Len() int {
- t.mutex.Lock()
- l := t.list.len
- t.mutex.Unlock()
- return l
-}
-
-// Debug returns debug stats about cache.
-func (t *Timeline[T, PK]) Debug() map[string]any {
- m := make(map[string]any, 2)
- t.mutex.Lock()
- m["list"] = t.list.len
- indices := make(map[string]any, len(t.indices))
- m["indices"] = indices
- for _, idx := range t.indices {
- var n uint64
- for _, l := range idx.data.m {
- n += uint64(l.len)
- }
- indices[idx.name] = n
- }
- t.mutex.Unlock()
- return m
-}
-
-func (t *Timeline[T, PK]) select_asc(min PK, max *PK, length *int) (values []T) {
- // Iterate through linked list
- // from bottom (i.e. tail), asc.
- prev := t.list.tail
-
- // Iterate from 'prev' up, skipping all
- // entries with pkey below cursor 'min'.
- for ; prev != nil; prev = prev.prev {
- item := (*timeline_item)(prev.data)
- pkey := *(*PK)(item.pk)
-
- // Check below min.
- if pkey <= min {
- continue
- }
-
- // Reached
- // cursor.
- break
- }
-
- if prev == nil {
- // No values
- // remaining.
- return
- }
-
- // Optimized switch case to handle
- // each set of argument combinations
- // separately, in order to minimize
- // number of checks during loops.
- switch {
-
- case length != nil && max != nil:
- // Deref arguments.
- length := *length
- max := *max
-
- // Optimistic preallocate slice.
- values = make([]T, 0, length)
-
- // Both a length and maximum were given,
- // select from cursor until either reached.
- for ; prev != nil; prev = prev.prev {
- item := (*timeline_item)(prev.data)
- pkey := *(*PK)(item.pk)
-
- // Check above max.
- if pkey >= max {
- break
- }
-
- // Append value copy.
- value := item.data.(T)
- value = t.copy(value)
- values = append(values, value)
-
- // Check if length reached.
- if len(values) >= length {
- break
- }
- }
-
- case length != nil:
- // Deref length.
- length := *length
-
- // Optimistic preallocate slice.
- values = make([]T, 0, length)
-
- // Only a length was given, select
- // from cursor until length reached.
- for ; prev != nil; prev = prev.prev {
- item := (*timeline_item)(prev.data)
-
- // Append value copy.
- value := item.data.(T)
- value = t.copy(value)
- values = append(values, value)
-
- // Check if length reached.
- if len(values) >= length {
- break
- }
- }
-
- case max != nil:
- // Deref min.
- max := *max
-
- // Only a maximum was given, select
- // from cursor until max is reached.
- for ; prev != nil; prev = prev.prev {
- item := (*timeline_item)(prev.data)
- pkey := *(*PK)(item.pk)
-
- // Check above max.
- if pkey >= max {
- break
- }
-
- // Append value copy.
- value := item.data.(T)
- value = t.copy(value)
- values = append(values, value)
- }
-
- default:
- // No maximum or length were given,
- // ALL from cursor need selecting.
- for ; prev != nil; prev = prev.prev {
- item := (*timeline_item)(prev.data)
-
- // Append value copy.
- value := item.data.(T)
- value = t.copy(value)
- values = append(values, value)
- }
- }
-
- return
-}
-
-func (t *Timeline[T, PK]) select_desc(min *PK, max PK, length *int) (values []T) {
- // Iterate through linked list
- // from top (i.e. head), desc.
- next := t.list.head
-
- // Iterate from 'next' down, skipping
- // all entries with pkey above cursor 'max'.
- for ; next != nil; next = next.next {
- item := (*timeline_item)(next.data)
- pkey := *(*PK)(item.pk)
-
- // Check above max.
- if pkey >= max {
- continue
- }
-
- // Reached
- // cursor.
- break
- }
-
- if next == nil {
- // No values
- // remaining.
- return
- }
-
- // Optimized switch case to handle
- // each set of argument combinations
- // separately, in order to minimize
- // number of checks during loops.
- switch {
-
- case length != nil && min != nil:
- // Deref arguments.
- length := *length
- min := *min
-
- // Optimistic preallocate slice.
- values = make([]T, 0, length)
-
- // Both a length and minimum were given,
- // select from cursor until either reached.
- for ; next != nil; next = next.next {
- item := (*timeline_item)(next.data)
- pkey := *(*PK)(item.pk)
-
- // Check below min.
- if pkey <= min {
- break
- }
-
- // Append value copy.
- value := item.data.(T)
- value = t.copy(value)
- values = append(values, value)
-
- // Check if length reached.
- if len(values) >= length {
- break
- }
- }
-
- case length != nil:
- // Deref length.
- length := *length
-
- // Optimistic preallocate slice.
- values = make([]T, 0, length)
-
- // Only a length was given, select
- // from cursor until length reached.
- for ; next != nil; next = next.next {
- item := (*timeline_item)(next.data)
-
- // Append value copy.
- value := item.data.(T)
- value = t.copy(value)
- values = append(values, value)
-
- // Check if length reached.
- if len(values) >= length {
- break
- }
- }
-
- case min != nil:
- // Deref min.
- min := *min
-
- // Only a minimum was given, select
- // from cursor until minimum reached.
- for ; next != nil; next = next.next {
- item := (*timeline_item)(next.data)
- pkey := *(*PK)(item.pk)
-
- // Check below min.
- if pkey <= min {
- break
- }
-
- // Append value copy.
- value := item.data.(T)
- value = t.copy(value)
- values = append(values, value)
- }
-
- default:
- // No minimum or length were given,
- // ALL from cursor need selecting.
- for ; next != nil; next = next.next {
- item := (*timeline_item)(next.data)
-
- // Append value copy.
- value := item.data.(T)
- value = t.copy(value)
- values = append(values, value)
- }
- }
-
- return
-}
-
-// value_with_pk wraps an incoming value type, with
-// its extracted primary key, and pointers to both.
-// this encompasses all arguments related to a value
-// required by store_one(), simplifying some logic.
-//
-// with all the primary keys extracted, it also
-// makes it much easier to sort input before insert.
-type value_with_pk[T any, PK comparable] struct {
- k PK // primary key value
- v T // value copy
-
- kptr unsafe.Pointer // primary key ptr
- vptr unsafe.Pointer // value copy ptr
-}
-
-func (t *Timeline[T, PK]) store_one(last *list_elem, value value_with_pk[T, PK]) *list_elem {
- // NOTE: the value passed here should
- // already be a copy of the original.
-
- // Alloc new index item.
- t_item := new_timeline_item()
- if cap(t_item.indexed) < len(t.indices) {
-
- // Preallocate item indices slice to prevent Go auto
- // allocating overlying large slices we don't need.
- t_item.indexed = make([]*index_entry, 0, len(t.indices))
- }
-
- // Set item value data.
- t_item.data = value.v
- t_item.pk = value.kptr
-
- // Get zero'th index, i.e.
- // the primary key index.
- idx0 := (&t.indices[0])
-
- // Acquire key buf.
- buf := new_buffer()
-
- // Calculate index key from already extracted
- // primary key, checking for zero return value.
- partptrs := []unsafe.Pointer{value.kptr}
- key := idx0.key(buf, partptrs)
- if key == "" { // i.e. (!allow_zero && pkey == zero)
- free_timeline_item(t_item)
- free_buffer(buf)
- return last
- }
-
- // Convert to indexed_item pointer.
- i_item := from_timeline_item(t_item)
-
- if last == nil {
- // No previous element was provided, this is
- // first insert, we need to work from head.
-
- // Check for emtpy head.
- if t.list.head == nil {
-
- // The easiest case, this will
- // be the first item in list.
- t.list.push_front(&t_item.elem)
- last = t.list.head // return value
- goto indexing
- }
-
- // Extract head item and its primary key.
- headItem := (*timeline_item)(t.list.head.data)
- headPK := *(*PK)(headItem.pk)
- if value.k > headPK {
-
- // Another easier case, this also
- // will be the first item in list.
- t.list.push_front(&t_item.elem)
- last = t.list.head // return value
- goto indexing
- }
-
- // Check (and drop) if pkey is a collision!
- if value.k == headPK && is_unique(idx0.flags) {
- free_timeline_item(t_item)
- free_buffer(buf)
- return t.list.head
- }
-
- // Set last = head.next
- // as next to work from.
- last = t.list.head.next
- }
-
- // Iterate through list from head
- // to find location. Optimized into two
- // cases to minimize loop CPU cycles.
- if is_unique(idx0.flags) {
- for next := last; //
- next != nil; next = next.next {
-
- // Extract item and it's primary key.
- nextItem := (*timeline_item)(next.data)
- nextPK := *(*PK)(nextItem.pk)
-
- // If pkey smaller than
- // cursor's, keep going.
- if value.k < nextPK {
- continue
- }
-
- // Check (and drop) if
- // pkey is a collision!
- if value.k == nextPK {
- free_timeline_item(t_item)
- free_buffer(buf)
- return next
- }
-
- // New pkey is larger than cursor,
- // insert into list just before it.
- t.list.insert(&t_item.elem, next.prev)
- last = next // return value
- goto indexing
- }
- } else {
- for next := last; //
- next != nil; next = next.next {
-
- // Extract item and it's primary key.
- nextItem := (*timeline_item)(next.data)
- nextPK := *(*PK)(nextItem.pk)
-
- // If pkey smaller than
- // cursor's, keep going.
- if value.k < nextPK {
- continue
- }
-
- // New pkey is larger than cursor,
- // insert into list just before it.
- t.list.insert(&t_item.elem, next.prev)
- last = next // return value
- goto indexing
- }
- }
-
- // We reached the end of the
- // list, insert at tail pos.
- t.list.push_back(&t_item.elem)
- last = t.list.tail // return value
- goto indexing
-
-indexing:
- // Set new head / tail
- // primary key values.
- switch last {
- case t.list.head:
- atomic.StorePointer(&t.headPK, value.kptr)
- case t.list.tail:
- atomic.StorePointer(&t.tailPK, value.kptr)
- }
-
- // Append already-extracted
- // primary key to 0th index.
- _ = idx0.add(key, i_item)
-
- // Insert item into each of indices.
- for i := 1; i < len(t.indices); i++ {
-
- // Get current index ptr.
- idx := (&t.indices[i])
-
- // Extract fields comprising index key from value.
- parts := extract_fields(value.vptr, idx.fields)
-
- // Calculate this index key,
- // checking for zero values.
- key := idx.key(buf, parts)
- if key == "" {
- continue
- }
-
- // Add this item to index,
- // checking for collisions.
- if !idx.add(key, i_item) {
-
- // This key already appears
- // in this unique index. So
- // drop new timeline item.
- t.delete(t_item)
- free_buffer(buf)
- return last
- }
- }
-
- // Done with bufs.
- free_buffer(buf)
- return last
-}
-
-func (t *Timeline[T, PK]) delete(i *timeline_item) {
- for len(i.indexed) > 0 {
- // Pop last indexed entry from list.
- entry := i.indexed[len(i.indexed)-1]
- i.indexed[len(i.indexed)-1] = nil
- i.indexed = i.indexed[:len(i.indexed)-1]
-
- // Get entry's index.
- index := entry.index
-
- // Drop this index_entry.
- index.delete_entry(entry)
- }
-
- // Drop from main list.
- t.list.remove(&i.elem)
-
- // Free unused item.
- free_timeline_item(i)
-}
-
-type timeline_item struct {
- indexed_item
-
- // retains fast ptr access
- // to primary key value of
- // above indexed_item{}.data
- pk unsafe.Pointer
-
- // check bits always all set
- // to 1. used to ensure cast
- // from indexed_item to this
- // type was originally a
- // timeline_item to begin with.
- ck uint
-}
-
-func init() {
- // ensure the embedded indexed_item struct is ALWAYS at zero offset.
- // we rely on this to allow a ptr to one to be a ptr to either of them.
- const off = unsafe.Offsetof(timeline_item{}.indexed_item)
- if off != 0 {
- panic(assert("offset_of(timeline_item{}.indexed_item) = 0"))
- }
-}
-
-// from_timeline_item converts a timeline_item ptr to indexed_item, given the above init() guarantee.
-func from_timeline_item(item *timeline_item) *indexed_item {
- return (*indexed_item)(unsafe.Pointer(item))
-}
-
-// to_timeline_item converts an indexed_item ptr to timeline_item, given the above init() guarantee.
-// NOTE THIS MUST BE AN indexed_item THAT WAS INITIALLY CONVERTED WITH from_timeline_item().
-func to_timeline_item(item *indexed_item) *timeline_item {
- to := (*timeline_item)(unsafe.Pointer(item))
- if to.ck != ^uint(0) {
- // ensure check bits set, indicating
- // it was a timeline_item originally.
- panic(assert("t.ck = ^uint(0)"))
- }
- return to
-}
-
-var timeline_item_pool mempool.UnsafePool
-
-// new_timeline_item returns a new prepared timeline_item.
-func new_timeline_item() *timeline_item {
- if ptr := timeline_item_pool.Get(); ptr != nil {
- return (*timeline_item)(ptr)
- }
- item := new(timeline_item)
- item.elem.data = unsafe.Pointer(item)
- item.ck = ^uint(0)
- return item
-}
-
-// free_timeline_item releases the timeline_item.
-func free_timeline_item(item *timeline_item) {
- if len(item.indexed) > 0 ||
- item.elem.next != nil ||
- item.elem.prev != nil {
- msg := assert("item not in use")
- os.Stderr.WriteString(msg + "\n")
- return
- }
- item.data = nil
- item.pk = nil
- ptr := unsafe.Pointer(item)
- timeline_item_pool.Put(ptr)
-}
diff --git a/vendor/codeberg.org/gruf/go-xunsafe/LICENSE b/vendor/codeberg.org/gruf/go-xunsafe/LICENSE
deleted file mode 100644
index d6f08d0ab..000000000
--- a/vendor/codeberg.org/gruf/go-xunsafe/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 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-xunsafe/README.md b/vendor/codeberg.org/gruf/go-xunsafe/README.md
deleted file mode 100644
index 9c8031e17..000000000
--- a/vendor/codeberg.org/gruf/go-xunsafe/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-xunsafe
-
-xunafe as in EXTRA UNSAFE. this exposes reflect and internal ABI package data structures in a manner that is kept up-to-date and version gated by the compile-time Go version. This package performs no validity checks on the data you provide to it, it is expected that you know what you are doing. Not to mention that some of the internal ABI data must only be exposed VERY carefully given that it is in non garbage-collected memory.
diff --git a/vendor/codeberg.org/gruf/go-xunsafe/abi.go b/vendor/codeberg.org/gruf/go-xunsafe/abi.go
deleted file mode 100644
index d492f5681..000000000
--- a/vendor/codeberg.org/gruf/go-xunsafe/abi.go
+++ /dev/null
@@ -1,109 +0,0 @@
-//go:build go1.24 && !go1.26
-
-package xunsafe
-
-import (
- "reflect"
- "unsafe"
-)
-
-func init() {
- // TypeOf(reflect.Type{}) == *struct{ abi.Type{} }
- t := reflect.TypeOf(reflect.TypeOf(0)).Elem()
- if t.Size() != unsafe.Sizeof(Abi_Type{}) {
- panic("Abi_Type{} not in sync with abi.Type{}")
- }
-}
-
-const (
- // see: go/src/internal/abi/type.go
- Abi_KindDirectIface uint8 = 1 << 5
- Abi_KindMask uint8 = (1 << 5) - 1
-)
-
-// Abi_Type is a copy of the memory layout of abi.Type{}.
-//
-// see: go/src/internal/abi/type.go
-type Abi_Type struct {
- _ uintptr
- PtrBytes uintptr
- _ uint32
- _ uint8
- _ uint8
- _ uint8
- Kind_ uint8
- _ func(unsafe.Pointer, unsafe.Pointer) bool
- _ *byte
- _ int32
- _ int32
-}
-
-// Abi_EmptyInterface is a copy of the memory layout of abi.EmptyInterface{},
-// which is to say also the memory layout of any method-less interface.
-//
-// see: go/src/internal/abi/iface.go
-type Abi_EmptyInterface struct {
- Type *Abi_Type
- Data unsafe.Pointer
-}
-
-// Abi_NonEmptyInterface is a copy of the memory layout of abi.NonEmptyInterface{},
-// which is to say also the memory layout of any interface containing method(s).
-//
-// see: go/src/internal/abi/iface.go on 1.25+
-// see: go/src/reflect/value.go on 1.24
-type Abi_NonEmptyInterface struct {
- ITab uintptr
- Data unsafe.Pointer
-}
-
-// see: go/src/internal/abi/type.go Type.Kind()
-func Abi_Type_Kind(t reflect.Type) uint8 {
- iface := (*Abi_NonEmptyInterface)(unsafe.Pointer(&t))
- atype := (*Abi_Type)(unsafe.Pointer(iface.Data))
- return atype.Kind_ & Abi_KindMask
-}
-
-// see: go/src/internal/abi/type.go Type.IfaceIndir()
-func Abi_Type_IfaceIndir(t reflect.Type) bool {
- iface := (*Abi_NonEmptyInterface)(unsafe.Pointer(&t))
- atype := (*Abi_Type)(unsafe.Pointer(iface.Data))
- return atype.Kind_&Abi_KindDirectIface == 0
-}
-
-// PackIface packs a new reflect.nonEmptyInterface{} using shielded
-// itab and data pointer, returning a pointer for caller casting.
-func PackIface(itab uintptr, word unsafe.Pointer) unsafe.Pointer {
- return unsafe.Pointer(&Abi_NonEmptyInterface{
- ITab: itab,
- Data: word,
- })
-}
-
-// GetIfaceITab generates a new value of given type,
-// casts it to the generic param interface type, and
-// returns the .itab portion of the abi.NonEmptyInterface{}.
-// this is useful for later calls to PackIface for known type.
-func GetIfaceITab[I any](t reflect.Type) uintptr {
- s := reflect.New(t).Elem().Interface().(I)
- i := (*Abi_NonEmptyInterface)(unsafe.Pointer(&s))
- return i.ITab
-}
-
-// UnpackEface returns the .Data portion of an abi.EmptyInterface{}.
-func UnpackEface(a any) unsafe.Pointer {
- return (*Abi_EmptyInterface)(unsafe.Pointer((&a))).Data
-}
-
-// see: go/src/internal/unsafeheader/unsafeheader.go
-type Unsafeheader_Slice struct {
- Data unsafe.Pointer
- Len int
- Cap int
-}
-
-// see: go/src/internal/unsafeheader/unsafeheader.go
-type Unsafeheader_String struct {
- Data unsafe.Pointer
- Len int
-}
diff --git a/vendor/codeberg.org/gruf/go-xunsafe/reflect.go b/vendor/codeberg.org/gruf/go-xunsafe/reflect.go
deleted file mode 100644
index de40b2c89..000000000
--- a/vendor/codeberg.org/gruf/go-xunsafe/reflect.go
+++ /dev/null
@@ -1,157 +0,0 @@
-//go:build go1.24 && !go1.26
-
-package xunsafe
-
-import (
- "reflect"
- "unsafe"
-)
-
-// see: go/src/reflect/value.go
-type Reflect_flag uintptr
-
-const (
- // see: go/src/reflect/value.go
- Reflect_flagKindWidth = 5 // there are 27 kinds
- Reflect_flagKindMask Reflect_flag = 1<<Reflect_flagKindWidth - 1
- Reflect_flagStickyRO Reflect_flag = 1 << 5
- Reflect_flagEmbedRO Reflect_flag = 1 << 6
- Reflect_flagIndir Reflect_flag = 1 << 7
- Reflect_flagAddr Reflect_flag = 1 << 8
- Reflect_flagMethod Reflect_flag = 1 << 9
- Reflect_flagMethodShift = 10
- Reflect_flagRO Reflect_flag = Reflect_flagStickyRO | Reflect_flagEmbedRO
-)
-
-// ReflectIfaceElemFlags returns the reflect_flag expected of an unboxed interface element of type.
-//
-// see: go/src/reflect/value.go unpackElem()
-func ReflectIfaceElemFlags(elemType reflect.Type) Reflect_flag {
- if elemType == nil {
- return 0
- }
- flags := Reflect_flag(Abi_Type_Kind(elemType))
- if Abi_Type_IfaceIndir(elemType) {
- flags |= Reflect_flagIndir
- }
- return flags
-}
-
-// ReflectPointerElemFlags returns the reflect_flag expected of a dereferenced pointer element of type.
-//
-// see: go/src/reflect/value.go Value.Elem()
-func ReflectPointerElemFlags(ptrFlags Reflect_flag, elemType reflect.Type) Reflect_flag {
- return ptrFlags | Reflect_flagIndir | Reflect_flagAddr | Reflect_flag(Abi_Type_Kind(elemType))
-}
-
-// ReflectArrayElemFlags returns the reflect_flag expected of an element of type in an array.
-//
-// see: go/src/reflect/value.go Value.Index()
-func ReflectArrayElemFlags(arrayFlags Reflect_flag, elemType reflect.Type) Reflect_flag {
- return arrayFlags&(Reflect_flagIndir|Reflect_flagAddr) | Reflect_flag(Abi_Type_Kind(elemType))
-}
-
-// reflect_slice_elem_flags returns the reflect_flag expected of a slice element of type.
-//
-// see: go/src/reflect/value.go Value.Index()
-func ReflectSliceElemFlags(elemType reflect.Type) Reflect_flag {
- return Reflect_flagAddr | Reflect_flagIndir | Reflect_flag(Abi_Type_Kind(elemType))
-}
-
-// ReflectStructFieldFlags returns the reflect_flag expected of a struct field of type.
-//
-// see: go/src/reflect/value.go Value.Field()
-func ReflectStructFieldFlags(structFlags Reflect_flag, fieldType reflect.Type) Reflect_flag {
- return structFlags&(Reflect_flagIndir|Reflect_flagAddr) | Reflect_flag(Abi_Type_Kind(fieldType))
-}
-
-// ReflectMapKeyFlags returns the reflect_flag expected of a map key of type.
-//
-// see: go/src/reflect/map_swiss.go MapIter.Key()
-func ReflectMapKeyFlags(keyType reflect.Type) Reflect_flag {
- return Reflect_flag(Abi_Type_Kind(keyType))
-}
-
-// ReflectMapElemFlags returns the reflect_flag expected of a map element of type.
-//
-// see: go/src/reflect/map_swiss.go MapIter.Value()
-func ReflectMapElemFlags(elemType reflect.Type) Reflect_flag {
- return Reflect_flag(Abi_Type_Kind(elemType))
-}
-
-// reflect_Value is a copy of the memory layout of reflect.Value{}.
-//
-// see: go/src/reflect/value.go
-type reflect_Value struct {
- typ_ unsafe.Pointer
- ptr unsafe.Pointer
- Reflect_flag
-}
-
-func init() {
- if unsafe.Sizeof(reflect_Value{}) != unsafe.Sizeof(reflect.Value{}) {
- panic("reflect_Value{} not in sync with reflect.Value{}")
- }
-}
-
-// reflect_type_data returns the .word from the reflect.Type{} cast
-// as the reflect.nonEmptyInterface{}, which itself will be a pointer
-// to the actual abi.Type{} that this reflect.Type{} is wrapping.
-func ReflectTypeData(t reflect.Type) unsafe.Pointer {
- return (*Abi_NonEmptyInterface)(unsafe.Pointer(&t)).Data
-}
-
-// BuildReflectValue manually builds a reflect.Value{} by setting the internal field members.
-func BuildReflectValue(rtype reflect.Type, data unsafe.Pointer, flags Reflect_flag) reflect.Value {
- return *(*reflect.Value)(unsafe.Pointer(&reflect_Value{ReflectTypeData(rtype), data, flags}))
-}
-
-// Reflect_MapIter is a copy of the memory layout of reflect.MapIter{}.
-//
-// see: go/src/reflect/map_swiss.go
-type Reflect_MapIter struct {
- m reflect.Value
- hiter maps_Iter
-}
-
-// maps_Iter is a copy of the memory layout of maps.Iter{}.
-//
-// see: go/src/internal/runtime/maps/table.go
-type maps_Iter struct {
- key unsafe.Pointer
- elem unsafe.Pointer
- _ uintptr
- _ uintptr
- _ uint64
- _ uint64
- _ uint64
- _ uint8
- _ int
- _ uintptr
- _ struct{ _ unsafe.Pointer }
- _ uint64
-}
-
-func init() {
- if unsafe.Sizeof(Reflect_MapIter{}) != unsafe.Sizeof(reflect.MapIter{}) {
- panic("Reflect_MapIter{} not in sync with reflect.MapIter{}")
- }
-}
-
-// GetMapIter creates a new map iterator from value,
-// skipping the initial v.MapRange() type checking.
-func GetMapIter(v reflect.Value) *reflect.MapIter {
- var i Reflect_MapIter
- i.m = v
- return (*reflect.MapIter)(unsafe.Pointer(&i))
-}
-
-// Map_Key returns ptr to current map key in iter.
-func Map_Key(i *reflect.MapIter) unsafe.Pointer {
- return (*Reflect_MapIter)(unsafe.Pointer(i)).hiter.key
-}
-
-// Map_Elem returns ptr to current map element in iter.
-func Map_Elem(i *reflect.MapIter) unsafe.Pointer {
- return (*Reflect_MapIter)(unsafe.Pointer(i)).hiter.elem
-}
diff --git a/vendor/codeberg.org/gruf/go-xunsafe/types.go b/vendor/codeberg.org/gruf/go-xunsafe/types.go
deleted file mode 100644
index b17603543..000000000
--- a/vendor/codeberg.org/gruf/go-xunsafe/types.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package xunsafe
-
-import "reflect"
-
-// TypeIter provides a simple wrapper for
-// a means of following reflected types.
-type TypeIter struct {
- TypeInfo
- Parent *TypeIter
-}
-
-// TypeInfo wraps reflect type information
-// along with flags specifying further details
-// necessary due to type nesting.
-type TypeInfo struct {
- Type reflect.Type
- Flag Reflect_flag
-}
-
-// ToTypeIter creates a new TypeIter{} from reflect type and flags.
-func ToTypeIter(rtype reflect.Type, flags Reflect_flag) TypeIter {
- return TypeIter{TypeInfo: TypeInfo{rtype, flags}}
-}
-
-// TypeIterFrom creates new TypeIter from interface value type.
-// Note this will always assume the initial value passed to you
-// will be coming from an interface.
-func TypeIterFrom(a any) TypeIter {
- rtype := reflect.TypeOf(a)
- flags := ReflectIfaceElemFlags(rtype)
- return ToTypeIter(rtype, flags)
-}
-
-// Indirect returns whether Reflect_flagIndir is set on receiving TypeInfo{}.Flag.
-func (t TypeInfo) Indirect() bool {
- return t.Flag&Reflect_flagIndir != 0
-}
-
-// IfaceIndir calls Abi_Type_IfaceIndir() on receiving TypeInfo{}.Type.
-func (t TypeInfo) IfaceIndir() bool {
- return Abi_Type_IfaceIndir(t.Type)
-}
-
-// Child returns a new TypeIter{} for given type and flags, with parent pointing to receiver.
-func (i TypeIter) Child(rtype reflect.Type, flags Reflect_flag) TypeIter {
- child := ToTypeIter(rtype, flags)
- child.Parent = &i
- return child
-}