Documentation ¶
Index ¶
- Variables
- func DrainClose(r io.ReadCloser)
- func UnsafeBuffer(s string) []byte
- func UnsafeString(b []byte) string
- type Duration
- func (d Duration) After() <-chan time.Time
- func (d Duration) AfterIf() <-chan time.Time
- func (d Duration) Clamp(lmin time.Duration, lmax time.Duration) Duration
- func (d Duration) Display() string
- func (d Duration) Duration() time.Duration
- func (d Duration) IsPositive() bool
- func (d Duration) IsZero() bool
- func (d Duration) MarshalJSON() ([]byte, error)
- func (d Duration) MarshalText() ([]byte, error)
- func (d Duration) MarshalYAML() (any, error)
- func (d Duration) Max(o time.Duration) Duration
- func (d Duration) Min(o time.Duration) Duration
- func (d Duration) Or(o time.Duration) Duration
- func (d Duration) String() string
- func (d Duration) Timeout(ctx context.Context) (context.Context, context.CancelFunc)
- func (d Duration) TimeoutCause(ctx context.Context, cause error) (context.Context, context.CancelFunc)
- func (d *Duration) UnmarshalJSON(text []byte) (err error)
- func (d *Duration) UnmarshalText(text []byte) (err error)
- func (d *Duration) UnmarshalYAML(node *yaml.Node) error
- type Enum
- type OrderedMap
- type Size
- func (d Size) Bytes() int
- func (n Size) Display() string
- func (d Size) Gigabytes() int
- func (d Size) IsPositive() bool
- func (d Size) IsZero() bool
- func (d Size) Kilobytes() int
- func (d Size) MarshalJSON() ([]byte, error)
- func (d Size) MarshalText() ([]byte, error)
- func (d Size) Megabytes() int
- func (d Size) String() string
- func (d *Size) UnmarshalJSON(text []byte) (err error)
- func (d *Size) UnmarshalText(text []byte) (err error)
- type Some
- func (a Some[T]) Elements() []T
- func (a Some[T]) Filter(f func(*T) bool) []T
- func (a Some[T]) ForEach(f func(*T))
- func (a Some[T]) IsZero() bool
- func (a Some[T]) MarshalJSON() ([]byte, error)
- func (a Some[T]) MarshalYAML() (any, error)
- func (a *Some[T]) String() string
- func (a *Some[T]) UnmarshalJSON(data []byte) error
- func (a *Some[T]) UnmarshalYAML(node *yaml.Node) error
- type TimedMutex
Constants ¶
This section is empty.
Variables ¶
View Source
var GetTotalMemory = sync.OnceValue(func() int64 { v, e := mem.VirtualMemory() if e != nil { return 16 * 1024 * 1024 * 1024 } return int64(v.Available) })
Functions ¶
func DrainClose ¶
func DrainClose(r io.ReadCloser)
always closed: 20k -> 8 seconds never closed: 20k -> 200ms assuming we lose ~1s per connection and 10k clients we should close any given reader after 5s of stalling for normal-exit
func UnsafeBuffer ¶
func UnsafeString ¶
Types ¶
type Duration ¶
func NewDuration ¶
func (Duration) After ¶
If positive duration, returns a channel that will be given the current time after the duration has passed. If non-positive duration, returns a closed channel, which will be selected immediately.
func (Duration) AfterIf ¶
If positive duration, returns a channel that will be given the current time after the duration has passed. If non-positive duration, returns nil, which will never be selected.
func (Duration) IsPositive ¶
func (Duration) MarshalJSON ¶
func (Duration) MarshalText ¶
func (Duration) MarshalYAML ¶
func (Duration) TimeoutCause ¶
func (d Duration) TimeoutCause(ctx context.Context, cause error) (context.Context, context.CancelFunc)
Creates a context that will be cancelled after the duration has passed.
func (*Duration) UnmarshalJSON ¶
func (*Duration) UnmarshalText ¶
func (*Duration) UnmarshalYAML ¶
type Enum ¶
type Enum[T comparable] struct { Names map[T]string Values map[string]T // contains filtered or unexported fields }
func NewEnum ¶
func NewEnum[T comparable](names map[T]string) Enum[T]
func (Enum[T]) MarshalText ¶
func (Enum[T]) UnmarshalText ¶
type OrderedMap ¶ added in v0.2.7
type OrderedMap[K comparable, V any] []lo.Tuple2[K, V]
func (OrderedMap[K, V]) ForEach ¶ added in v0.2.7
func (m OrderedMap[K, V]) ForEach(fn func(k K, v V))
func (OrderedMap[K, V]) Get ¶ added in v0.2.7
func (m OrderedMap[K, V]) Get(key K) (v V, ok bool)
func (OrderedMap[K, V]) MarshalYAML ¶ added in v0.2.7
func (m OrderedMap[K, V]) MarshalYAML() (any, error)
func (*OrderedMap[K, V]) Set ¶ added in v0.2.7
func (m *OrderedMap[K, V]) Set(key K, value V)
func (*OrderedMap[K, V]) UnmarshalYAML ¶ added in v0.2.7
func (m *OrderedMap[K, V]) UnmarshalYAML(node *yaml.Node) error
type Size ¶
type Size int
func (Size) IsPositive ¶
func (Size) MarshalJSON ¶
func (Size) MarshalText ¶
func (*Size) UnmarshalJSON ¶
func (*Size) UnmarshalText ¶
type Some ¶
type Some[T any] []T
func (Some[T]) MarshalJSON ¶
func (Some[T]) MarshalYAML ¶
func (*Some[T]) UnmarshalJSON ¶
func (*Some[T]) UnmarshalYAML ¶
type TimedMutex ¶
type TimedMutex struct {
// contains filtered or unexported fields
}
func (*TimedMutex) Lock ¶
func (tm *TimedMutex) Lock()
func (*TimedMutex) TryLockContext ¶
func (tm *TimedMutex) TryLockContext(ctx context.Context) bool
func (*TimedMutex) Unlock ¶
func (tm *TimedMutex) Unlock()
Click to show internal directories.
Click to hide internal directories.