Update dependencies

This commit is contained in:
eleksir
2026-02-10 20:54:39 +03:00
parent f2fc168abe
commit 170d0d0ed4
559 changed files with 66718 additions and 72415 deletions

3
vendor/github.com/cockroachdb/fifo/README.md generated vendored Normal file
View File

@@ -0,0 +1,3 @@
DEPRECATED
Moved to [github.com/cockroachdb/crlib](https://github.com/cockroachdb/crlib/tree/main/fifo)

View File

@@ -26,13 +26,47 @@ type Buffer struct {
}
// SingleTagBuffer returns a Buffer with a single tag.
func SingleTagBuffer(key string, value interface{}) *Buffer {
func SingleTagBuffer(key string, value any) *Buffer {
b := &Buffer{}
b.init(1, 1)
b.tags[0] = Tag{key: key, value: value}
return b
}
// BuildBuffer is used to build a *Buffer that contains an arbitrary number
// of tags. Sample usage:
//
// bld := BuildBuffer()
// bld.Add("a", 1)
// bld.Add("b", 2)
// buf := bld.Finish()
//
// It is equivalent to using SingleTagBuffer() followed by Buffer.Add() calls,
// but avoids allocating each intermediate buffer.
func BuildBuffer() BufferBuilder {
bld := BufferBuilder{b: &Buffer{}}
bld.b.init(0, 0)
return bld
}
// BufferBuilder is returned by BuildBuffer.
type BufferBuilder struct {
b *Buffer
}
// Add a log tag to the buffer. If the key was added already, the value is
// replaced.
func (bld *BufferBuilder) Add(key string, value any) {
bld.b.addOrReplace(key, value)
}
// Finish returns the buffer with the tags that were added to the builder.
func (bld *BufferBuilder) Finish() *Buffer {
b := bld.b
bld.b = nil
return b
}
// Get returns the tags, as a slice. This slice must not be modified.
func (b *Buffer) Get() []Tag {
return b.tags
@@ -55,7 +89,7 @@ func (b *Buffer) GetTag(key string) (Tag, bool) {
// Add returns a new buffer with one more tag. If the tag has the same key as an
// earlier tag, that tag is overwritten.
// The receiver can be nil.
func (b *Buffer) Add(key string, value interface{}) *Buffer {
func (b *Buffer) Add(key string, value any) *Buffer {
if b == nil {
return SingleTagBuffer(key, value)
}
@@ -191,7 +225,7 @@ func (b *Buffer) init(length, capacityHint int) {
}
}
func (b *Buffer) addOrReplace(key string, value interface{}) {
func (b *Buffer) addOrReplace(key string, value any) {
for i := range b.tags {
if b.tags[i].key == key {
b.tags[i].value = value

View File

@@ -21,6 +21,9 @@ type contextLogTagsKey struct{}
// FromContext returns the tags stored in the context (by WithTags, AddTag, or
// AddTags).
func FromContext(ctx context.Context) *Buffer {
if fromContextFn != nil {
return fromContextFn(ctx)
}
val := ctx.Value(contextLogTagsKey{})
if val == nil {
return nil
@@ -31,6 +34,9 @@ func FromContext(ctx context.Context) *Buffer {
// WithTags returns a context with the given tags. Any existing tags are
// ignored.
func WithTags(ctx context.Context, tags *Buffer) context.Context {
if withTagsFn != nil {
return withTagsFn(ctx, tags)
}
return context.WithValue(ctx, contextLogTagsKey{}, tags)
}
@@ -63,3 +69,19 @@ func AddTags(ctx context.Context, tags *Buffer) context.Context {
}
return WithTags(ctx, newB)
}
// OverrideContextFuncs can be used to override the implementation of
// FromContext and WithTags. This is useful if we have a more efficient
// implementation of context-associated values.
//
// Must be called before WithTags or FromContext are called.
func OverrideContextFuncs(
fromContext func(ctx context.Context) *Buffer,
withTags func(ctx context.Context, tags *Buffer) context.Context,
) {
fromContextFn = fromContext
withTagsFn = withTags
}
var fromContextFn func(ctx context.Context) *Buffer
var withTagsFn func(ctx context.Context, tags *Buffer) context.Context

View File

@@ -130,6 +130,16 @@ func (b *StringBuilder) SafeRune(s i.SafeRune) {
_ = b.Buffer.WriteRune(rune(s))
}
func (b *StringBuilder) SafeByte(s i.SafeByte) {
b.SetMode(ib.SafeEscaped)
_ = b.Buffer.WriteByte(byte(s))
}
func (b *StringBuilder) SafeBytes(s i.SafeBytes) {
b.SetMode(ib.SafeEscaped)
_, _ = b.Buffer.Write([]byte(s))
}
// UnsafeString is part of the SafeWriter interface.
func (b *StringBuilder) UnsafeString(s string) {
b.SetMode(ib.UnsafeEscaped)

View File

@@ -65,6 +65,12 @@ type SafeWriter interface {
// SafeRune emits a safe rune.
SafeRune(SafeRune)
// SafeByte emits a safe byte.
SafeByte(SafeByte)
// SafeBytes emits a safe byte slice.
SafeBytes(SafeBytes)
// Print emits its arguments separated by spaces.
// For each argument it dynamically checks for the SafeFormatter or
// SafeValue interface and either use that, or mark the argument
@@ -119,6 +125,18 @@ type SafeRune rune
// SafeValue makes SafeRune a SafeValue.
func (SafeRune) SafeValue() {}
// SafeByte represents a byte that is not a sensitive value.
type SafeByte byte
// SafeValue makes SafeByte a SafeValue.
func (SafeByte) SafeValue() {}
// SafeBytes represents a byte slice that is not a sensitive value.
type SafeBytes []byte
// SafeValue makes SafeBytes a SafeValue.
func (SafeBytes) SafeValue() {}
// SafeValue is a marker interface to be implemented by types that
// alias base Go types and whose natural representation via Printf is
// always safe for reporting.

View File

@@ -46,6 +46,18 @@ func (p *pp) SafeRune(r i.SafeRune) {
p.buf.WriteRune(rune(r))
}
// SafeByte implements SafePrinter.
func (p *pp) SafeByte(r i.SafeByte) {
defer p.startSafeOverride().restore()
p.buf.WriteByte(byte(r))
}
// SafeBytes implements SafePrinter.
func (p *pp) SafeBytes(r i.SafeBytes) {
defer p.startSafeOverride().restore()
p.buf.Write(r)
}
func (p *pp) Print(args ...interface{}) {
defer p.buf.SetMode(p.buf.GetMode())
np := newPrinter()

View File

@@ -176,6 +176,27 @@ func (tb *TokenBucket) Exhausted() time.Duration {
return time.Duration(tb.exhaustedMicros+ongoingExhaustionMicros) * time.Microsecond
}
// EnsureLowerBound ensures that the current number of tokens is at least
// minTokens. The value of minTokens can be negative. This is useful in
// scenarios where the use of Adjust can be used to subtract a large amount of
// tokens, resulting in a token bucket with a very low negative number of
// tokens which would take a long time to recover to zero. In such scenarios,
// a periodic call to EnsureLowerBound is useful to reset to a better state.
func (tb *TokenBucket) EnsureLowerBound(minTokens Tokens) {
tb.Update()
if tb.current >= minTokens {
return
}
// tb.current < minTokens.
tb.current = minTokens
if tb.current > tb.burst {
tb.current = tb.burst
}
if tb.current > 0 {
tb.updateExhaustedMicros()
}
}
// Available returns the currently available tokens (can be -ve). Exported only
// for metrics.
func (tb *TokenBucket) Available() Tokens {