summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/codeberg.org')
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/README.md12
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/buffer.go131
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/bytes.go261
-rw-r--r--vendor/codeberg.org/gruf/go-bytes/bytesconv_table.go11
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/README.md1
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/bytesize.go369
-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-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.go326
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/LICENSE674
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpreg.wasm.gzbin8255440 -> 0 bytes
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/embed/lib.go39
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/wasm/funcs.go74
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/wasm/run.go87
-rw-r--r--vendor/codeberg.org/gruf/go-ffmpreg/wasm/runtime.go67
-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-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/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/README.md31
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/helpers.go200
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/load.go223
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/mangle.go130
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/manglers.go113
-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.go99
-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.go235
-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.go64
-rw-r--r--vendor/codeberg.org/gruf/go-runners/pool.go292
-rw-r--r--vendor/codeberg.org/gruf/go-runners/process.go81
-rw-r--r--vendor/codeberg.org/gruf/go-runners/service.go217
-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.go143
-rw-r--r--vendor/codeberg.org/gruf/go-sched/scheduler.go290
-rw-r--r--vendor/codeberg.org/gruf/go-sched/timing.go92
-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/errors.go21
-rw-r--r--vendor/codeberg.org/gruf/go-storage/s3/s3.go470
-rw-r--r--vendor/codeberg.org/gruf/go-storage/storage.go73
-rw-r--r--vendor/codeberg.org/gruf/go-storage/test.sh29
-rw-r--r--vendor/codeberg.org/gruf/go-structr/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-structr/README.md143
-rw-r--r--vendor/codeberg.org/gruf/go-structr/cache.go675
-rw-r--r--vendor/codeberg.org/gruf/go-structr/index.go433
-rw-r--r--vendor/codeberg.org/gruf/go-structr/item.go63
-rw-r--r--vendor/codeberg.org/gruf/go-structr/key.go58
-rw-r--r--vendor/codeberg.org/gruf/go-structr/list.go151
-rw-r--r--vendor/codeberg.org/gruf/go-structr/map.go58
-rw-r--r--vendor/codeberg.org/gruf/go-structr/ordered_list.bak180
-rw-r--r--vendor/codeberg.org/gruf/go-structr/queue.go342
-rw-r--r--vendor/codeberg.org/gruf/go-structr/queue_ctx.go152
-rw-r--r--vendor/codeberg.org/gruf/go-structr/runtime.go216
-rw-r--r--vendor/codeberg.org/gruf/go-structr/test.sh5
-rw-r--r--vendor/codeberg.org/gruf/go-structr/util.go13
-rw-r--r--vendor/codeberg.org/superseriousbusiness/exif-terminator/LICENSE661
-rw-r--r--vendor/codeberg.org/superseriousbusiness/exif-terminator/README.md122
-rw-r--r--vendor/codeberg.org/superseriousbusiness/exif-terminator/exif.go53
-rw-r--r--vendor/codeberg.org/superseriousbusiness/exif-terminator/jpeg.go132
-rw-r--r--vendor/codeberg.org/superseriousbusiness/exif-terminator/png.go85
-rw-r--r--vendor/codeberg.org/superseriousbusiness/exif-terminator/terminator.go146
-rw-r--r--vendor/codeberg.org/superseriousbusiness/exif-terminator/webp.go109
140 files changed, 0 insertions, 16509 deletions
diff --git a/vendor/codeberg.org/gruf/go-bytes/LICENSE b/vendor/codeberg.org/gruf/go-bytes/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-bytes/README.md b/vendor/codeberg.org/gruf/go-bytes/README.md
deleted file mode 100644
index fbdf99798..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-drop-in replacement for standard "bytes" library
-
-contains alternative Buffer implementation that provides direct access to the
-underlying byte-slice, with some interesting alternative struct methods. provides
-no safety guards, if you pass bad values it will blow up in your face...
-
-and alternative `ToUpper()` and `ToLower()` implementations that use lookup
-tables for improved performance
-
-provides direct call-throughs to most of the "bytes" library functions to facilitate
-this being a direct drop-in. in some time, i may offer alternative implementations
-for other functions too \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-bytes/buffer.go b/vendor/codeberg.org/gruf/go-bytes/buffer.go
deleted file mode 100644
index 5c3b2cb5b..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/buffer.go
+++ /dev/null
@@ -1,131 +0,0 @@
-package bytes
-
-import (
- "unicode/utf8"
-)
-
-// Buffer is a very simple buffer implementation that allows
-// access to and reslicing of the underlying byte slice.
-type Buffer struct {
- B []byte
-}
-
-func NewBuffer(b []byte) Buffer {
- return Buffer{
- B: b,
- }
-}
-
-func (b *Buffer) Write(p []byte) (int, error) {
- b.Grow(len(p))
- return copy(b.B[b.Len()-len(p):], p), nil
-}
-
-func (b *Buffer) WriteString(s string) (int, error) {
- b.Grow(len(s))
- return copy(b.B[b.Len()-len(s):], s), nil
-}
-
-func (b *Buffer) WriteByte(c byte) error {
- l := b.Len()
- b.Grow(1)
- b.B[l] = c
- return nil
-}
-
-func (b *Buffer) WriteRune(r rune) (int, error) {
- if r < utf8.RuneSelf {
- b.WriteByte(byte(r))
- return 1, nil
- }
-
- l := b.Len()
- b.Grow(utf8.UTFMax)
- n := utf8.EncodeRune(b.B[l:b.Len()], r)
- b.B = b.B[:l+n]
-
- return n, nil
-}
-
-func (b *Buffer) WriteAt(p []byte, start int64) (int, error) {
- b.Grow(len(p) - int(int64(b.Len())-start))
- return copy(b.B[start:], p), nil
-}
-
-func (b *Buffer) WriteStringAt(s string, start int64) (int, error) {
- b.Grow(len(s) - int(int64(b.Len())-start))
- return copy(b.B[start:], s), nil
-}
-
-func (b *Buffer) Truncate(size int) {
- b.B = b.B[:b.Len()-size]
-}
-
-func (b *Buffer) ShiftByte(index int) {
- copy(b.B[index:], b.B[index+1:])
-}
-
-func (b *Buffer) Shift(start int64, size int) {
- copy(b.B[start:], b.B[start+int64(size):])
-}
-
-func (b *Buffer) DeleteByte(index int) {
- b.ShiftByte(index)
- b.Truncate(1)
-}
-
-func (b *Buffer) Delete(start int64, size int) {
- b.Shift(start, size)
- b.Truncate(size)
-}
-
-func (b *Buffer) InsertByte(index int64, c byte) {
- l := b.Len()
- b.Grow(1)
- copy(b.B[index+1:], b.B[index:l])
- b.B[index] = c
-}
-
-func (b *Buffer) Insert(index int64, p []byte) {
- l := b.Len()
- b.Grow(len(p))
- copy(b.B[index+int64(len(p)):], b.B[index:l])
- copy(b.B[index:], p)
-}
-
-func (b *Buffer) Bytes() []byte {
- return b.B
-}
-
-func (b *Buffer) String() string {
- return string(b.B)
-}
-
-func (b *Buffer) StringPtr() string {
- return BytesToString(b.B)
-}
-
-func (b *Buffer) Cap() int {
- return cap(b.B)
-}
-
-func (b *Buffer) Len() int {
- return len(b.B)
-}
-
-func (b *Buffer) Reset() {
- b.B = b.B[:0]
-}
-
-func (b *Buffer) Grow(size int) {
- b.Guarantee(size)
- b.B = b.B[:b.Len()+size]
-}
-
-func (b *Buffer) Guarantee(size int) {
- if size > b.Cap()-b.Len() {
- nb := make([]byte, 2*b.Cap()+size)
- copy(nb, b.B)
- b.B = nb[:b.Len()]
- }
-}
diff --git a/vendor/codeberg.org/gruf/go-bytes/bytes.go b/vendor/codeberg.org/gruf/go-bytes/bytes.go
deleted file mode 100644
index 5fef75d56..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/bytes.go
+++ /dev/null
@@ -1,261 +0,0 @@
-package bytes
-
-import (
- "bytes"
- "reflect"
- "unsafe"
-)
-
-var (
- _ Bytes = &Buffer{}
- _ Bytes = bytesType{}
-)
-
-// Bytes defines a standard way of retrieving the content of a
-// byte buffer of some-kind.
-type Bytes interface {
- // Bytes returns the byte slice content
- Bytes() []byte
-
- // String returns byte slice cast directly to string, this
- // will cause an allocation but comes with the safety of
- // being an immutable Go string
- String() string
-
- // StringPtr returns byte slice cast to string via the unsafe
- // package. This comes with the same caveats of accessing via
- // .Bytes() in that the content is liable change and is NOT
- // immutable, despite being a string type
- StringPtr() string
-}
-
-type bytesType []byte
-
-func (b bytesType) Bytes() []byte {
- return b
-}
-
-func (b bytesType) String() string {
- return string(b)
-}
-
-func (b bytesType) StringPtr() string {
- return BytesToString(b)
-}
-
-// ToBytes casts the provided byte slice as the simplest possible
-// Bytes interface implementation
-func ToBytes(b []byte) Bytes {
- return bytesType(b)
-}
-
-// Copy returns a new copy of slice b, does NOT maintain nil values
-func Copy(b []byte) []byte {
- p := make([]byte, len(b))
- copy(p, b)
- return p
-}
-
-// BytesToString returns byte slice cast to string via the "unsafe" package
-func BytesToString(b []byte) string {
- return *(*string)(unsafe.Pointer(&b))
-}
-
-// StringToBytes returns the string cast to string via the "unsafe" and "reflect" packages
-func StringToBytes(s string) []byte {
- // thank you to https://github.com/valyala/fasthttp/blob/master/bytesconv.go
- var b []byte
-
- // Get byte + string headers
- bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
- sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
-
- // Manually set bytes to string
- bh.Data = sh.Data
- bh.Len = sh.Len
- bh.Cap = sh.Len
-
- return b
-}
-
-// // InsertByte inserts the supplied byte into the slice at provided position
-// func InsertByte(b []byte, at int, c byte) []byte {
-// return append(append(b[:at], c), b[at:]...)
-// }
-
-// // Insert inserts the supplied byte slice into the slice at provided position
-// func Insert(b []byte, at int, s []byte) []byte {
-// return append(append(b[:at], s...), b[at:]...)
-// }
-
-// ToUpper offers a faster ToUpper implementation using a lookup table
-func ToUpper(b []byte) {
- for i := 0; i < len(b); i++ {
- c := &b[i]
- *c = toUpperTable[*c]
- }
-}
-
-// ToLower offers a faster ToLower implementation using a lookup table
-func ToLower(b []byte) {
- for i := 0; i < len(b); i++ {
- c := &b[i]
- *c = toLowerTable[*c]
- }
-}
-
-// HasBytePrefix returns whether b has the provided byte prefix
-func HasBytePrefix(b []byte, c byte) bool {
- return (len(b) > 0) && (b[0] == c)
-}
-
-// HasByteSuffix returns whether b has the provided byte suffix
-func HasByteSuffix(b []byte, c byte) bool {
- return (len(b) > 0) && (b[len(b)-1] == c)
-}
-
-// HasBytePrefix returns b without the provided leading byte
-func TrimBytePrefix(b []byte, c byte) []byte {
- if HasBytePrefix(b, c) {
- return b[1:]
- }
- return b
-}
-
-// TrimByteSuffix returns b without the provided trailing byte
-func TrimByteSuffix(b []byte, c byte) []byte {
- if HasByteSuffix(b, c) {
- return b[:len(b)-1]
- }
- return b
-}
-
-// Compare is a direct call-through to standard library bytes.Compare()
-func Compare(b, s []byte) int {
- return bytes.Compare(b, s)
-}
-
-// Contains is a direct call-through to standard library bytes.Contains()
-func Contains(b, s []byte) bool {
- return bytes.Contains(b, s)
-}
-
-// TrimPrefix is a direct call-through to standard library bytes.TrimPrefix()
-func TrimPrefix(b, s []byte) []byte {
- return bytes.TrimPrefix(b, s)
-}
-
-// TrimSuffix is a direct call-through to standard library bytes.TrimSuffix()
-func TrimSuffix(b, s []byte) []byte {
- return bytes.TrimSuffix(b, s)
-}
-
-// Equal is a direct call-through to standard library bytes.Equal()
-func Equal(b, s []byte) bool {
- return bytes.Equal(b, s)
-}
-
-// EqualFold is a direct call-through to standard library bytes.EqualFold()
-func EqualFold(b, s []byte) bool {
- return bytes.EqualFold(b, s)
-}
-
-// Fields is a direct call-through to standard library bytes.Fields()
-func Fields(b []byte) [][]byte {
- return bytes.Fields(b)
-}
-
-// FieldsFunc is a direct call-through to standard library bytes.FieldsFunc()
-func FieldsFunc(b []byte, fn func(rune) bool) [][]byte {
- return bytes.FieldsFunc(b, fn)
-}
-
-// HasPrefix is a direct call-through to standard library bytes.HasPrefix()
-func HasPrefix(b, s []byte) bool {
- return bytes.HasPrefix(b, s)
-}
-
-// HasSuffix is a direct call-through to standard library bytes.HasSuffix()
-func HasSuffix(b, s []byte) bool {
- return bytes.HasSuffix(b, s)
-}
-
-// Index is a direct call-through to standard library bytes.Index()
-func Index(b, s []byte) int {
- return bytes.Index(b, s)
-}
-
-// IndexByte is a direct call-through to standard library bytes.IndexByte()
-func IndexByte(b []byte, c byte) int {
- return bytes.IndexByte(b, c)
-}
-
-// IndexAny is a direct call-through to standard library bytes.IndexAny()
-func IndexAny(b []byte, s string) int {
- return bytes.IndexAny(b, s)
-}
-
-// IndexRune is a direct call-through to standard library bytes.IndexRune()
-func IndexRune(b []byte, r rune) int {
- return bytes.IndexRune(b, r)
-}
-
-// IndexFunc is a direct call-through to standard library bytes.IndexFunc()
-func IndexFunc(b []byte, fn func(rune) bool) int {
- return bytes.IndexFunc(b, fn)
-}
-
-// LastIndex is a direct call-through to standard library bytes.LastIndex()
-func LastIndex(b, s []byte) int {
- return bytes.LastIndex(b, s)
-}
-
-// LastIndexByte is a direct call-through to standard library bytes.LastIndexByte()
-func LastIndexByte(b []byte, c byte) int {
- return bytes.LastIndexByte(b, c)
-}
-
-// LastIndexAny is a direct call-through to standard library bytes.LastIndexAny()
-func LastIndexAny(b []byte, s string) int {
- return bytes.LastIndexAny(b, s)
-}
-
-// LastIndexFunc is a direct call-through to standard library bytes.LastIndexFunc()
-func LastIndexFunc(b []byte, fn func(rune) bool) int {
- return bytes.LastIndexFunc(b, fn)
-}
-
-// Replace is a direct call-through to standard library bytes.Replace()
-func Replace(b, s, r []byte, c int) []byte {
- return bytes.Replace(b, s, r, c)
-}
-
-// ReplaceAll is a direct call-through to standard library bytes.ReplaceAll()
-func ReplaceAll(b, s, r []byte) []byte {
- return bytes.ReplaceAll(b, s, r)
-}
-
-// Split is a direct call-through to standard library bytes.Split()
-func Split(b, s []byte) [][]byte {
- return bytes.Split(b, s)
-}
-
-// SplitAfter is a direct call-through to standard library bytes.SplitAfter()
-func SplitAfter(b, s []byte) [][]byte {
- return bytes.SplitAfter(b, s)
-}
-
-// SplitN is a direct call-through to standard library bytes.SplitN()
-func SplitN(b, s []byte, c int) [][]byte {
- return bytes.SplitN(b, s, c)
-}
-
-// SplitAfterN is a direct call-through to standard library bytes.SplitAfterN()
-func SplitAfterN(b, s []byte, c int) [][]byte {
- return bytes.SplitAfterN(b, s, c)
-}
-
-// NewReader is a direct call-through to standard library bytes.NewReader()
-func NewReader(b []byte) *bytes.Reader {
- return bytes.NewReader(b)
-}
diff --git a/vendor/codeberg.org/gruf/go-bytes/bytesconv_table.go b/vendor/codeberg.org/gruf/go-bytes/bytesconv_table.go
deleted file mode 100644
index 3d3058ada..000000000
--- a/vendor/codeberg.org/gruf/go-bytes/bytesconv_table.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package bytes
-
-// Code generated by go run bytesconv_table_gen.go; DO NOT EDIT.
-// See bytesconv_table_gen.go for more information about these tables.
-//
-// Source: https://github.com/valyala/fasthttp/blob/master/bytes_table_gen.go
-
-const (
- toLowerTable = "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
- toUpperTable = "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~\u007f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
-)
diff --git a/vendor/codeberg.org/gruf/go-bytesize/LICENSE b/vendor/codeberg.org/gruf/go-bytesize/LICENSE
deleted file mode 100644
index b7c4417ac..000000000
--- a/vendor/codeberg.org/gruf/go-bytesize/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2021 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-bytesize/README.md b/vendor/codeberg.org/gruf/go-bytesize/README.md
deleted file mode 100644
index 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 d24ff5f0f..000000000
--- a/vendor/codeberg.org/gruf/go-bytesize/bytesize.go
+++ /dev/null
@@ -1,369 +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
-}
-
-// MarshalText implements encoding.TextMarshaler{}.
-func (sz *Size) MarshalText() ([]byte, error) {
- const maxLen = 7 // max IEC string length
- return sz.AppendFormatIEC(make([]byte, 0, maxLen)), nil
-}
-
-// 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
- } // above is fast-path, .appendFormat() is outlined
- return sz.appendFormat(dst, 1000, &sipows, "B")
-}
-
-// AppendFormatIEC will append IEC formatted size to 'dst'.
-func (sz Size) AppendFormatIEC(dst []byte) []byte {
- if uint64(sz) < 1024 {
- dst = itoa(dst, uint64(sz))
- dst = append(dst, 'B')
- return dst
- } // above is fast-path, .appendFormat() is outlined
- return sz.appendFormat(dst, 1024, &iecpows, "iB")
-}
-
-// appendFormat will append formatted Size to 'dst', depending on base, powers table and single unit suffix.
-func (sz Size) appendFormat(dst []byte, base uint64, pows *[6]float64, sunit string) []byte {
- const (
- // min "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 *= float64(base)
- n--
- }
-
- // Append formatted float with units
- dst = ftoa(dst, f)
- dst = append(dst, units[n-1])
- dst = append(dst, sunit...)
- return dst
-}
-
-// StringSI returns an SI unit string format of Size.
-func (sz Size) StringSI() string {
- 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
-}
-
-// 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 a12b33ab9..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(nil)
- }
- 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-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 42cbfd4f7..000000000
--- a/vendor/codeberg.org/gruf/go-fastpath/v2/path.go
+++ /dev/null
@@ -1,326 +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 *(*string)(unsafe.Pointer(&b.B))
-}
-
-// Absolute returns whether current path is absolute (not relative).
-func (b Builder) Absolute() bool {
- return b.abs
-}
-
-// SetAbsolute converts the current path to-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(*(*string)(unsafe.Pointer(&b)))
-}
-
-// 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 080e1aeca..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 7829b5524..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/embed/lib.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package embed
-
-import (
- "bytes"
- "compress/gzip"
- _ "embed"
- "io"
- "os"
-)
-
-func init() {
- var err error
-
- if path := os.Getenv("FFMPREG_WASM"); path != "" {
- // Read file into memory.
- B, err = os.ReadFile(path)
- if err != nil {
- panic(err)
- }
- }
-
- // Wrap bytes in reader.
- b := bytes.NewReader(B)
-
- // Create unzipper from reader.
- gz, err := gzip.NewReader(b)
- if err != nil {
- panic(err)
- }
-
- // Extract gzipped binary.
- B, err = io.ReadAll(gz)
- if err != nil {
- panic(err)
- }
-}
-
-//go:embed ffmpreg.wasm.gz
-var B []byte
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 a809ff120..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/funcs.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package wasm
-
-import (
- "context"
-
- "github.com/tetratelabs/wazero/api"
- "github.com/tetratelabs/wazero/experimental"
-)
-
-type snapshotskey struct{}
-
-// 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 {
- snapshots := make(map[uint32]experimental.Snapshot, 10)
- ctx = experimental.WithSnapshotter(ctx)
- ctx = context.WithValue(ctx, snapshotskey{}, snapshots)
- return ctx
-}
-
-func getSnapshots(ctx context.Context) map[uint32]experimental.Snapshot {
- v, _ := ctx.Value(snapshotskey{}).(map[uint32]experimental.Snapshot)
- return v
-}
-
-// setjmp implements the C function: setjmp(env jmp_buf)
-func setjmp(ctx context.Context, mod 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)
- if snapshots == nil {
- panic("setjmp / longjmp not supported")
- }
-
- // Set latest snapshot in map.
- snapshots[envptr] = snapshot
-
- // Set return.
- stack[0] = 0
-}
-
-// longjmp implements the C function: int longjmp(env jmp_buf, value int)
-func longjmp(ctx context.Context, mod 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[envptr]
- if snapshot == nil {
- panic("must first call setjmp")
- }
-
- // 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 7b07d851d..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/run.go
+++ /dev/null
@@ -1,87 +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)
-
- 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 328a26193..000000000
--- a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/runtime.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package wasm
-
-import (
- "context"
-
- "github.com/tetratelabs/wazero"
- "github.com/tetratelabs/wazero/api"
- "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
-
-// 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)
-
- // 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.ValueType{api.ValueTypeI32},
- ).Export("setjmp")
-
- // Register longjmp host function.
- env = env.NewFunctionBuilder().
- WithGoModuleFunction(
- api.GoModuleFunc(longjmp),
- []api.ValueType{api.ValueTypeI32, api.ValueTypeI32},
- []api.ValueType{},
- ).Export("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-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/LICENSE b/vendor/codeberg.org/gruf/go-mangler/LICENSE
deleted file mode 100644
index dffbdf0c9..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/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/README.md b/vendor/codeberg.org/gruf/go-mangler/README.md
deleted file mode 100644
index 636c2494c..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/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/helpers.go b/vendor/codeberg.org/gruf/go-mangler/helpers.go
deleted file mode 100644
index 4e37e1344..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/helpers.go
+++ /dev/null
@@ -1,200 +0,0 @@
-package mangler
-
-import (
- "reflect"
- "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),
- )
-}
-
-type typecontext struct {
- ntype reflect.Type
- rtype reflect.Type
-}
-
-func deref_ptr_mangler(ctx typecontext, mangle Mangler, n uint) Mangler {
- if mangle == nil || n == 0 {
- panic("bad input")
- }
-
- // Non-nested value types,
- // i.e. just direct ptrs to
- // primitives require one
- // less dereference to ptr.
- if ctx.ntype == nil {
- n--
- }
-
- return func(buf []byte, ptr unsafe.Pointer) []byte {
-
- // Deref n number times.
- for i := n; i > 0; i-- {
-
- if ptr == nil {
- // Check for nil values
- buf = append(buf, '0')
- return buf
- }
-
- // 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 = mangle(buf, ptr)
- return buf
- }
-}
-
-func iter_slice_mangler(ctx typecontext, mangle Mangler) Mangler {
- if ctx.rtype == nil || mangle == nil {
- panic("bad input")
- }
-
- // memory size of elem.
- esz := ctx.rtype.Size()
-
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- // Get data as slice hdr.
- hdr := (*slice_header)(ptr)
-
- for i := 0; i < hdr.len; i++ {
- // Mangle data at slice index.
- eptr := array_at(hdr.data, esz, i)
- buf = mangle(buf, eptr)
- buf = append(buf, ',')
- }
-
- if hdr.len > 0 {
- // Drop final comma.
- buf = buf[:len(buf)-1]
- }
-
- return buf
- }
-}
-
-func iter_array_mangler(ctx typecontext, mangle Mangler) Mangler {
- if ctx.rtype == nil || mangle == nil {
- panic("bad input")
- }
-
- // no. array elements.
- n := ctx.ntype.Len()
-
- // memory size of elem.
- esz := ctx.rtype.Size()
-
- 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 = mangle(buf, eptr)
- buf = append(buf, ',')
- }
-
- if n > 0 {
- // Drop final comma.
- buf = buf[:len(buf)-1]
- }
-
- return buf
- }
-}
-
-func iter_struct_mangler(ctx typecontext, manglers []Mangler) Mangler {
- if ctx.rtype == nil || len(manglers) != ctx.rtype.NumField() {
- panic("bad input")
- }
-
- type field struct {
- mangle Mangler
- offset uintptr
- }
-
- // Bundle together the fields and manglers.
- fields := make([]field, ctx.rtype.NumField())
- for i := range fields {
- rfield := ctx.rtype.FieldByIndex([]int{i})
- fields[i].offset = rfield.Offset
- fields[i].mangle = manglers[i]
- if fields[i].mangle == nil {
- panic("bad input")
- }
- }
-
- 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
- }
-}
-
-// array_at returns ptr to index in array at ptr, given element size.
-func array_at(ptr unsafe.Pointer, esz uintptr, i int) unsafe.Pointer {
- return unsafe.Pointer(uintptr(ptr) + esz*uintptr(i))
-}
-
-// 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)
-}
-
-type slice_header struct {
- data unsafe.Pointer
- len int
- cap int
-}
-
-func eface_data(a any) unsafe.Pointer {
- type eface struct{ _, data unsafe.Pointer }
- return (*eface)(unsafe.Pointer(&a)).data
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/load.go b/vendor/codeberg.org/gruf/go-mangler/load.go
deleted file mode 100644
index bc79d381e..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/load.go
+++ /dev/null
@@ -1,223 +0,0 @@
-package mangler
-
-import (
- "reflect"
-)
-
-// loadMangler is the top-most Mangler load function. It guarantees that a Mangler
-// function will be returned for given value interface{} and reflected type. Else panics.
-func loadMangler(t reflect.Type) Mangler {
- ctx := typecontext{rtype: t}
-
- // Load mangler fn
- mng := load(ctx)
- if mng != nil {
- return mng
- }
-
- // No mangler function could be determined
- panic("cannot mangle type: " + t.String())
-}
-
-// load will load a Mangler or reflect Mangler for given type and iface 'a'.
-// Note: allocates new interface value if nil provided, i.e. if coming via reflection.
-func load(ctx typecontext) Mangler {
- if ctx.rtype == nil {
- // There is no reflect type to search by
- panic("cannot mangle nil interface{} type")
- }
-
- // Search by reflection.
- mng := loadReflect(ctx)
- if mng != nil {
- return mng
- }
-
- return nil
-}
-
-// loadReflect will load a Mangler (or rMangler) function for the given reflected type info.
-// NOTE: this is used as the top level load function for nested reflective searches.
-func loadReflect(ctx typecontext) Mangler {
- switch ctx.rtype.Kind() {
- case reflect.Pointer:
- return loadReflectPtr(ctx)
-
- case reflect.String:
- return mangle_string
-
- case reflect.Struct:
- return loadReflectStruct(ctx)
-
- case reflect.Array:
- return loadReflectArray(ctx)
-
- case reflect.Slice:
- return loadReflectSlice(ctx)
-
- 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
- }
-}
-
-// loadReflectPtr loads a Mangler (or rMangler) function for a ptr's element type.
-// This also handles further dereferencing of any further ptr indrections (e.g. ***int).
-func loadReflectPtr(ctx typecontext) Mangler {
- var n uint
-
- // Iteratively dereference ptrs
- for ctx.rtype.Kind() == reflect.Pointer {
- ctx.rtype = ctx.rtype.Elem()
- n++
- }
-
- // Search for elemn type mangler.
- if mng := load(ctx); mng != nil {
- return deref_ptr_mangler(ctx, mng, n)
- }
-
- return nil
-}
-
-// loadReflectKnownSlice loads a Mangler function for a
-// known slice-of-element type (in this case, primtives).
-func loadReflectKnownSlice(ctx typecontext) Mangler {
- switch ctx.rtype.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
- }
-}
-
-// loadReflectSlice ...
-func loadReflectSlice(ctx typecontext) Mangler {
- // Set nesting type.
- ctx.ntype = ctx.rtype
-
- // Get nested element type.
- ctx.rtype = ctx.rtype.Elem()
-
- // Preferably look for known slice mangler func
- if mng := loadReflectKnownSlice(ctx); mng != nil {
- return mng
- }
-
- // Use nested mangler iteration.
- if mng := load(ctx); mng != nil {
- return iter_slice_mangler(ctx, mng)
- }
-
- return nil
-}
-
-// loadReflectArray ...
-func loadReflectArray(ctx typecontext) Mangler {
- // Set nesting type.
- ctx.ntype = ctx.rtype
-
- // Get nested element type.
- ctx.rtype = ctx.rtype.Elem()
-
- // Use manglers for nested iteration.
- if mng := load(ctx); mng != nil {
- return iter_array_mangler(ctx, mng)
- }
-
- return nil
-}
-
-// loadReflectStruct ...
-func loadReflectStruct(ctx typecontext) Mangler {
- var mngs []Mangler
-
- // Set nesting type.
- ctx.ntype = ctx.rtype
-
- // Gather manglers for all fields.
- for i := 0; i < ctx.ntype.NumField(); i++ {
-
- // Field typectx.
- ctx := typecontext{
- ntype: ctx.ntype,
- rtype: ctx.ntype.Field(i).Type,
- }
-
- // Load mangler.
- mng := load(ctx)
- if mng == nil {
- return nil
- }
-
- // Append next to map.
- mngs = append(mngs, mng)
- }
-
- // Use manglers for nested iteration.
- return iter_struct_mangler(ctx, mngs)
-}
diff --git a/vendor/codeberg.org/gruf/go-mangler/mangle.go b/vendor/codeberg.org/gruf/go-mangler/mangle.go
deleted file mode 100644
index 576286682..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/mangle.go
+++ /dev/null
@@ -1,130 +0,0 @@
-package mangler
-
-import (
- "reflect"
- "sync"
- "unsafe"
-)
-
-// manglers is a map of runtime
-// type ptrs => Mangler functions.
-var manglers sync.Map
-
-// Mangler is a function that will take an input interface value of known
-// type, and append it in mangled serialized form to the given byte buffer.
-// While the value type is an interface, the Mangler functions are accessed
-// by the value's runtime type pointer, allowing the input value type to be known.
-type Mangler func(buf []byte, ptr unsafe.Pointer) []byte
-
-// Get will fetch the Mangler function for given runtime type.
-// Note that the returned mangler will be a no-op in the case
-// that an incorrect type is passed as the value argument.
-func Get(t reflect.Type) Mangler {
- var mng Mangler
-
- // Get raw runtime type ptr
- uptr := uintptr(eface_data(t))
-
- // Look for a cached mangler
- v, ok := manglers.Load(uptr)
-
- if !ok {
- // Load mangler function
- mng = loadMangler(t)
- } else {
- // cast cached value
- mng = v.(Mangler)
- }
-
- return func(buf []byte, ptr unsafe.Pointer) []byte {
- // First write the type ptr (this adds
- // a unique prefix for each runtime type).
- buf = append_uint64(buf, uint64(uptr))
-
- // Finally, mangle value
- return mng(buf, ptr)
- }
-}
-
-// Register will register the given Mangler function for use with vars of given runtime type. This allows
-// registering performant manglers for existing types not implementing Mangled (e.g. std library types).
-// NOTE: panics if there already exists a Mangler function for given type. Register on init().
-func Register(t reflect.Type, m Mangler) {
- if t == nil {
- // Nil interface{} types cannot be searched by, do not accept
- panic("cannot register mangler for nil interface{} type")
- }
-
- // Get raw runtime type ptr
- uptr := uintptr(eface_data(t))
-
- // Ensure this is a unique encoder
- if _, ok := manglers.Load(uptr); ok {
- panic("already registered mangler for type: " + t.String())
- }
-
- // Cache this encoder func
- manglers.Store(uptr, m)
-}
-
-// 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 {
- var mng Mangler
-
- // Get reflect type of 'a'
- t := reflect.TypeOf(a)
-
- // Get raw runtime type ptr
- uptr := uintptr(eface_data(t))
-
- // Look for a cached mangler
- v, ok := manglers.Load(uptr)
-
- if !ok {
- // Load into cache
- mng = loadMangler(t)
- manglers.Store(uptr, mng)
- } else {
- // cast cached value
- mng = v.(Mangler)
- }
-
- // First write the type ptr (this adds
- // a unique prefix for each runtime type).
- b = append_uint64(b, uint64(uptr))
-
- // Finally, mangle value
- ptr := eface_data(a)
- return mng(b, ptr)
-}
-
-// 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:
-// - string
-// - bool
-// - int,int8,int16,int32,int64
-// - uint,uint8,uint16,uint32,uint64,uintptr
-// - float32,float64
-// - complex64,complex128
-// - arbitrary structs
-// - all type aliases of above
-// - all pointers to the above
-// - all slices / arrays of the above
-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/manglers.go b/vendor/codeberg.org/gruf/go-mangler/manglers.go
deleted file mode 100644
index 79bfe3c00..000000000
--- a/vendor/codeberg.org/gruf/go-mangler/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-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 af4cb6770..000000000
--- a/vendor/codeberg.org/gruf/go-mempool/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# go-mempool
-
-very simple memory pool implementation \ No newline at end of file
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 e5ff6ba3d..000000000
--- a/vendor/codeberg.org/gruf/go-mempool/pool.go
+++ /dev/null
@@ -1,99 +0,0 @@
-package mempool
-
-import (
- "unsafe"
-)
-
-const DefaultDirtyFactor = 128
-
-// Pool provides a type-safe form
-// of UnsafePool using generics.
-//
-// Note it is NOT safe for concurrent
-// use, you must protect it yourself!
-type Pool[T any] struct {
-
- // 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)
-
- UnsafePool
-}
-
-func (p *Pool[T]) Get() T {
- if ptr := p.UnsafePool.Get(); ptr != nil {
- return *(*T)(ptr)
- } else if p.New != nil {
- return p.New()
- }
- var z T
- return z
-}
-
-func (p *Pool[T]) Put(t T) {
- if p.Reset != nil {
- p.Reset(t)
- }
- ptr := unsafe.Pointer(&t)
- p.UnsafePool.Put(ptr)
-}
-
-// UnsafePool provides an incredibly
-// simple memory pool implementation
-// that stores ptrs to memory values,
-// and regularly flushes internal pool
-// structures according to DirtyFactor.
-//
-// Note it is NOT safe for concurrent
-// use, you must protect it yourself!
-type UnsafePool struct {
-
- // DirtyFactor determines the max
- // number of $dirty count before
- // pool is garbage collected. Where:
- // $dirty = len(current) - len(victim)
- DirtyFactor int
-
- current []unsafe.Pointer
- victim []unsafe.Pointer
-}
-
-func (p *UnsafePool) 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 *UnsafePool) Put(ptr unsafe.Pointer) {
- p.current = append(p.current, ptr)
-
- // Get dirty factor.
- df := p.DirtyFactor
- if df == 0 {
- df = DefaultDirtyFactor
- }
-
- if len(p.current)-len(p.victim) > df {
- // Garbage collection!
- p.victim = p.current
- p.current = nil
- }
-}
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 4b721cec4..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/map.go
+++ /dev/null
@@ -1,235 +0,0 @@
-package mutexes
-
-import (
- "sync"
- "sync/atomic"
- "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.UnsafePool
-}
-
-// checkInit ensures MutexMap is initialized (UNSAFE).
-func (mm *MutexMap) checkInit() {
- if mm.mumap.m == nil {
- mm.mumap.init(0)
- mm.mupool.DirtyFactor = 256
- }
-}
-
-// 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 && mu.t == lockTypeWrite:
- panic("BUG: multiple writer locks")
- case mu.l < 0:
- panic("BUG: negative lock count")
-
- case mu.l == 0:
- // Fully unlocked.
- mu.t = 0
-
- // 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
- }
-
- // Awake all blocked goroutines and check
- // for change in the last notified ticket.
- cptr := (*syncCond)(unsafe.Pointer(&mu.c))
- before := atomic.LoadUint32(&cptr.n.notify)
- mu.c.Broadcast() // awakes all blocked!
- after := atomic.LoadUint32(&cptr.n.notify)
-
- // If ticket changed, this indicates
- // AT LEAST one goroutine was awoken.
- //
- // (before != after) => (waiters > 0)
- // (before == after) => (waiters = 0)
- return (before == after)
-
- default:
- // 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/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 12f7f1a10..000000000
--- a/vendor/codeberg.org/gruf/go-runners/context.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package runners
-
-import (
- "context"
- "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) {
- ctx := make(chan struct{})
- cncl := func() { close(ctx) }
- return CancelCtx(ctx), cncl
-}
-
-// 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/pool.go b/vendor/codeberg.org/gruf/go-runners/pool.go
deleted file mode 100644
index 644cde0b9..000000000
--- a/vendor/codeberg.org/gruf/go-runners/pool.go
+++ /dev/null
@@ -1,292 +0,0 @@
-package runners
-
-import (
- "context"
- "fmt"
- "os"
- "runtime"
- "sync"
-
- "codeberg.org/gruf/go-errors/v2"
-)
-
-// WorkerFunc represents a function processable by a worker in WorkerPool. Note
-// that implementations absolutely MUST check whether passed context is <-ctx.Done()
-// otherwise stopping the pool may block indefinitely.
-type WorkerFunc func(context.Context)
-
-// WorkerPool provides a means of enqueuing asynchronous work.
-type WorkerPool struct {
- fns chan WorkerFunc
- svc Service
-}
-
-// Start will start the main WorkerPool management loop in a new goroutine, along
-// with requested number of child worker goroutines. Returns false if already running.
-func (pool *WorkerPool) Start(workers int, queue int) bool {
- // Attempt to start the svc
- ctx, ok := pool.svc.doStart()
- if !ok {
- return false
- }
-
- if workers <= 0 {
- // Use $GOMAXPROCS as default.
- workers = runtime.GOMAXPROCS(0)
- }
-
- if queue < 0 {
- // Use reasonable queue default.
- queue = workers * 10
- }
-
- // Allocate pool queue of given size.
- //
- // This MUST be set BEFORE we return and NOT in
- // the launched goroutine, or there is a risk that
- // the pool may appear as closed for a short time
- // until the main goroutine has been entered.
- fns := make(chan WorkerFunc, queue)
- pool.fns = fns
-
- go func() {
- defer func() {
- // unlock single wait
- pool.svc.wait.Unlock()
-
- // ensure stopped
- pool.svc.Stop()
- }()
-
- var wait sync.WaitGroup
-
- // Start goroutine worker functions
- for i := 0; i < workers; i++ {
- wait.Add(1)
-
- go func() {
- defer wait.Done()
-
- // Run worker function (retry on panic)
- for !worker_run(CancelCtx(ctx), fns) {
- }
- }()
- }
-
- // Wait on ctx
- <-ctx
-
- // Drain function queue.
- //
- // All functions in the queue MUST be
- // run, so we pass them a closed context.
- //
- // This mainly allows us to block until
- // the function queue is empty, as worker
- // functions will also continue draining in
- // the background with the (now) closed ctx.
- for !drain_queue(fns) {
- // retry on panic
- }
-
- // Now the queue is empty, we can
- // safely close the channel signalling
- // all of the workers to return.
- close(fns)
- wait.Wait()
- }()
-
- return true
-}
-
-// Stop will stop the WorkerPool management loop, blocking until stopped.
-func (pool *WorkerPool) Stop() bool {
- return pool.svc.Stop()
-}
-
-// Running returns if WorkerPool management loop is running (i.e. NOT stopped / stopping).
-func (pool *WorkerPool) Running() bool {
- return pool.svc.Running()
-}
-
-// Done returns a channel that's closed when WorkerPool.Stop() is called. It is the same channel provided to the currently running worker functions.
-func (pool *WorkerPool) Done() <-chan struct{} {
- return pool.svc.Done()
-}
-
-// Enqueue will add provided WorkerFunc to the queue to be performed when there is a free worker.
-// This will block until function is queued or pool is stopped. In all cases, the WorkerFunc will be
-// executed, with the state of the pool being indicated by <-ctx.Done() of the passed ctx.
-// WorkerFuncs MUST respect the passed context.
-func (pool *WorkerPool) Enqueue(fn WorkerFunc) {
- // Check valid fn
- if fn == nil {
- return
- }
-
- select {
- // Pool ctx cancelled
- case <-pool.svc.Done():
- fn(closedctx)
-
- // Placed fn in queue
- case pool.fns <- fn:
- }
-}
-
-// EnqueueCtx is functionally identical to WorkerPool.Enqueue() but returns early in the
-// case that caller provided <-ctx.Done() is closed, WITHOUT running the WorkerFunc.
-func (pool *WorkerPool) EnqueueCtx(ctx context.Context, fn WorkerFunc) bool {
- // Check valid fn
- if fn == nil {
- return false
- }
-
- select {
- // Caller ctx cancelled
- case <-ctx.Done():
- return false
-
- // Pool ctx cancelled
- case <-pool.svc.Done():
- return false
-
- // Placed fn in queue
- case pool.fns <- fn:
- return true
- }
-}
-
-// MustEnqueueCtx functionally performs similarly to WorkerPool.EnqueueCtx(), but in the case
-// that the provided <-ctx.Done() is closed, it is passed asynchronously to WorkerPool.Enqueue().
-// Return boolean indicates whether function was executed in time before <-ctx.Done() is closed.
-func (pool *WorkerPool) MustEnqueueCtx(ctx context.Context, fn WorkerFunc) (ok bool) {
- // Check valid fn
- if fn == nil {
- return false
- }
-
- select {
- case <-ctx.Done():
- // We failed to add this entry to the worker queue before the
- // incoming context was cancelled. So to ensure processing
- // we simply queue it asynchronously and return early to caller.
- go pool.Enqueue(fn)
- return false
-
- case <-pool.svc.Done():
- // Pool ctx cancelled
- fn(closedctx)
- return false
-
- case pool.fns <- fn:
- // Placed fn in queue
- return true
- }
-}
-
-// EnqueueNow attempts Enqueue but returns false if not executed.
-func (pool *WorkerPool) EnqueueNow(fn WorkerFunc) bool {
- // Check valid fn
- if fn == nil {
- return false
- }
-
- select {
- // Pool ctx cancelled
- case <-pool.svc.Done():
- return false
-
- // Placed fn in queue
- case pool.fns <- fn:
- return true
-
- // Queue is full
- default:
- return false
- }
-}
-
-// Queue returns the number of currently queued WorkerFuncs.
-func (pool *WorkerPool) Queue() int {
- var l int
- pool.svc.While(func() {
- l = len(pool.fns)
- })
- return l
-}
-
-// worker_run is the main worker routine, accepting functions from 'fns' until it is closed.
-func worker_run(ctx context.Context, fns <-chan WorkerFunc) bool {
- defer func() {
- // Recover and drop any panic
- if r := recover(); r != nil {
-
- // Gather calling func frames.
- pcs := make([]uintptr, 10)
- n := runtime.Callers(3, pcs)
- i := runtime.CallersFrames(pcs[:n])
- c := gatherFrames(i, n)
-
- const msg = "worker_run: recovered panic: %v\n\n%s\n"
- fmt.Fprintf(os.Stderr, msg, r, c.String())
- }
- }()
-
- for {
- // Wait on next func
- fn, ok := <-fns
- if !ok {
- return true
- }
-
- // Run with ctx
- fn(ctx)
- }
-}
-
-// drain_queue will drain and run all functions in worker queue, passing in a closed context.
-func drain_queue(fns <-chan WorkerFunc) bool {
- defer func() {
- // Recover and drop any panic
- if r := recover(); r != nil {
-
- // Gather calling func frames.
- pcs := make([]uintptr, 10)
- n := runtime.Callers(3, pcs)
- i := runtime.CallersFrames(pcs[:n])
- c := gatherFrames(i, n)
-
- const msg = "worker_run: recovered panic: %v\n\n%s\n"
- fmt.Fprintf(os.Stderr, msg, r, c.String())
- }
- }()
-
- for {
- select {
- // Run with closed ctx
- case fn := <-fns:
- fn(closedctx)
-
- // Queue is empty
- default:
- return true
- }
- }
-}
-
-// gatherFrames collates runtime frames from a frame iterator.
-func gatherFrames(iter *runtime.Frames, n int) errors.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-runners/process.go b/vendor/codeberg.org/gruf/go-runners/process.go
deleted file mode 100644
index ca39ac0d0..000000000
--- a/vendor/codeberg.org/gruf/go-runners/process.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package runners
-
-import (
- "fmt"
- "sync"
-)
-
-// Processable defines a runnable process with error return
-// that can be passed to a Processor instance for managed running.
-type Processable func() error
-
-// 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 {
- mutex sync.Mutex
- wait *sync.WaitGroup
- err *error
-}
-
-// 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 Processable) (err error) {
- // Acquire state lock.
- p.mutex.Lock()
-
- if p.wait != nil {
- // Already running.
- //
- // Get current ptrs.
- waitPtr := p.wait
- errPtr := p.err
-
- // Free state lock.
- p.mutex.Unlock()
-
- // Wait for finish.
- waitPtr.Wait()
- return *errPtr
- }
-
- // Alloc waiter for new process.
- var wait sync.WaitGroup
-
- // No need to alloc new error as
- // we use the alloc'd named error
- // return required for panic handling.
-
- // Reset ptrs.
- p.wait = &wait
- p.err = &err
-
- // Set started.
- wait.Add(1)
- p.mutex.Unlock()
-
- defer func() {
- if r := recover(); r != nil {
- if err != nil {
- rOld := r // wrap the panic so we don't lose existing returned error
- r = fmt.Errorf("panic occured after error %q: %v", err.Error(), rOld)
- }
-
- // Catch any panics and wrap as error.
- err = fmt.Errorf("caught panic: %v", r)
- }
-
- // Mark done.
- wait.Done()
-
- // Set stopped.
- p.mutex.Lock()
- p.wait = nil
- p.mutex.Unlock()
- }()
-
- // Run process.
- err = proc()
- return
-}
diff --git a/vendor/codeberg.org/gruf/go-runners/service.go b/vendor/codeberg.org/gruf/go-runners/service.go
deleted file mode 100644
index 8a7c0051a..000000000
--- a/vendor/codeberg.org/gruf/go-runners/service.go
+++ /dev/null
@@ -1,217 +0,0 @@
-package runners
-
-import (
- "context"
- "sync"
-)
-
-// Service provides a means of tracking a single long-running service, provided protected state
-// changes and preventing multiple instances running. Also providing service state information.
-type Service struct {
- state uint32 // 0=stopped, 1=running, 2=stopping
- mutex sync.Mutex // mutex protects overall state changes
- wait sync.Mutex // wait is used as a single-entity wait-group, only ever locked within 'mutex'
- ctx chan struct{} // ctx is the current context for running function (or nil if not running)
-}
-
-// 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)) bool {
- // Attempt to start the svc
- ctx, ok := svc.doStart()
- if !ok {
- return false
- }
-
- defer func() {
- // unlock single wait
- svc.wait.Unlock()
-
- // ensure stopped
- _ = svc.Stop()
- }()
-
- // Run with context.
- fn(CancelCtx(ctx))
-
- return true
-}
-
-// 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)) bool {
- // Attempt to start the svc
- ctx, ok := svc.doStart()
- if !ok {
- return false
- }
-
- go func() {
- defer func() {
- // unlock single wait
- svc.wait.Unlock()
-
- // ensure stopped
- _ = svc.Stop()
- }()
-
- // Run with context.
- fn(CancelCtx(ctx))
- }()
-
- return true
-}
-
-// RunWait is functionally the same as .Run(), but blocks until the first instance of .Run() returns.
-func (svc *Service) RunWait(fn func(context.Context)) bool {
- // Attempt to start the svc
- ctx, ok := svc.doStart()
- if !ok {
- <-ctx // block
- return false
- }
-
- defer func() {
- // unlock single wait
- svc.wait.Unlock()
-
- // ensure stopped
- _ = svc.Stop()
- }()
-
- // Run with context.
- fn(CancelCtx(ctx))
-
- return true
-}
-
-// Stop will attempt to stop the service, cancelling the running function's context. Immediately
-// returns false if not running, and true only after Service is fully stopped.
-func (svc *Service) Stop() bool {
- // Attempt to stop the svc
- ctx, ok := svc.doStop()
- if !ok {
- return false
- }
-
- defer func() {
- // Get svc lock
- svc.mutex.Lock()
-
- // Wait until stopped
- svc.wait.Lock()
- svc.wait.Unlock()
-
- // Reset the svc
- svc.ctx = nil
- svc.state = 0
- svc.mutex.Unlock()
- }()
-
- // Cancel ctx
- close(ctx)
-
- return true
-}
-
-// While allows you to execute given function guaranteed within current
-// service state. Please note that this will hold the underlying service
-// state change mutex open while executing the function.
-func (svc *Service) While(fn func()) {
- // Protect state change
- svc.mutex.Lock()
- defer svc.mutex.Unlock()
-
- // Run
- fn()
-}
-
-// doStart will safely set Service state to started, returning a ptr to this context insance.
-func (svc *Service) doStart() (chan struct{}, bool) {
- // Protect startup
- svc.mutex.Lock()
-
- if svc.ctx == nil {
- // this will only have been allocated
- // if svc.Done() was already called.
- svc.ctx = make(chan struct{})
- }
-
- // Take our own ptr
- ctx := svc.ctx
-
- if svc.state != 0 {
- // State was not stopped.
- svc.mutex.Unlock()
- return ctx, false
- }
-
- // Set started.
- svc.state = 1
-
- // Start waiter.
- svc.wait.Lock()
-
- // Unlock and return
- svc.mutex.Unlock()
- return ctx, true
-}
-
-// doStop will safely set Service state to stopping, returning a ptr to this cancelfunc instance.
-func (svc *Service) doStop() (chan struct{}, bool) {
- // Protect stop
- svc.mutex.Lock()
-
- if svc.state != 1 /* not started */ {
- svc.mutex.Unlock()
- return nil, false
- }
-
- // state stopping
- svc.state = 2
-
- // Take our own ptr
- // and unlock state
- ctx := svc.ctx
- svc.mutex.Unlock()
-
- return ctx, true
-}
-
-// Running returns if Service is running (i.e. state NOT stopped / stopping).
-func (svc *Service) Running() bool {
- svc.mutex.Lock()
- state := svc.state
- svc.mutex.Unlock()
- return (state == 1)
-}
-
-// Done returns a channel that's closed when Service.Stop() is called. It is
-// the same channel provided to the currently running service function.
-func (svc *Service) Done() <-chan struct{} {
- var done <-chan struct{}
-
- svc.mutex.Lock()
- switch svc.state {
- // stopped
- case 0:
- if svc.ctx == nil {
- // here we create a new context so that the
- // returned 'done' channel here will still
- // be valid for when Service is next started.
- svc.ctx = make(chan struct{})
- }
- done = svc.ctx
-
- // started
- case 1:
- done = svc.ctx
-
- // stopping
- case 2:
- done = svc.ctx
- }
- svc.mutex.Unlock()
-
- return done
-}
diff --git a/vendor/codeberg.org/gruf/go-sched/LICENSE b/vendor/codeberg.org/gruf/go-sched/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-sched/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-sched/README.md b/vendor/codeberg.org/gruf/go-sched/README.md
deleted file mode 100644
index d32a961ae..000000000
--- a/vendor/codeberg.org/gruf/go-sched/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# go-sched
-
-A simple job (both run-once and recurring) queueing library with down-to millisecond precision.
-
-Precision estimates based on test output (running on i7-11800h): 1ms precision with 80% tolerance. \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-sched/job.go b/vendor/codeberg.org/gruf/go-sched/job.go
deleted file mode 100644
index 2531769d6..000000000
--- a/vendor/codeberg.org/gruf/go-sched/job.go
+++ /dev/null
@@ -1,143 +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 unsafe.Pointer // *time.Time
- timing Timing
- call func(time.Time)
- panic func(interface{})
-}
-
-// NewJob returns a new Job to run given function.
-func NewJob(fn func(now time.Time)) *Job {
- if fn == nil {
- // Ensure a function
- panic("nil func")
- }
-
- j := &Job{ // set defaults
- timing: emptytiming, // i.e. fire immediately
- call: fn,
- panic: func(i interface{}) { panic(i) },
- }
-
- 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
-}
-
-// OnPanic specifies how this job handles panics, default is an actual panic.
-func (job *Job) OnPanic(fn func(interface{})) *Job {
- if fn == nil {
- // Ensure a function
- panic("nil func")
- }
-
- if job.id != 0 {
- // Cannot update scheduled job
- panic("job already scheduled")
- }
-
- job.panic = fn
- return job
-}
-
-// Next returns the next time this Job is expected to run.
-func (job *Job) Next() time.Time {
- return loadTime(&job.next)
-}
-
-// Run will execute this Job and pass through given now time.
-func (job *Job) Run(now time.Time) {
- defer func() {
- switch r := recover(); {
- case r == nil:
- // no panic
- case job != nil &&
- job.panic != nil:
- job.panic(r)
- default:
- panic(r)
- }
- }()
- job.call(now)
-}
-
-// String provides a debuggable string representation of Job including ID, next time and Timing type.
-func (job *Job) String() string {
- var buf strings.Builder
- buf.WriteByte('{')
- buf.WriteString("id=")
- buf.WriteString(strconv.FormatUint(job.id, 10))
- buf.WriteByte(' ')
- buf.WriteString("next=")
- buf.WriteString(loadTime(&job.next).Format(time.StampMicro))
- buf.WriteByte(' ')
- buf.WriteString("timing=")
- buf.WriteString(reflect.TypeOf(job.timing).String())
- buf.WriteByte('}')
- return buf.String()
-}
-
-func loadTime(p *unsafe.Pointer) time.Time {
- if p := atomic.LoadPointer(p); p != nil {
- return *(*time.Time)(p)
- }
- return zerotime
-}
-
-func storeTime(p *unsafe.Pointer, t time.Time) {
- atomic.StorePointer(p, unsafe.Pointer(&t))
-}
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 79913a9b3..000000000
--- a/vendor/codeberg.org/gruf/go-sched/scheduler.go
+++ /dev/null
@@ -1,290 +0,0 @@
-package sched
-
-import (
- "context"
- "sort"
- "sync"
- "sync/atomic"
- "time"
-
- "codeberg.org/gruf/go-runners"
-)
-
-// precision is the maximum time we can offer scheduler run-time precision down to.
-const precision = 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 {
- jobs []*Job // jobs is a list of tracked Jobs to be executed
- jch chan interface{} // jch accepts either Jobs or job IDs to notify new/removed jobs
- svc runners.Service // svc manages the main scheduler routine
- jid atomic.Uint64 // jid is used to iteratively generate unique IDs for jobs
- rgo func(func()) // goroutine runner, allows using goroutine pool to launch 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(gorun func(func())) bool {
- var block sync.Mutex
-
- // Use mutex to synchronize between started
- // goroutine and ourselves, to ensure that
- // we don't return before Scheduler init'd.
- block.Lock()
- defer block.Unlock()
-
- ok := sch.svc.GoRun(func(ctx context.Context) {
- // Create Scheduler job channel
- sch.jch = make(chan interface{})
-
- // Set goroutine runner function
- if sch.rgo = gorun; sch.rgo == nil {
- sch.rgo = func(f func()) { go f() }
- }
-
- // Unlock start routine
- block.Unlock()
-
- // Enter main loop
- sch.run(ctx)
- })
-
- if ok {
- // Wait on goroutine
- block.Lock()
- }
-
- 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()) {
- switch {
- // Check a job was passed
- case job == nil:
- panic("nil job")
-
- // Check we are running
- case !sch.Running():
- panic("scheduler not running")
- }
-
- // Calculate next job ID
- last := sch.jid.Load()
- next := sch.jid.Add(1)
- if next < last {
- panic("job id overflow")
- }
-
- // Pass job to scheduler
- job.id = next
- sch.jch <- job
-
- // Take ptrs to current state chs
- ctx := sch.svc.Done()
- jch := sch.jch
-
- // Return cancel function for job ID
- return func() {
- select {
- // Sched stopped
- case <-ctx:
-
- // Cancel this job
- case jch <- next:
- }
- }
-}
-
-// run is the main scheduler run routine, which runs for as long as ctx is valid.
-func (sch *Scheduler) run(ctx context.Context) {
- 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 jobs 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)
- tch = timer.C
- timerset = true
- }
- } else {
- // Unset timer
- tch = neverticks
- }
-
- select {
- // Scheduler stopped
- case <-ctx.Done():
- stopdrain()
- return
-
- // Timer ticked, run scheduled
- case t := <-tch:
- if !timerset {
- // '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 := <-sch.jch:
- sch.handle(v)
- stopdrain()
- }
- }
-}
-
-// handle takes an interfaces received from Scheduler.jch and handles either:
-// - Job --> new job to add.
-// - uint64 --> job ID to remove.
-func (sch *Scheduler) handle(v interface{}) {
- switch v := v.(type) {
- // New job added
- case *Job:
- // Get current time
- now := time.Now()
-
- // Update the next call time
- next := v.timing.Next(now)
- storeTime(&v.next, 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
- }
-
- // Pass to runner
- sch.rgo(func() {
- job.Run(now)
- })
-
- // Update the next call time
- next := job.timing.Next(now)
- storeTime(&job.next, 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]
-}
diff --git a/vendor/codeberg.org/gruf/go-sched/timing.go b/vendor/codeberg.org/gruf/go-sched/timing.go
deleted file mode 100644
index 33c230fa5..000000000
--- a/vendor/codeberg.org/gruf/go-sched/timing.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package sched
-
-import (
- "time"
-)
-
-var (
- // zerotime is zero time.Time (unix epoch).
- zerotime = time.Time{}
-
- // emptytiming is a global timingempty to check against.
- emptytiming = timingempty{}
-)
-
-// Timing provides scheduling for a Job, determining the next time
-// for given current time that execution is required. Please note that
-// calls to .Next() may alter the results of the next call, and should
-// only be called by the Scheduler.
-type Timing interface {
- Next(time.Time) time.Time
-}
-
-// timingempty is a 'zero' Timing implementation that always returns zero time.
-type timingempty struct{}
-
-func (timingempty) Next(time.Time) time.Time {
- return zerotime
-}
-
-// Once implements Timing to provide a run-once Job execution.
-type Once time.Time
-
-func (o *Once) Next(time.Time) time.Time {
- ret := *(*time.Time)(o)
- *o = Once(zerotime) // reset
- return ret
-}
-
-// Periodic implements Timing to provide a recurring Job execution.
-type Periodic time.Duration
-
-func (p Periodic) Next(now time.Time) time.Time {
- return now.Add(time.Duration(p))
-}
-
-// PeriodicAt implements Timing to provide a recurring Job execution starting at 'Once' time.
-type PeriodicAt struct {
- Once Once
- Period Periodic
-}
-
-func (p *PeriodicAt) Next(now time.Time) time.Time {
- if next := p.Once.Next(now); !next.IsZero() {
- return next
- }
- return p.Period.Next(now)
-}
-
-// TimingWrap allows combining two different Timing implementations.
-type TimingWrap struct {
- Outer Timing
- Inner Timing
-
- // determined next times
- outerNext time.Time
- innerNext time.Time
-}
-
-func (t *TimingWrap) Next(now time.Time) time.Time {
- if t.outerNext.IsZero() {
- // Regenerate outermost next run time
- t.outerNext = t.Outer.Next(now)
- }
-
- if t.innerNext.IsZero() {
- // Regenerate innermost next run time
- t.innerNext = t.Inner.Next(now)
- }
-
- // If outer comes before inner, return outer
- if t.outerNext != zerotime &&
- t.outerNext.Before(t.innerNext) {
- next := t.outerNext
- t.outerNext = zerotime
- return next
- }
-
- // Else, return inner
- next := t.innerNext
- t.innerNext = zerotime
- return next
-}
diff --git a/vendor/codeberg.org/gruf/go-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/errors.go b/vendor/codeberg.org/gruf/go-storage/s3/errors.go
deleted file mode 100644
index 1f4404469..000000000
--- a/vendor/codeberg.org/gruf/go-storage/s3/errors.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package s3
-
-import (
- "strings"
-
- "github.com/minio/minio-go/v7"
-)
-
-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 ")
-}
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 ad7686737..000000000
--- a/vendor/codeberg.org/gruf/go-storage/s3/s3.go
+++ /dev/null
@@ -1,470 +0,0 @@
-package s3
-
-import (
- "bytes"
- "context"
- "errors"
- "io"
- "net/http"
-
- "codeberg.org/gruf/go-storage"
- "codeberg.org/gruf/go-storage/internal"
- "github.com/minio/minio-go/v7"
-)
-
-// 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 {
- // 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
-}
-
-// 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{
- CoreOpts: cfg.CoreOpts,
- PutChunkSize: cfg.PutChunkSize,
- ListSize: cfg.ListSize,
- }
-}
-
-// 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) {
- // Check + set config defaults.
- config := getS3Config(cfg)
-
- // Create new S3 client connection to given endpoint.
- client, err := minio.NewCore(endpoint, &config.CoreOpts)
- if err != nil {
- return nil, err
- }
-
- ctx := context.Background()
-
- // 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) {
-
- // 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) {
- // 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)
- }
-
- }
-
- 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) {
- 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)
- }
-
- }
-
- 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
- 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) {
-
- // Query bucket for object info.
- info, err := st.client.StatObject(
- ctx,
- st.bucket,
- key,
- opts,
- )
- if err != nil {
-
- if isNotFoundError(err) {
- // 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)
- }
-
- }
-
- 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 {
-
- // Remove object from S3 bucket
- err := st.client.RemoveObject(
- ctx,
- st.bucket,
- key,
- opts,
- )
-
- if err != nil {
-
- if isNotFoundError(err) {
- // 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)
- }
-
- }
-
- 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")
- }
-
- var (
- prev string
- token string
- )
-
- for {
- // 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 result contents.
- for _, obj := range result.Contents {
-
- // Skip filtered obj keys.
- if opts.Filter != nil &&
- opts.Filter(obj.Key) {
- continue
- }
-
- // Pass each obj through step func.
- if err := opts.Step(storage.Entry{
- Key: obj.Key,
- Size: obj.Size,
- }); 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 91286b5c8..000000000
--- a/vendor/codeberg.org/gruf/go-storage/test.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-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' \
- HUP INT QUIT ABRT KILL TERM 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 c8e1585b3..000000000
--- a/vendor/codeberg.org/gruf/go-structr/README.md
+++ /dev/null
@@ -1,143 +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 a hashmap keyed by serialized input key type. This is handled by the incredibly performant serialization library [go-mangler](https://codeberg.org/gruf/go-mangler), which at this point in time supports just about **any** arbitrary type, so feel free to index by *anything*!
-
-## Cache example
-
-```golang
-type Cached struct {
- Username string
- Domain string
- URL string
- CountryCode int
-}
-
-var c structr.Cache[*Cached]
-
-c.Init(structr.CacheConfig[*Cached]{
-
- // Fields this cached struct type
- // will be indexed and stored under.
- Indices: []structr.IndexConfig{
- {Fields: "Username,Domain", AllowZero: true},
- {Fields: "URL"},
- {Fields: "CountryCode", Multiple: true},
- },
-
- // Maximum LRU cache size before
- // new entries cause evictions.
- MaxSize: 1000,
-
- // User provided value copy function to
- // reduce need for reflection + ensure
- // concurrency safety for returned values.
- Copy: func(c *Cached) *Cached {
- c2 := new(Cached)
- *c2 = *c
- return c2
- },
-
- // User defined invalidation hook.
- Invalidate: func(c *Cached) {
- log.Println("invalidated:", c)
- },
-})
-
-// Access and store indexes ahead-of-time for perf.
-usernameDomainIndex := c.Index("Username,Domain")
-urlIndex := c.Index("URL")
-countryCodeIndex := c.Index("CountryCode")
-
-var url string
-
-// Generate URL index key.
-urlKey := urlIndex.Key(url)
-
-// Load value from cache, with callback function to hydrate
-// cache if value cannot be found under index name with key.
-// Negative (error) results are also cached, with user definable
-// errors to ignore from caching (e.g. context deadline errs).
-value, err := c.LoadOne(urlIndex, func() (*Cached, error) {
- return dbType.SelectByURL(url)
-}, urlKey)
-if err != nil {
- return nil, err
-}
-
-// Store value in cache, only if provided callback
-// function returns without error. Passes value through
-// invalidation hook regardless of error return value.
-//
-// On success value will be automatically added to and
-// accessible under all initially configured indices.
-if err := c.Store(value, func() error {
- return dbType.Insert(value)
-}); err != nil {
- return nil, err
-}
-
-// Generate country code index key.
-countryCodeKey := countryCodeIndex.Key(42)
-
-// Invalidate all cached results stored under
-// provided index name with give field value(s).
-c.Invalidate(countryCodeIndex, countryCodeKey)
-```
-
-## Queue example
-
-```golang
-
-type Queued struct{
- Username string
- Domain string
- URL string
- CountryCode int
-}
-
-var q structr.Queue[*Queued]
-
-q.Init(structr.QueueConfig[*Cached]{
-
- // Fields this queued struct type
- // will be indexed and stored under.
- Indices: []structr.IndexConfig{
- {Fields: "Username,Domain", AllowZero: true},
- {Fields: "URL"},
- {Fields: "CountryCode", Multiple: true},
- },
-
- // User defined pop hook.
- Pop: func(c *Cached) {
- log.Println("popped:", c)
- },
-})
-
-// Access and store indexes ahead-of-time for perf.
-usernameDomainIndex := q.Index("Username,Domain")
-urlIndex := q.Index("URL")
-countryCodeIndex := q.Index("CountryCode")
-
-// ...
-q.PushBack(Queued{
- Username: "billybob",
- Domain: "google.com",
- URL: "https://some.website.here",
- CountryCode: 42,
-})
-
-// ...
-queued, ok := q.PopFront()
-
-// Generate country code index key.
-countryCodeKey := countryCodeIndex.Key(42)
-
-// ...
-queuedByCountry := q.Pop(countryCodeIndex, countryCodeKey)
-```
-
-## 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 3705d7c7c..000000000
--- a/vendor/codeberg.org/gruf/go-structr/cache.go
+++ /dev/null
@@ -1,675 +0,0 @@
-package structr
-
-import (
- "context"
- "errors"
- "reflect"
- "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 struct cache.
-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 lruList in order
- // to evict old entries.
- maxSize int
-
- // protective mutex, guards:
- // - Cache{}.lruList
- // - Index{}.data
- // - Cache{} hook fns
- 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 := reflect.TypeOf((*T)(nil)).Elem()
-
- 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()
- 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
- c.mutex.Unlock()
-}
-
-// 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()
-
- // Wrap unlock to only do once.
- unlock := once(c.mutex.Unlock)
- defer 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
- // the lock.
- unlock()
-
- 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()
-
- // Wrap unlock to only do once.
- unlock := once(c.mutex.Unlock)
- defer 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
- // the lock.
- unlock()
-
- 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()
-
- // 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()
-
- 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()
-
- // Wrap unlock to only do once.
- unlock := once(c.mutex.Unlock)
- defer 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
- // the lock.
- unlock()
-
- 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()
-
- // Store all uncached values.
- for i := range uncached {
- c.store_value(
- nil, "",
- uncached[i],
- )
- }
-
- // Done with lock.
- c.mutex.Unlock()
-
- // 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.
-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 cached.
- 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.
- index.append(&c.lru, key, item)
- }
-
- // 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)
- if parts == nil {
- continue
- }
-
- // Calculate index key.
- key := idx.key(buf, parts)
- if key == "" {
- continue
- }
-
- // Append item to this index.
- idx.append(&c.lru, key, item)
- }
-
- // Add item to main lru list.
- c.lru.push_front(&item.elem)
-
- // Done with buf.
- free_buffer(buf)
-
- 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.
- index.append(&c.lru, key, item)
-
- // 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(item *indexed_item) {
- for len(item.indexed) != 0 {
- // Pop last indexed entry from list.
- entry := item.indexed[len(item.indexed)-1]
- item.indexed = item.indexed[:len(item.indexed)-1]
-
- // Drop index_entry from index.
- entry.index.delete_entry(entry)
- }
-
- // Drop entry from lru list.
- c.lru.remove(&item.elem)
-
- // Free now-unused item.
- free_indexed_item(item)
-}
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 558832da9..000000000
--- a/vendor/codeberg.org/gruf/go-structr/index.go
+++ /dev/null
@@ -1,433 +0,0 @@
-package structr
-
-import (
- "reflect"
- "strings"
- "sync"
- "unsafe"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-// 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"
- //
- // Note that nested fields where the nested
- // struct field is a ptr are supported, but
- // nil ptr values in nesting will result in
- // that particular value NOT being indexed.
- // e.g. with "Favorites.Color" if *Favorites
- // is nil then it will not be indexed.
- //
- // Field types supported include any of those
- // supported by the `go-mangler` 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 Cache/Queue
- // 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
- // the cached results contained within wrapping
- // index_entry{} which also contains the exact
- // key each result is stored under. the hash map
- // only keys by the xxh3 hash checksum for speed.
- data hashmap
-
- // struct fields encompassed by
- // keys (+ hashes) 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
-}
-
-// Key generates Key{} from given parts for
-// the type of lookup this Index uses in cache.
-// NOTE: panics on incorrect no. parts / types given.
-func (i *Index) Key(parts ...any) Key {
- ptrs := make([]unsafe.Pointer, len(parts))
- for x, part := range parts {
- ptrs[x] = eface_data(part)
- }
- buf := new_buffer()
- key := i.key(buf, ptrs)
- free_buffer(buf)
- return Key{
- raw: parts,
- key: key,
- }
-}
-
-// Keys generates []Key{} from given (multiple) parts
-// for the type of lookup this Index uses in the cache.
-// NOTE: panics on incorrect no. parts / types given.
-func (i *Index) Keys(parts ...[]any) []Key {
- keys := make([]Key, 0, len(parts))
- buf := new_buffer()
- for _, parts := range parts {
- ptrs := make([]unsafe.Pointer, len(parts))
- for x, part := range parts {
- ptrs[x] = eface_data(part)
- }
- key := i.key(buf, ptrs)
- if key == "" {
- continue
- }
- keys = append(keys, Key{
- raw: parts,
- key: key,
- })
- }
- free_buffer(buf)
- return keys
-}
-
-// init will initialize the cache with given type, config and capacity.
-func (i *Index) init(t reflect.Type, cfg IndexConfig, cap int) {
- switch {
- // The only 2 types we support are
- // structs, and ptrs to a struct.
- case t.Kind() == reflect.Struct:
- case t.Kind() == reflect.Pointer &&
- t.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 usable struct field.
- 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 uses hasher to generate Key{} from given raw parts.
-func (i *Index) key(buf *byteutil.Buffer, parts []unsafe.Pointer) string {
- buf.B = buf.B[:0]
- if len(parts) != len(i.fields) {
- panicf("incorrect number key parts: want=%d received=%d",
- len(i.fields),
- len(parts),
- )
- }
- 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)
-}
-
-// 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(ll *list, key string, item *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 item is not indexed,
- // remove from outer linked list.
- ll.remove(&evicted.elem)
- free_indexed_item(evicted)
- }
- }
-
- // 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)
-}
-
-// 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 sync.Pool
-
-// new_index_entry returns a new prepared index_entry.
-func new_index_entry() *index_entry {
- v := index_entry_pool.Get()
- if v == nil {
- e := new(index_entry)
- e.elem.data = unsafe.Pointer(e)
- v = e
- }
- entry := v.(*index_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 {
- should_not_reach()
- return
- }
- entry.key = ""
- entry.index = nil
- entry.item = nil
- index_entry_pool.Put(entry)
-}
-
-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 6178e18e3..000000000
--- a/vendor/codeberg.org/gruf/go-structr/item.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package structr
-
-import (
- "sync"
- "unsafe"
-)
-
-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 sync.Pool
-
-// new_indexed_item returns a new prepared indexed_item.
-func new_indexed_item() *indexed_item {
- v := indexed_item_pool.Get()
- if v == nil {
- i := new(indexed_item)
- i.elem.data = unsafe.Pointer(i)
- v = i
- }
- item := v.(*indexed_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 {
- should_not_reach()
- return
- }
- item.data = nil
- indexed_item_pool.Put(item)
-}
-
-// 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 65bdba455..000000000
--- a/vendor/codeberg.org/gruf/go-structr/key.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package structr
-
-import (
- "sync"
-
- "codeberg.org/gruf/go-byteutil"
-)
-
-// Key represents one key to
-// lookup (potentially) stored
-// entries in an Index.
-type Key struct {
- key string
- raw []any
-}
-
-// 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
-}
-
-// Zero indicates a zero value key.
-func (k Key) Zero() bool {
- return (k.raw == nil)
-}
-
-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 bf380aa26..000000000
--- a/vendor/codeberg.org/gruf/go-structr/list.go
+++ /dev/null
@@ -1,151 +0,0 @@
-package structr
-
-import (
- "sync"
- "unsafe"
-)
-
-// 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 sync.Pool
-
-// new_list returns a new prepared list.
-func new_list() *list {
- v := list_pool.Get()
- if v == nil {
- v = new(list)
- }
- list := v.(*list)
- return list
-}
-
-// free_list releases the list.
-func free_list(list *list) {
- if list.head != nil ||
- list.tail != nil ||
- list.len != 0 {
- should_not_reach()
- return
- }
- list_pool.Put(list)
-}
-
-// 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)
-}
-
-// 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 316a8e528..000000000
--- a/vendor/codeberg.org/gruf/go-structr/map.go
+++ /dev/null
@@ -1,58 +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.
- 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/ordered_list.bak b/vendor/codeberg.org/gruf/go-structr/ordered_list.bak
deleted file mode 100644
index 46b56853f..000000000
--- a/vendor/codeberg.org/gruf/go-structr/ordered_list.bak
+++ /dev/null
@@ -1,180 +0,0 @@
-package structr
-
-import "sync"
-
-type Timeline[StructType any, PK comparable] struct {
-
- // hook functions.
- pkey func(StructType) PK
- gte func(PK, PK) bool
- lte func(PK, PK) bool
- copy func(StructType) StructType
-
- // main underlying
- // ordered item list.
- list list
-
- // indices used in storing passed struct
- // types by user defined sets of fields.
- indices []Index
-
- // protective mutex, guards:
- // - TODO
- mutex sync.Mutex
-}
-
-func (t *Timeline[T, PK]) Init(config any) {
-
-}
-
-func (t *Timeline[T, PK]) Index(name string) *Index {
- for i := range t.indices {
- if t.indices[i].name == name {
- return &t.indices[i]
- }
- }
- panic("unknown index: " + name)
-}
-
-func (t *Timeline[T, PK]) Insert(values ...T) {
-
-}
-
-func (t *Timeline[T, PK]) LoadTop(min, max PK, length int, load func(min, max PK, length int) ([]T, error)) ([]T, error) {
- // Allocate expected no. values.
- values := make([]T, 0, length)
-
- // Acquire lock.
- t.mutex.Lock()
-
- // Wrap unlock to only do once.
- unlock := once(t.mutex.Unlock)
- defer unlock()
-
- // Check init'd.
- if t.copy == nil {
- panic("not initialized")
- }
-
- // Iterate through linked list from top (i.e. head).
- for next := t.list.head; next != nil; next = next.next {
-
- // Check if we've gathered
- // enough values from timeline.
- if len(values) >= length {
- return values, nil
- }
-
- item := (*indexed_item)(next.data)
- value := item.data.(T)
- pkey := t.pkey(value)
-
- // Check if below min.
- if t.lte(pkey, min) {
- continue
- }
-
- // Update min.
- min = pkey
-
- // Check if above max.
- if t.gte(pkey, max) {
- break
- }
-
- // Append value copy.
- value = t.copy(value)
- values = append(values, value)
- }
-}
-
-func (t *Timeline[T, PK]) LoadBottom(min, max PK, length int, load func(min, max PK, length int) ([]T, error)) ([]T, error) {
- // Allocate expected no. values.
- values := make([]T, 0, length)
-
- // Acquire lock.
- t.mutex.Lock()
-
- // Wrap unlock to only do once.
- unlock := once(t.mutex.Unlock)
- defer unlock()
-
- // Check init'd.
- if t.copy == nil {
- panic("not initialized")
- }
-
- // Iterate through linked list from bottom (i.e. tail).
- for next := t.list.tail; next != nil; next = next.prev {
-
- // Check if we've gathered
- // enough values from timeline.
- if len(values) >= length {
- return values, nil
- }
-
- item := (*indexed_item)(next.data)
- value := item.data.(T)
- pkey := t.pkey(value)
-
- // Check if above max.
- if t.gte(pkey, max) {
- continue
- }
-
- // Update max.
- max = pkey
-
- // Check if below min.
- if t.lte(pkey, min) {
- break
- }
-
- // Append value copy.
- value = t.copy(value)
- values = append(values, value)
- }
-
- // Done with
- // the lock.
- unlock()
-
- // Attempt to load values up to given length.
- next, err := load(min, max, length-len(values))
- if err != nil {
- return nil, err
- }
-
- // Acquire lock.
- t.mutex.Lock()
-
- // Store uncached values.
- for i := range next {
- t.store_value(
- nil, "",
- uncached[i],
- )
- }
-
- // Done with lock.
- t.mutex.Unlock()
-
- // Append uncached to return values.
- values = append(values, next...)
-
- return values, nil
-}
-
-func (t *Timeline[T, PK]) index(value T) *indexed_item {
- pk := t.pkey(value)
-
- switch {
- case t.list.len == 0:
-
- case pk < t.list.head.data:
- }
-}
-
-func (t *Timeline[T, PK]) delete(item *indexed_item) {
-
-}
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 dab925f95..000000000
--- a/vendor/codeberg.org/gruf/go-structr/queue.go
+++ /dev/null
@@ -1,342 +0,0 @@
-package structr
-
-import (
- "reflect"
- "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 := reflect.TypeOf((*T)(nil)).Elem()
-
- if len(config.Indices) == 0 {
- panic("no indices provided")
- }
-
- // Safely copy over
- // provided config.
- q.mutex.Lock()
- 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
- q.mutex.Unlock()
-}
-
-// 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 queued.
- 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 queued.
- 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)
- if parts == nil {
- continue
- }
-
- // Calculate index key.
- key := idx.key(buf, parts)
- if key == "" {
- continue
- }
-
- // Append item to this index.
- idx.append(&q.queue, key, item)
- }
-
- // Done with buf.
- free_buffer(buf)
-
- return item
-}
-
-func (q *Queue[T]) delete(item *indexed_item) {
- for len(item.indexed) != 0 {
- // Pop last indexed entry from list.
- entry := item.indexed[len(item.indexed)-1]
- item.indexed = item.indexed[:len(item.indexed)-1]
-
- // Get entry's index.
- index := entry.index
-
- // Drop this index_entry.
- index.delete_entry(entry)
-
- // Check compact map.
- index.data.Compact()
- }
-
- // Drop entry from queue list.
- q.queue.remove(&item.elem)
-
- // Free now-unused item.
- free_indexed_item(item)
-}
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 1dac46349..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 queued.
- 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 6e8af83dd..000000000
--- a/vendor/codeberg.org/gruf/go-structr/runtime.go
+++ /dev/null
@@ -1,216 +0,0 @@
-package structr
-
-import (
- "fmt"
- "os"
- "reflect"
- "runtime"
- "strings"
- "unicode"
- "unicode/utf8"
- "unsafe"
-
- "codeberg.org/gruf/go-mangler"
-)
-
-// struct_field contains pre-prepared type
-// information about a struct's field member,
-// including memory offset and hash function.
-type struct_field struct {
- rtype reflect.Type
-
- // 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,
- // if set this indicates zero
- // values of field not allowed
- zerostr string
-
- // offsets defines whereabouts in
- // memory this field is located.
- 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 uint
- offset uintptr
-}
-
-// 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 reflect.Type, names []string) (sfield struct_field) {
- 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) {
- panicf("field is not exported: %s", name)
- }
- return name
- }
-
- // field is the iteratively searched
- // struct field value in below loop.
- field reflect.StructField
- )
-
- for len(names) > 0 {
- // Pop next name.
- name := pop_name()
-
- var off next_offset
-
- // Dereference any ptrs to struct.
- for t.Kind() == reflect.Pointer {
- t = t.Elem()
- off.derefs++
- }
-
- // Check for valid struct type.
- if t.Kind() != reflect.Struct {
- panicf("field %s is not struct (or ptr-to): %s", t, name)
- }
-
- var ok bool
-
- // Look for next field by name.
- field, ok = t.FieldByName(name)
- if !ok {
- panicf("unknown field: %s", name)
- }
-
- // Set next offset value.
- off.offset = field.Offset
- sfield.offsets = append(sfield.offsets, off)
-
- // Set the next type.
- t = field.Type
- }
-
- // Set final type.
- sfield.rtype = t
-
- // Find mangler for field type.
- sfield.mangle = mangler.Get(t)
-
- // Get new zero value data ptr.
- v := reflect.New(t).Elem()
- zptr := eface_data(v.Interface())
- zstr := sfield.mangle(nil, zptr)
- sfield.zerostr = string(zstr)
- sfield.zero = zptr
-
- return
-}
-
-// 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))
- 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 like_ptr(field.rtype) && fptr != nil {
- // Further dereference value ptr.
- fptr = *(*unsafe.Pointer)(fptr)
- }
-
- if fptr == nil {
- // Use zero value.
- fptr = field.zero
- }
-
- // Set field ptr.
- ptrs[i] = fptr
- }
-
- return ptrs
-}
-
-// like_ptr returns whether type's kind is ptr-like.
-func like_ptr(t reflect.Type) bool {
- switch t.Kind() {
- case reflect.Pointer,
- reflect.Map,
- reflect.Chan,
- reflect.Func:
- return true
- }
- return false
-}
-
-// deref will dereference ptr 'n' times (or until nil).
-func deref(p unsafe.Pointer, n uint) unsafe.Pointer {
- for ; n > 0; n-- {
- if p == nil {
- return nil
- }
- p = *(*unsafe.Pointer)(p)
- }
- return p
-}
-
-// eface_data returns the data ptr from an empty interface.
-func eface_data(a any) unsafe.Pointer {
- type eface struct{ _, data unsafe.Pointer }
- return (*eface)(unsafe.Pointer(&a)).data
-}
-
-// panicf provides a panic with string formatting.
-func panicf(format string, args ...any) {
- panic(fmt.Sprintf(format, args...))
-}
-
-// should_not_reach can be called to indicated a
-// block of code should not be able to be reached,
-// else it prints callsite info with a BUG report.
-//
-//go:noinline
-func should_not_reach() {
- pcs := make([]uintptr, 1)
- _ = runtime.Callers(2, pcs)
- fn := runtime.FuncForPC(pcs[0])
- funcname := "go-structr" // by default use just our library name
- if fn != nil {
- funcname = fn.Name()
- if i := strings.LastIndexByte(funcname, '/'); i != -1 {
- funcname = funcname[i+1:]
- }
- }
- os.Stderr.WriteString("BUG: assertion failed in " + funcname + "\n")
-}
diff --git a/vendor/codeberg.org/gruf/go-structr/test.sh b/vendor/codeberg.org/gruf/go-structr/test.sh
deleted file mode 100644
index 554417df7..000000000
--- a/vendor/codeberg.org/gruf/go-structr/test.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-set -e
-go test -v -tags=structr_32bit_hash .
-go test -v -tags=structr_48bit_hash .
-go test -v -tags=structr_64bit_hash . \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-structr/util.go b/vendor/codeberg.org/gruf/go-structr/util.go
deleted file mode 100644
index 46535fcff..000000000
--- a/vendor/codeberg.org/gruf/go-structr/util.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structr
-
-// once only executes 'fn' once.
-func once(fn func()) func() {
- var once int32
- return func() {
- if once != 0 {
- return
- }
- once = 1
- fn()
- }
-}
diff --git a/vendor/codeberg.org/superseriousbusiness/exif-terminator/LICENSE b/vendor/codeberg.org/superseriousbusiness/exif-terminator/LICENSE
deleted file mode 100644
index dba13ed2d..000000000
--- a/vendor/codeberg.org/superseriousbusiness/exif-terminator/LICENSE
+++ /dev/null
@@ -1,661 +0,0 @@
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are 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.
-
- 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.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- 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 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 work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- 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 AGPL, see
-<http://www.gnu.org/licenses/>.
diff --git a/vendor/codeberg.org/superseriousbusiness/exif-terminator/README.md b/vendor/codeberg.org/superseriousbusiness/exif-terminator/README.md
deleted file mode 100644
index ddb97fbb6..000000000
--- a/vendor/codeberg.org/superseriousbusiness/exif-terminator/README.md
+++ /dev/null
@@ -1,122 +0,0 @@
-# exif-terminator
-
-`exif-terminator` removes exif data from images (jpeg and png currently supported) in a streaming manner. All you need to do is provide a reader of the image in, and exif-terminator will provide a reader of the image out.
-
-Hasta la vista, baby!
-
-```text
- .,lddxococ.
- ..',lxO0Oo;'.
- . .. .,coodO0klc:.
- .,. ..','. .. .,..'. .':llxKXk'
- .;c:cc;;,... .''.,l:cc. .....:l:,,:oo:..
- .,:ll'. .,;cox0OxOKKXX0kOOxlcld0X0d;,,,'.
- .:xkl. .':cdKNWWWWMMMMMMMMMMWWNXK0KWNd.
- .coxo,..:ollk0KKXNWMMMMMMMMMMWWXXXOoOM0;
- ,oc,. .;cloxOKXXWWMMMMMMMMMMMWNXk;;OWO'
- . ..;cdOKXNNWWMMMMMMMMMMMMWO,,ONO'
- ...... ....;okOO000XWWMMMMMMMMMWXx;,ONNx.
-.;c;. .:l'ckl. ..';looooolldolloooodolcc:;'.;oo:.
-.oxl. ;:..OO. .. .. .,' .;.
-.oko. .cc.'Ok. .:; .:,..';.
-.cdc. .;;lc.,Ox. . .',,'..','. .dN0; .. .c:,,':.
-.:oc. ,dxkl.,0x. . .. . .oNMMKc.. ...:l.
-.:o:. cKXKl.,Ox. .. .lKWMMMXo,. ...''.
-.:l; c0KKo.,0x. ...........';:lk0OKNNXKkl,..,;cxd'
-.::' ;k00l.;0d. .. .,cloooddddxxddol;:ddloxdc,:odOWNc
-.;,. ,ONKc.;0d. 'l,.. .:clllllllokKOl::cllclkKx'.lolxx'
-.,. '0W0:.;0d. .:l,. .,:ccc:::oOXNXOkxdook0NWNx,,;c;.
-... .kX0c.;0d. .loc' .,::;;;;lk0kddoooooddooO0o',ld;
-.. .oOkk:cKd. .... .;:,',;cxK0o::ldkOkkOkxod:';oKx.
-.. :dlOolKO, '::'.';:oOK0xdddoollooxOx::ccOx.
-.. ';:o,.xKo. .,;'...';lddolooodkkkdol:,::lc.
-.. ...:..oOl. ........';:codxxOXKKKk;':;:kl
-.. .,..lOc. .. ....,codxkxxxxxo:,,;lKO. .,;'..
-... .. ck: ';,'. .;:cllloc,;;;colOK; .;odxxoc;.
-...,.... . :x; .;:cc;'. .,;::c:'..,kXk:xNc .':oook00x:.
- . cKx. .'.. ':clllc,...'';:::cc:;.,kOo:xNx. .'codddoox
- .. ,xxl;',col:;. .:cccccc;;;:lxkkOOkdc,,lolcxWO' ;kNKc.'
- .,. .c' ':dkO0O; .. .;ccccccc:::cldxkxoll:;oolcdN0:.. .xWNk;
- .:' .c',xXNKkOXo .,. .,:cccccllc::lloooolc:;lo:;oXKc,::. .kWWX
- ,' .cONMWMWkco, ', .';::ccclolc:llolollcccodo;:KXl..cl,. ;KWN
- '. .xWWWWMKc;; ....;' ',;::::coolclloooollc:,:o;;0Xx, .,:;... ,0Ko
- . ,kKNWWXd,cdd0NXKk:,;;;'';::::coollllllllllc;;ccl0Nkc. ..';loOx'
- 'lxXWMXOOXNMMMMWWNNNWXkc;;;;;:cllccccccccc::lllkNWXd,. .cxO0Ol'
- ,xKNWWXkkXWM0dxKNWWWMWNX0OOkl;;:c::cccc:,...:oONMMXOo;. :kOkOkl;
- .;,;:;...,::. .;lokXKKNMMMWNOc,;;;,::;'...lOKNWNKkol:,..cKdcO0do
- .:;... .. .,:okO0KNN0:.',,''''. ':xNMWKkxxOKXd,.cNk,:l:o
-```
-
-## Why?
-
-Exif removal is a pain in the arse. Most other libraries seem to parse the whole image into memory, then remove the exif data, then encode the image again.
-
-`exif-terminator` differs in that it removes exif data *while scanning through the image bytes*, and it doesn't do any reencoding of the image. Bytes of exif data are simply all set to 0, and the image data is piped back out again into the returned reader.
-
-The only exception is orientation data: if an image contains orientation data, this and only this data will be preserved since it's *actually useful*.
-
-## Example
-
-You can run the following example with `go run ./example/main.go`:
-
-```go
-package main
-
-import (
- "io"
- "os"
-
- terminator "codeberg.org/superseriousbusiness/exif-terminator"
-)
-
-func main() {
- // open a file
- sloth, err := os.Open("./images/sloth.jpg")
- if err != nil {
- panic(err)
- }
- defer sloth.Close()
-
- // get the length of the file
- stat, err := sloth.Stat()
- if err != nil {
- panic(err)
- }
-
- // terminate!
- out, err := terminator.Terminate(sloth, int(stat.Size()), "jpeg")
- if err != nil {
- panic(err)
- }
-
- // read the bytes from the reader
- b, err := io.ReadAll(out)
- if err != nil {
- panic(err)
- }
-
- // save the file somewhere
- if err := os.WriteFile("./images/sloth-clean.jpg", b, 0666); err != nil {
- panic(err)
- }
-}
-```
-
-## Credits
-
-### Libraries
-
-`exif-terminator` borrows heavily from the two [`dsoprea`](https://github.com/dsoprea) libraries credited below. In fact, it's basically a hack on top of those libraries. Thanks `dsoprea`!
-
-- [dsoprea/go-exif](https://github.com/dsoprea/go-exif): exif header reconstruction. [MIT License](https://spdx.org/licenses/MIT.html).
-- [dsoprea/go-jpeg-image-structure](https://github.com/dsoprea/go-jpeg-image-structure): jpeg structure parsing. [MIT License](https://spdx.org/licenses/MIT.html).
-- [dsoprea/go-png-image-structure](https://github.com/dsoprea/go-png-image-structure): png structure parsing. [MIT License](https://spdx.org/licenses/MIT.html).
-- [stretchr/testify](https://github.com/stretchr/testify); test framework. [MIT License](https://spdx.org/licenses/MIT.html).
-
-## License
-
-![the gnu AGPL logo](https://www.gnu.org/graphics/agplv3-155x51.png)
-
-`exif-terminator` is free software, licensed under the [GNU AGPL v3 LICENSE](LICENSE).
-
-Copyright (C) 2022-2024 SuperSeriousBusiness.
diff --git a/vendor/codeberg.org/superseriousbusiness/exif-terminator/exif.go b/vendor/codeberg.org/superseriousbusiness/exif-terminator/exif.go
deleted file mode 100644
index 02dacc654..000000000
--- a/vendor/codeberg.org/superseriousbusiness/exif-terminator/exif.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- exif-terminator
- Copyright (C) 2022 SuperSeriousBusiness admin@gotosocial.org
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package terminator
-
-import (
- "strings"
-
- exif "github.com/dsoprea/go-exif/v3"
- exifcommon "github.com/dsoprea/go-exif/v3/common"
-)
-
-type withEXIF interface {
- Exif() (rootIfd *exif.Ifd, data []byte, err error)
- SetExif(ib *exif.IfdBuilder) (err error)
-}
-
-func terminateEXIF(data withEXIF) error {
- ifd, _, err := data.Exif()
- if err != nil {
- if strings.Contains(err.Error(), "no exif data") {
- err = nil
- }
- return err
- }
-
- ifdb := exif.NewIfdBuilderFromExistingChain(ifd)
- orientation, _ := ifdb.FindTagWithName("Orientation")
-
- im, ti := exifcommon.NewIfdMapping(), exif.NewTagIndex()
- ifdb = exif.NewIfdBuilder(im, ti, ifd.IfdIdentity(), ifd.ByteOrder())
-
- if orientation != nil {
- ifdb.Add(orientation)
- }
-
- return data.SetExif(ifdb)
-}
diff --git a/vendor/codeberg.org/superseriousbusiness/exif-terminator/jpeg.go b/vendor/codeberg.org/superseriousbusiness/exif-terminator/jpeg.go
deleted file mode 100644
index 01ca313ca..000000000
--- a/vendor/codeberg.org/superseriousbusiness/exif-terminator/jpeg.go
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- exif-terminator
- Copyright (C) 2022 SuperSeriousBusiness admin@gotosocial.org
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package terminator
-
-import (
- "encoding/binary"
- "fmt"
- "io"
-
- jpegstructure "github.com/superseriousbusiness/go-jpeg-image-structure/v2"
-)
-
-var markerLen = map[byte]int{
- 0x00: 0,
- 0x01: 0,
- 0xd0: 0,
- 0xd1: 0,
- 0xd2: 0,
- 0xd3: 0,
- 0xd4: 0,
- 0xd5: 0,
- 0xd6: 0,
- 0xd7: 0,
- 0xd8: 0,
- 0xd9: 0,
- 0xda: 0,
-
- // J2C
- 0x30: 0,
- 0x31: 0,
- 0x32: 0,
- 0x33: 0,
- 0x34: 0,
- 0x35: 0,
- 0x36: 0,
- 0x37: 0,
- 0x38: 0,
- 0x39: 0,
- 0x3a: 0,
- 0x3b: 0,
- 0x3c: 0,
- 0x3d: 0,
- 0x3e: 0,
- 0x3f: 0,
- 0x4f: 0,
- 0x92: 0,
- 0x93: 0,
-
- // J2C extensions
- 0x74: 4,
- 0x75: 4,
- 0x77: 4,
-}
-
-type jpegVisitor struct {
- js *jpegstructure.JpegSplitter
- writer io.Writer
-}
-
-// HandleSegment satisfies the visitor interface{} of the jpegstructure library.
-//
-// We don't really care about many of the parameters, since all we're interested
-// in here is the very last segment that was scanned.
-func (v *jpegVisitor) HandleSegment(segmentMarker byte, _ string, _ int, _ bool) error {
- segmentList := v.js.Segments()
- segments := segmentList.Segments()
- mostRecentSegment := segments[len(segments)-1]
- return v.writeSegment(mostRecentSegment)
-}
-
-func (v *jpegVisitor) writeSegment(s *jpegstructure.Segment) error {
- w := v.writer
-
- defer func() {
- // whatever happens, when we finished then evict data from the segment;
- // once we've written it we don't want it in memory anymore
- s.Data = nil
- }()
-
- if s.IsExif() {
- // Segment contains exif data, terminate!
- if err := terminateEXIF(s); err != nil {
- return err
- }
- }
-
- // The scan-data will have a marker-ID of (0) because it doesn't have a marker-ID or length.
- if s.MarkerId != 0 {
- _, err := w.Write([]byte{0xff, s.MarkerId})
- if err != nil {
- return err
- }
-
- sizeLen, found := markerLen[s.MarkerId]
- if !found || sizeLen == 2 {
- l := uint16(len(s.Data) + 2)
- b := make([]byte, 2)
- binary.BigEndian.PutUint16(b, l)
- if _, err := w.Write(b); err != nil {
- return err
- }
- } else if sizeLen == 4 {
- l := uint32(len(s.Data) + 4)
- b := make([]byte, 4)
- binary.BigEndian.PutUint32(b, l)
- if _, err := w.Write(b); err != nil {
- return err
- }
- } else if sizeLen != 0 {
- return fmt.Errorf("not a supported marker-size: MARKER-ID=(0x%02x) MARKER-SIZE-LEN=(%d)", s.MarkerId, sizeLen)
- }
- }
-
- _, err := w.Write(s.Data)
- return err
-}
diff --git a/vendor/codeberg.org/superseriousbusiness/exif-terminator/png.go b/vendor/codeberg.org/superseriousbusiness/exif-terminator/png.go
deleted file mode 100644
index b8b94efb7..000000000
--- a/vendor/codeberg.org/superseriousbusiness/exif-terminator/png.go
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- exif-terminator
- Copyright (C) 2022 SuperSeriousBusiness admin@gotosocial.org
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package terminator
-
-import (
- "io"
-
- pngstructure "github.com/superseriousbusiness/go-png-image-structure/v2"
-)
-
-type pngVisitor struct {
- ps *pngstructure.PngSplitter
- writer io.Writer
- lastWrittenChunk int
-}
-
-func (v *pngVisitor) split(data []byte, atEOF bool) (int, []byte, error) {
- // execute the ps split function to read in data
- advance, token, err := v.ps.Split(data, atEOF)
- if err != nil {
- return advance, token, err
- }
-
- // if we haven't written anything at all yet, then
- // write the png header back into the writer first
- if v.lastWrittenChunk == -1 {
- if _, err := v.writer.Write(pngstructure.PngSignature[:]); err != nil {
- return advance, token, err
- }
- }
-
- // Check if the splitter now has
- // any new chunks in it for us.
- chunkSlice, err := v.ps.Chunks()
- if err != nil {
- return advance, token, err
- }
-
- // Write each chunk by passing it
- // through our custom write func,
- // which strips out exif and fixes
- // the CRC of each chunk.
- chunks := chunkSlice.Chunks()
- for i := v.lastWrittenChunk + 1; i < len(chunks); i++ {
- chunk := chunks[i]
-
- if chunk.Type == pngstructure.EXifChunkType {
- // Finally, some exif data! Terminate it!!
- if err := terminateEXIF(chunkSlice); err != nil {
- return advance, token, err
- }
-
- // Update chunk crc.
- chunk.UpdateCrc32()
- }
-
- // Write this new chunk.
- if _, err := chunk.WriteTo(v.writer); err != nil {
- return advance, token, err
- }
- v.lastWrittenChunk = i
-
- // Zero data; here you
- // go garbage collector.
- chunk.Data = nil
- }
-
- return advance, token, err
-}
diff --git a/vendor/codeberg.org/superseriousbusiness/exif-terminator/terminator.go b/vendor/codeberg.org/superseriousbusiness/exif-terminator/terminator.go
deleted file mode 100644
index 5793b8599..000000000
--- a/vendor/codeberg.org/superseriousbusiness/exif-terminator/terminator.go
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- exif-terminator
- Copyright (C) 2022 SuperSeriousBusiness admin@gotosocial.org
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package terminator
-
-import (
- "bufio"
- "bytes"
- "errors"
- "fmt"
- "io"
-
- jpegstructure "github.com/superseriousbusiness/go-jpeg-image-structure/v2"
- pngstructure "github.com/superseriousbusiness/go-png-image-structure/v2"
-)
-
-func Terminate(in io.Reader, mediaType string) (io.Reader, error) {
- // To avoid keeping too much stuff
- // in memory we want to pipe data
- // directly to the reader.
- pr, pw := io.Pipe()
-
- // Setup scanner to terminate exif into pipe writer.
- scanner, err := terminatingScanner(pw, in, mediaType)
- if err != nil {
- _ = pw.Close()
- return nil, err
- }
-
- go func() {
- var err error
-
- defer func() {
- // Always close writer, using returned
- // scanner error (if any). If err is nil
- // then the standard io.EOF will be used.
- // (this will not overwrite existing).
- pw.CloseWithError(err)
- }()
-
- // Scan through input.
- for scanner.Scan() {
- }
-
- // Set error on return.
- err = scanner.Err()
- }()
-
- return pr, nil
-}
-
-func TerminateInto(out io.Writer, in io.Reader, mediaType string) error {
- // Setup scanner to terminate exif from 'in' to 'out'.
- scanner, err := terminatingScanner(out, in, mediaType)
- if err != nil {
- return err
- }
-
- // Scan through input.
- for scanner.Scan() {
- }
-
- // Return scan errors.
- return scanner.Err()
-}
-
-func terminatingScanner(out io.Writer, in io.Reader, mediaType string) (*bufio.Scanner, error) {
- scanner := bufio.NewScanner(in)
-
- // 40mb buffer size should be enough
- // to scan through most file chunks
- // without running into issues, they're
- // usually chunked smaller than this...
- scanner.Buffer(nil, 40*1024*1024)
-
- switch mediaType {
- case "image/jpeg", "jpeg", "jpg":
- v := &jpegVisitor{
- writer: out,
- }
-
- // Provide the visitor to the splitter so
- // that it triggers on every section scan.
- js := jpegstructure.NewJpegSplitter(v)
-
- // The visitor also needs to read back the
- // list of segments: for this it needs to
- // know what jpeg splitter it's attached to,
- // so give it a pointer to the splitter.
- v.js = js
-
- // Jpeg visitor's 'split' function
- // satisfies bufio.SplitFunc{}.
- scanner.Split(js.Split)
-
- case "image/webp", "webp":
- // Webp visitor's 'split' function
- // satisfies bufio.SplitFunc{}.
- scanner.Split((&webpVisitor{
- writer: out,
- }).split)
-
- case "image/png", "png":
- // For pngs we need to skip the header bytes, so read
- // them in and check we're really dealing with a png.
- header := make([]byte, len(pngstructure.PngSignature))
- if _, headerError := in.Read(header); headerError != nil {
- return nil, headerError
- } else if !bytes.Equal(header, pngstructure.PngSignature[:]) {
- return nil, errors.New("could not decode png: invalid header")
- }
-
- // Don't bother checking CRC;
- // we're overwriting it anyway.
- ps := pngstructure.NewPngSplitter()
- ps.DoCheckCrc(false)
-
- // Png visitor's 'split' function
- // satisfies bufio.SplitFunc{}.
- scanner.Split((&pngVisitor{
- ps: ps,
- writer: out,
- lastWrittenChunk: -1,
- }).split)
-
- default:
- return nil, fmt.Errorf("mediaType %s cannot be processed", mediaType)
- }
-
- return scanner, nil
-}
diff --git a/vendor/codeberg.org/superseriousbusiness/exif-terminator/webp.go b/vendor/codeberg.org/superseriousbusiness/exif-terminator/webp.go
deleted file mode 100644
index b050f38fc..000000000
--- a/vendor/codeberg.org/superseriousbusiness/exif-terminator/webp.go
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- exif-terminator
- Copyright (C) 2022 SuperSeriousBusiness admin@gotosocial.org
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package terminator
-
-import (
- "encoding/binary"
- "errors"
- "io"
-)
-
-const (
- riffHeader = "RIFF"
- webpHeader = "WEBP"
- exifFourcc = "EXIF"
- xmpFourcc = "XMP "
-)
-
-var (
- errNoRiffHeader = errors.New("no RIFF header")
- errNoWebpHeader = errors.New("not a WEBP file")
- errInvalidChunk = errors.New("invalid chunk")
-)
-
-type webpVisitor struct {
- writer io.Writer
- doneHeader bool
-}
-
-func (v *webpVisitor) split(data []byte, atEOF bool) (advance int, token []byte, err error) {
- // parse/write the header first
- if !v.doneHeader {
-
- // const rifHeaderSize = 12
- if len(data) < 12 {
- if atEOF {
- err = errNoRiffHeader
- }
- return
- }
-
- if string(data[:4]) != riffHeader {
- err = errNoRiffHeader
- return
- }
-
- if string(data[8:12]) != webpHeader {
- err = errNoWebpHeader
- return
- }
-
- if _, err = v.writer.Write(data[:12]); err != nil {
- return
- }
-
- advance += 12
- data = data[12:]
- v.doneHeader = true
- }
-
- for {
- // need enough for
- // fourcc and size
- if len(data) < 8 {
- return
- }
-
- size := int64(binary.LittleEndian.Uint32(data[4:]))
-
- if (size & 1) != 0 {
- // odd chunk size:
- // extra padding byte
- size++
- }
-
- // wait until there is enough
- if int64(len(data)) < 8+size {
- return
- }
-
- // replace exif/xmp with blank
- switch string(data[:4]) {
- case exifFourcc, xmpFourcc:
- clear(data[8 : 8+size])
- }
-
- if _, err = v.writer.Write(data[:8+size]); err != nil {
- return
- }
-
- advance += 8 + int(size)
- data = data[8+size:]
- }
-}