{"modulePath":"github.com/livekit/protocol","version":"v1.55.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\nCopyright (c) 2016,2020 Uber Technologies, Inc.\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n\nSOURCE: [https://github.com/uber-go/ratelimit/blob/main/limiter\\_mutexbased.go](https://github.com/uber-go/ratelimit/blob/main/limiter_mutexbased.go) EDIT: slight modification to allow setting rate limit on the fly SCOPE: LeakyBucket\n\n## Constants\n\n```go\nconst (\n\tDataChannelRpcMaxRoundTripLatency    = 7000 * time.Millisecond\n\tDataChannelRpcMaxMessageBytes        = 256\n\tDataChannelRpcMaxDataBytes           = 15360 // 15KiB\n\tDataChannelRpcMaxPayloadBytes        = 15360 // 15KiB\n\tDataChannelRpcDefaultResponseTimeout = 15000 * time.Millisecond\n)\n```\n\n```go\nconst (\n\tRoomPrefix                         = guid.RoomPrefix\n\tNodePrefix                         = guid.NodePrefix\n\tParticipantPrefix                  = guid.ParticipantPrefix\n\tTrackPrefix                        = guid.TrackPrefix\n\tDataTrackPrefix                    = guid.DataTrackPrefix\n\tAPIKeyPrefix                       = guid.APIKeyPrefix\n\tEgressPrefix                       = guid.EgressPrefix\n\tIngressPrefix                      = guid.IngressPrefix\n\tSIPTrunkPrefix                     = guid.SIPTrunkPrefix\n\tSIPDispatchRulePrefix              = guid.SIPDispatchRulePrefix\n\tSIPCallPrefix                      = guid.SIPCallPrefix\n\tSIPTransferPrefix                  = guid.SIPTransferPrefix\n\tRPCPrefix                          = guid.RPCPrefix\n\tWHIPResourcePrefix                 = guid.WHIPResourcePrefix\n\tRTMPResourcePrefix                 = guid.RTMPResourcePrefix\n\tURLResourcePrefix                  = guid.URLResourcePrefix\n\tSIPHostnamePrefix                  = guid.SIPHostnamePrefix\n\tAgentWorkerPrefix                  = guid.AgentWorkerPrefix\n\tAgentJobPrefix                     = guid.AgentJobPrefix\n\tAgentDispatchPrefix                = guid.AgentDispatchPrefix\n\tCloudAgentPrefix                   = guid.CloudAgentPrefix\n\tCloudAgentRegionPrefix             = guid.CloudAgentRegionPrefix\n\tCloudAgentVersionPrefix            = guid.CloudAgentVersionPrefix\n\tCloudAgentSecretPrefix             = guid.CloudAgentSecretPrefix\n\tCloudAgentWorkerPrefix             = guid.CloudAgentWorkerPrefix\n\tCloudAgentPrivateLinkPrefix        = guid.CloudAgentPrivateLinkPrefix\n\tCloudAgentPrivateLinkClusterPrefix = guid.CloudAgentPrivateLinkClusterPrefix\n\tCloudAgentPrivateLinkGatewayPrefix = guid.CloudAgentPrivateLinkGatewayPrefix\n\tCloudAgentPrivateLinkSecretPrefix  = guid.CloudAgentPrivateLinkSecretPrefix\n\tScenarioPrefix                     = guid.ScenarioPrefix\n\tScenarioGroupPrefix                = guid.ScenarioGroupPrefix\n)\n```\n\n```go\nconst (\n\tGuidSize = guid.Size\n)\n```\n\n```go\nconst (\n\tMetricsBatchBuilderInvalidTimeSeriesMetricId = -1\n)\n```\n\n## Variables\n\n```go\nvar (\n\tErrInvalidMetricLabel           = errors.New(\"invalid metric label\")\n\tErrFilteredMetricLabel          = errors.New(\"filtered metric label\")\n\tErrInvalidTimeSeriesMetricIndex = errors.New(\"invalid time series metric index\")\n)\n```\n\n```go\nvar (\n\tErrAnachronousSample = errors.New(\"anachronous sample\")\n)\n```\n\n```go\nvar ErrMaxAttemptsReached = errors.New(\"max attempts reached\")\n```\n\n## Functions\n\n```go\nfunc Abs[T constraints.Signed | constraints.Float](v T) T\n```\n\n```go\nfunc AggregateRTPStats(statsList []*livekit.RTPStats, gapHistogramSize int) *livekit.RTPStats\n```\n\n```go\nfunc AwaitPromise[T any](ctx context.Context, p *Promise[T]) (T, error)\n```\n\n```go\nfunc CastStringSlice[OutType, InType ~string](src []InType) []OutType\n```\n\n```go\nfunc CloneProto[T proto.Message](m T) T\n```\n\n```go\nfunc CloneProtoRedacted[T proto.Message](m T) T\n```\n\n```go\nfunc CloneProtoSlice[T proto.Message](ms []T) []T\n```\n\n```go\nfunc CloseFunc[T CloseFuncType](fn T) io.Closer\n```\n\n```go\nfunc DeepCopy[T any](v T) T\n```\n\n```go\nfunc EnableLockTracker()\n```\nEnableLockTracker enable lock tracking background worker. This should be called during init\n\n```go\nfunc ErrIsTerminal(err error) bool\n```\n\n```go\nfunc ErrorIsOneOf(err error, targets ...error) bool\n```\n\n```go\nfunc FastLogisticFunc(x0, L, k float64) func(x float64) float64\n```\n\n```go\nfunc GetMimeTypeForAudioCodec(codec livekit.AudioCodec) string\n```\n\n```go\nfunc GetMimeTypeForVideoCodec(codec livekit.VideoCodec) string\n```\n\n```go\nfunc HashedID(id string) string\n```\nHashedID creates a hashed ID from a unique string\n\n```go\nfunc HedgeCall[T any](ctx context.Context, params HedgeParams[T]) (v T, err error)\n```\nrace retries if the function takes too long to return |---------------- attempt 1 ----------------| |    delay    |--------- attempt 2 ---------|\n\nIf an attempt fails while no others are in flight, the next attempt starts immediately rather than waiting out RetryDelay: |-- attempt 1 --X|-- attempt 2 ----------|\n\n```go\nfunc IsConnectionQualityHigher(prev livekit.ConnectionQuality, curr livekit.ConnectionQuality) bool\n```\n\n```go\nfunc IsConnectionQualityLower(prev livekit.ConnectionQuality, curr livekit.ConnectionQuality) bool\n```\n\n```go\nfunc LocalNodeID() (string, error)\n```\n\n```go\nfunc LogisticFunc(x0, L, k float64) func(x float64) float64\n```\n\n```go\nfunc MarshalGuid[T livekit.Guid](id T) livekit.GuidBlock\n```\n\n```go\nfunc NewGuid(prefix string) string\n```\n\n```go\nfunc NumMutexes() int\n```\n\n```go\nfunc ParallelExec[T any](vals []T, parallelThreshold, step uint64, fn func(T))\n```\nParallelExec will executes the given function with each element of vals, if len(vals) \u003e= parallelThreshold, will execute them in parallel, with the given step size. So fn must be thread-safe.\n\n```go\nfunc PopulateHolderStacks(stuck []*StuckLock)\n```\nPopulateHolderStacks resolves the current stack of each stuck lock's holder goroutines from a single snapshot of all goroutine stacks. The snapshot stops the world; call it once per detection, not per lock.\n\n```go\nfunc RandomSecret() string\n```\n\n```go\nfunc Redact(s, name string) string\n```\n\n```go\nfunc RedactIdentifier(identifier string) string\n```\n\n```go\nfunc RedactStreamKey(url string) (string, bool)\n```\n\n```go\nfunc RedactUrlQueryValues(rawUrl string) string\n```\nRedactUrlQueryValues fully redacts every query parameter value in rawUrl, keeping parameter names intact.\n\n```go\nfunc Retry(ctx context.Context, minTime, maxTime, timeout time.Duration, f func(ctx context.Context) error) error\n```\n\n```go\nfunc ScreenError(err error, ignored ...error) error\n```\n\n```go\nfunc TerminalError(err error) error\n```\n\n```go\nfunc ToggleLockTrackerStackTraces(enable bool)\n```\n\n```go\nfunc UnmarshalGuid[T livekit.Guid](b livekit.GuidBlock) T\n```\n\n## Types\n\n```go\ntype Bitmap[T bitmapNumber] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewBitmap[T bitmapNumber](size int) *Bitmap[T]\n```\n\n```go\nfunc (b *Bitmap[T]) Clear(val T)\n```\n\n```go\nfunc (b *Bitmap[T]) ClearRange(min, max T)\n```\n\n```go\nfunc (b *Bitmap[T]) GetAndSet(val T) bool\n```\n\n```go\nfunc (b *Bitmap[T]) IsSet(val T) bool\n```\n\n```go\nfunc (b *Bitmap[T]) Len() int\n```\n\n```go\nfunc (b *Bitmap[T]) Set(val T)\n```\n\n```go\nfunc (b *Bitmap[T]) SetRange(min, max T)\n```\n\n```go\ntype Clock interface {\n\tNow() time.Time\n\tSleep(time.Duration)\n}\n```\n\n```go\ntype CloseFuncType interface {\n\t~func() error | ~func()\n}\n```\n\n```go\ntype Closers []io.Closer\n```\n\n```go\nfunc CombineClosers(cs ...io.Closer) Closers\n```\n\n```go\nfunc (s *Closers) Close() error\n```\n\n```go\ntype ConfigBuilder[T any] = configutil.Builder[T]\n```\n\n```go\ntype ConfigDefaulter[T any] = configutil.Defaulter[T]\n```\n\n```go\ntype ConfigObserver[T any] = configutil.Observer[T]\n```\n\n```go\nfunc NewConfigObserver[T any](path string, builder ConfigBuilder[T]) (*ConfigObserver[T], *T, error)\n```\n\n```go\ntype DataChannelRpcError struct {\n\tCode    DataChannelRpcErrorCode\n\tMessage string\n\tData    string\n}\n```\n\n```go\nfunc DataChannelRpcErrorFromBuiltInCodes(code DataChannelRpcErrorCode, data string) *DataChannelRpcError\n```\n\n```go\nfunc (e *DataChannelRpcError) Error() string\n```\n\n```go\nfunc (e *DataChannelRpcError) PsrpcError() psrpc.Error\n```\n\n```go\ntype DataChannelRpcErrorCode uint32\n```\n\n```go\nconst (\n\tDataChannelRpcApplicationError DataChannelRpcErrorCode = 1500 + iota\n\tDataChannelRpcConnectionTimeout\n\tDataChannelRpcResponseTimeout\n\tDataChannelRpcRecipientDisconnected\n\tDataChannelRpcResponsePayloadTooLarge\n\tDataChannelRpcSendFailed\n\tDataChannelRpcConnectionClosed\n)\n```\n\n```go\nconst (\n\tDataChannelRpcUnsupportedMethod DataChannelRpcErrorCode = 1400 + iota\n\tDataChannelRpcRecipientNotFound\n\tDataChannelRpcRequestPayloadTooLarge\n\tDataChannelRpcUnsupportedServer\n\tDataChannelRpcUnsupportedVersion\n)\n```\n\n```go\ntype DataChannelRpcPendingAckHandler struct {\n\tResolve             func()\n\tParticipantIdentity string\n}\n```\n\n```go\ntype DataChannelRpcPendingResponseHandler struct {\n\tResolve             func(payload string, err *DataChannelRpcError)\n\tParticipantIdentity string\n}\n```\n\n```go\ntype DedupedSlice[T comparable] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewDedupedSlice[T comparable](maxLen int) *DedupedSlice[T]\n```\n\n```go\nfunc (d *DedupedSlice[T]) Add(val T) bool\n```\n\n```go\nfunc (d *DedupedSlice[T]) Clear()\n```\n\n```go\nfunc (d *DedupedSlice[T]) Get() []T\n```\n\n```go\nfunc (d *DedupedSlice[T]) Has(val T) bool\n```\n\n```go\nfunc (d *DedupedSlice[T]) Len() int\n```\n\n```go\ntype ErrArray struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (e *ErrArray) AppendErr(err error)\n```\n\n```go\nfunc (e *ErrArray) ToError() psrpc.Error\n```\n\n```go\ntype EventMetric struct {\n\tMetricLabel         livekit.MetricLabel\n\tCustomMetricLabel   string\n\tParticipantIdentity livekit.ParticipantIdentity\n\tTrackID             livekit.TrackID\n\tStartedAt           time.Time\n\tEndedAt             time.Time\n\tNormalizedStartedAt time.Time\n\tNormalizedEndedAt   time.Time\n\tMetadata            string\n\tRid                 string\n}\n```\n\n```go\ntype FlowGraph struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewFlowGraph(n int64) FlowGraph\n```\n\n```go\nfunc (g *FlowGraph) AddEdge(s, t, cap, cost int64)\n```\n\n```go\ntype Graph[K comparable, N GraphNodeProps[K], E GraphEdgeProps] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewGraph[K comparable, N GraphNodeProps[K], E GraphEdgeProps]() *Graph[K, N, E]\n```\n\n```go\nfunc (g *Graph[K, N, E]) DeleteEdge(src, dst K)\n```\n\n```go\nfunc (g *Graph[K, N, E]) DeleteNode(id K)\n```\n\n```go\nfunc (g *Graph[K, N, E]) Edge(src, dst K) (p E)\n```\n\n```go\nfunc (g *Graph[K, N, E]) HasEdge(src, dst K) bool\n```\n\n```go\nfunc (g *Graph[K, N, E]) HasNode(id K) bool\n```\n\n```go\nfunc (g *Graph[K, N, E]) InEdges(dst K) map[K]E\n```\n\n```go\nfunc (g *Graph[K, N, E]) InsertEdge(src, dst K, props E)\n```\n\n```go\nfunc (g *Graph[K, N, E]) InsertNode(props N)\n```\n\n```go\nfunc (g *Graph[K, N, E]) Node(id K) (props N)\n```\n\n```go\nfunc (g *Graph[K, N, E]) NodeIDs() []K\n```\n\n```go\nfunc (g *Graph[K, N, E]) OutEdges(src K) map[K]E\n```\n\n```go\nfunc (g *Graph[K, N, E]) ShortestPath(src, dst K) ([]N, int64)\n```\n\n```go\nfunc (g *Graph[K, N, E]) Size() int\n```\n\n```go\nfunc (g *Graph[K, N, E]) TopologicalSort() []N\n```\n\n```go\ntype GraphEdge[N, E any] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype GraphEdgeProps interface {\n\tLength() int64\n}\n```\n\n```go\ntype GraphNode[T any] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype GraphNodeProps[K comparable] interface {\n\tID() K\n}\n```\n\n```go\ntype HedgeParams[T any] struct {\n\tTimeout       time.Duration\n\tRetryDelay    time.Duration\n\tMaxAttempts   int\n\tIsRecoverable func(err error) bool\n\tFunc          func(context.Context) (T, error)\n}\n```\n\n```go\ntype HolderStrength int32\n```\nHolderStrength describes how a stuck lock is held.\n\n```go\nconst (\n\tHolderExclusive HolderStrength = iota // Mutex, RWMutex write lock\n\tHolderShared                          // RWMutex read locks\n)\n```\n\n```go\nfunc (s HolderStrength) String() string\n```\n\n```go\ntype KillableService interface {\n\tKill()\n}\n```\n\n```go\ntype LatencyAggregate struct {\n\t// contains filtered or unexported fields\n}\n```\na ring buffer of welford mean/var summaries used to aggregate jitter and rtt.\n\n```go\nfunc NewLatencyAggregate(interval, windowLength time.Duration) *LatencyAggregate\n```\n\n```go\nfunc (a *LatencyAggregate) Get(ts time.Duration) (Welford, bool)\n```\n\n```go\nfunc (a *LatencyAggregate) MarshalLogObject(e zapcore.ObjectEncoder) error\n```\n\n```go\nfunc (a *LatencyAggregate) Summarize() Welford\n```\naggregate the interval summaries\n\n```go\nfunc (a *LatencyAggregate) SummarizeLast(d time.Duration) Welford\n```\n\n```go\nfunc (a *LatencyAggregate) Update(ts time.Duration, v float64)\n```\nextend the ring to contain ts then merge the value into the interval summary.\n\n```go\ntype LeakyBucket struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewLeakyBucket(rateLimit int, slack int, clock Clock) *LeakyBucket\n```\nNewLeakyBucket initiates LeakyBucket with rateLimit, slack, and clock.\n\nrateLimit is defined as the number of request per second.\n\nslack is defined as the number of allowed requests before limiting. e.g. when slack=5, LeakyBucket will allow 5 requests to pass through Take without a sleep as long as these requests are under perRequest duration.\n\n```go\nfunc (lb *LeakyBucket) Take() time.Time\n```\nTake blocks to ensure that the time spent between multiple Take calls is on average time.Second/rate.\n\nTake is THREAD SAFE and BLOCKING.\n\n```go\nfunc (lb *LeakyBucket) Update(rateLimit int, slack int)\n```\nUpdate sets the underlying rate limit and slack. The setting may not be applied immediately.\n\nUpdate is THREAD SAFE and NON-BLOCKING.\n\n```go\ntype MetricLabelRange struct {\n\tStartInclusive livekit.MetricLabel\n\tEndInclusive   livekit.MetricLabel\n}\n```\n\n```go\ntype MetricRestrictedLabels struct {\n\tLabelRanges         []MetricLabelRange\n\tParticipantIdentity livekit.ParticipantIdentity\n}\n```\n\n```go\ntype MetricSample struct {\n\tAt           time.Time\n\tNormalizedAt time.Time\n\tValue        float32\n}\n```\n\n```go\ntype MetricsBatchBuilder struct {\n\t*livekit.MetricsBatch\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewMetricsBatchBuilder() *MetricsBatchBuilder\n```\n\n```go\nfunc (m *MetricsBatchBuilder) AddEventMetric(em EventMetric) error\n```\n\n```go\nfunc (m *MetricsBatchBuilder) AddMetricSamplesToTimeSeriesMetric(timeSeriesMetricIdx int, samples []MetricSample) error\n```\n\n```go\nfunc (m *MetricsBatchBuilder) AddTimeSeriesMetric(tsm TimeSeriesMetric) (int, error)\n```\n\n```go\nfunc (m *MetricsBatchBuilder) IsEmpty() bool\n```\n\n```go\nfunc (m *MetricsBatchBuilder) Merge(other *livekit.MetricsBatch)\n```\n\n```go\nfunc (m *MetricsBatchBuilder) SetRestrictedLabels(mrl MetricRestrictedLabels)\n```\n\n```go\nfunc (m *MetricsBatchBuilder) SetTime(at time.Time, normalizedAt time.Time)\n```\n\n```go\nfunc (m *MetricsBatchBuilder) ToProto() *livekit.MetricsBatch\n```\n\n```go\ntype MinCostMaxFlow struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (f *MinCostMaxFlow) ComputeMaxFlow(g FlowGraph, s, t int64) (flow, cost int64)\n```\n\n```go\nfunc (f *MinCostMaxFlow) Flow(s, t int64) int64\n```\n\n```go\ntype MultitonService[K comparable] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *MultitonService[K]) Kill()\n```\n\n```go\nfunc (s *MultitonService[K]) Replace(k K, v KillableService) func()\n```\n\n```go\ntype Mutex struct {\n\tsync.Mutex\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (m *Mutex) Lock()\n```\n\n```go\nfunc (m *Mutex) Unlock()\n```\n\n```go\ntype Promise[T any] = promise.Promise[T]\n```\nPromise must stay an alias rather than a defined type: a promise built under either spelling has to satisfy an interface written against the other.\n\n```go\nfunc GoPromise[T any](f func() (T, error)) *Promise[T]\n```\n\n```go\nfunc NewPromise[T any]() *Promise[T]\n```\n\n```go\nfunc NewResolvedPromise[T any](result T, err error) *Promise[T]\n```\n\n```go\ntype ProtoProxy[T proto.Message] struct {\n\t// contains filtered or unexported fields\n}\n```\nProtoProxy is a caching proxy for protobuf messages that may be expensive to compute. It is used to avoid unnecessary re-generation of Protobufs\n\n```go\nfunc NewProtoProxy[T proto.Message](refreshInterval time.Duration, updateFn func() T) *ProtoProxy[T]\n```\nNewProtoProxy creates a new ProtoProxy that regenerates underlying values at a cadence of refreshInterval this should be used for updates that should be sent periodically, but does not have the urgency of immediate delivery updateFn should provide computations required to generate the protobuf if refreshInterval is 0, then proxy will only update on MarkDirty(true)\n\n```go\nfunc (p *ProtoProxy[T]) Get() T\n```\n\n```go\nfunc (p *ProtoProxy[T]) MarkDirty(immediate bool) \u003c-chan struct{}\n```\n\n```go\nfunc (p *ProtoProxy[T]) Stop()\n```\n\n```go\nfunc (p *ProtoProxy[T]) Updated() \u003c-chan struct{}\n```\n\n```go\ntype RWMutex struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (m *RWMutex) Lock()\n```\n\n```go\nfunc (m *RWMutex) RLock()\n```\n\n```go\nfunc (m *RWMutex) RUnlock()\n```\n\n```go\nfunc (m *RWMutex) Unlock()\n```\n\n```go\ntype Scanner struct {\n\t// contains filtered or unexported fields\n}\n```\nScanner holds the source string to be searched.\n\n```go\nfunc NewKVRegexScanner(s string) Scanner\n```\n\n```go\nfunc (kv Scanner) Bool(re *regexp.Regexp, group ...string) (bool, bool)\n```\n\n```go\nfunc (kv Scanner) DurationNs(re *regexp.Regexp, group ...string) (time.Duration, bool)\n```\nDurationNs treats the captured value as nanoseconds and returns time.Duration.\n\n```go\nfunc (kv Scanner) Float64(re *regexp.Regexp, group ...string) (float64, bool)\n```\n\n```go\nfunc (kv Scanner) Int(re *regexp.Regexp, group ...string) (int, bool)\n```\n\n```go\nfunc (kv Scanner) Int64(re *regexp.Regexp, group ...string) (int64, bool)\n```\n\n```go\nfunc (kv Scanner) Raw(re *regexp.Regexp, group ...string) (string, bool)\n```\nRaw returns the first capture group by default, or a named group if provided. Example:\n\n\tre := regexp.MustCompile(`key=(\\d+)`)         // group 1\n\tkv.Raw(re)  -\u003e \"123\", true\n\tre2 := regexp.MustCompile(`key=(?P\u003cval\u003e\\d+)`) // named group \"val\"\n\tkv.Raw(re2, \"val\") -\u003e \"123\", true\n\n```go\nfunc (kv Scanner) String(re *regexp.Regexp, group ...string) (string, bool)\n```\nString returns the captured string, unquoting if it looks like \"...\" (handles \\\\\" escapes).\n\n```go\nfunc (kv Scanner) Uint(re *regexp.Regexp, group ...string) (uint, bool)\n```\n\n```go\nfunc (kv Scanner) Uint64(re *regexp.Regexp, group ...string) (uint64, bool)\n```\n\n```go\ntype SimpleGraphEdge struct{}\n```\n\n```go\nfunc (e SimpleGraphEdge) Length() int64\n```\n\n```go\ntype SimulatedClock struct {\n\tclock.Mock\n}\n```\n\n```go\ntype StuckLock struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc ScanTrackedLocks(threshold time.Duration) []*StuckLock\n```\nScanTrackedLocks check all lock trackers\n\n```go\nfunc ScanTrackedLocksI(threshold time.Duration, n int) []*StuckLock\n```\nScanTrackedLocksI check lock trackers incrementally n at a time\n\n```go\nfunc (d *StuckLock) FirstLockedAtStack() string\n```\n\n```go\nfunc (d *StuckLock) HeldSince() time.Time\n```\n\n```go\nfunc (d *StuckLock) HolderGoroutineIDs() []int64\n```\nHolderGoroutineIDs returns the ids of the goroutines holding the lock: the single holder for a Mutex, the writer or up to 8 concurrent readers for an RWMutex (compare with NumGoroutineHeld to detect overflow).\n\n```go\nfunc (d *StuckLock) HolderStacks() string\n```\nHolderStacks returns the holder goroutines' stacks as resolved by PopulateHolderStacks, or \"\" if not resolved.\n\n```go\nfunc (d *StuckLock) HolderStrength() HolderStrength\n```\nHolderStrength reports whether the lock is held exclusively or shared by readers.\n\n```go\nfunc (d *StuckLock) NumGoroutineHeld() int\n```\n\n```go\nfunc (d *StuckLock) NumGoroutineWaiting() int\n```\n\n```go\ntype SystemClock struct{}\n```\n\n```go\nfunc (SystemClock) Now() time.Time\n```\n\n```go\nfunc (SystemClock) Sleep(d time.Duration)\n```\n\n```go\ntype TimeSeriesMetric struct {\n\tMetricLabel         livekit.MetricLabel\n\tCustomMetricLabel   string\n\tParticipantIdentity livekit.ParticipantIdentity\n\tTrackID             livekit.TrackID\n\tSamples             []MetricSample\n\tRid                 string\n}\n```\n\n```go\ntype TimeSizeCache[T any] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTimeSizeCache[T any](params TimeSizeCacheParams) *TimeSizeCache[T]\n```\n\n```go\nfunc (t *TimeSizeCache[T]) Add(item *T, size int)\n```\n\n```go\nfunc (t *TimeSizeCache[T]) AddAt(item *T, size int, atNano int64)\n```\n\n```go\nfunc (t *TimeSizeCache[T]) Get() []*T\n```\n\n```go\nfunc (t *TimeSizeCache[T]) Prune()\n```\n\n```go\nfunc (t *TimeSizeCache[T]) PruneAt(atNano int64)\n```\n\n```go\ntype TimeSizeCacheParams struct {\n\tTTL     time.Duration\n\tMaxSize int\n}\n```\n\n```go\ntype TimedAggregator[T timedAggregatorNumber] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTimedAggregator[T timedAggregatorNumber](params TimedAggregatorParams) *TimedAggregator[T]\n```\n\n```go\nfunc (t *TimedAggregator[T]) AddSample(val T) error\n```\n\n```go\nfunc (t *TimedAggregator[T]) AddSampleAt(val T, at time.Time) error\n```\n\n```go\nfunc (t *TimedAggregator[T]) GetAggregate() (T, time.Duration)\n```\n\n```go\nfunc (t *TimedAggregator[T]) GetAggregateAndRestartAt(at time.Time) (T, time.Duration, error)\n```\n\n```go\nfunc (t *TimedAggregator[T]) GetAggregateAt(at time.Time) (T, time.Duration, error)\n```\n\n```go\nfunc (t *TimedAggregator[T]) GetAverage() float64\n```\n\n```go\nfunc (t *TimedAggregator[T]) GetAverageAndRestartAt(at time.Time) (float64, error)\n```\n\n```go\nfunc (t *TimedAggregator[T]) GetAverageAt(at time.Time) (float64, error)\n```\n\n```go\nfunc (t *TimedAggregator[T]) Reset()\n```\n\n```go\nfunc (t *TimedAggregator[T]) Restart()\n```\n\n```go\nfunc (t *TimedAggregator[T]) RestartAt(at time.Time)\n```\n\n```go\ntype TimedAggregatorParams struct {\n\tCapNegativeValues bool\n}\n```\n\n```go\ntype TimedVersion uint64\n```\n\n```go\nfunc TimedVersionFromProto(proto *livekit.TimedVersion) TimedVersion\n```\n\n```go\nfunc TimedVersionFromTime(t time.Time) TimedVersion\n```\n\n```go\nfunc (t TimedVersion) After(other TimedVersion) bool\n```\n\n```go\nfunc (t TimedVersion) Compare(other TimedVersion) int\n```\n\n```go\nfunc (t *TimedVersion) Downgrade(other TimedVersion) bool\n```\n\n```go\nfunc (t TimedVersion) GormDataType() string\n```\n\n```go\nfunc (t TimedVersion) IsZero() bool\n```\n\n```go\nfunc (t TimedVersion) Load() TimedVersion\n```\n\n```go\nfunc (t TimedVersion) MarshalBinary() ([]byte, error)\n```\n\n```go\nfunc (t TimedVersion) Next() TimedVersion\n```\n\n```go\nfunc (t TimedVersion) Prev() TimedVersion\n```\n\n```go\nfunc (t *TimedVersion) Scan(src interface{}) (err error)\n```\n\n```go\nfunc (t *TimedVersion) Store(other TimedVersion)\n```\n\n```go\nfunc (t TimedVersion) String() string\n```\n\n```go\nfunc (t TimedVersion) Time() time.Time\n```\n\n```go\nfunc (t TimedVersion) ToProto() *livekit.TimedVersion\n```\n\n```go\nfunc (t *TimedVersion) UnmarshalBinary(b []byte) error\n```\n\n```go\nfunc (t *TimedVersion) Update(other TimedVersion) bool\n```\n\n```go\nfunc (t *TimedVersion) Upgrade(other TimedVersion) bool\n```\n\n```go\nfunc (t TimedVersion) Value() (driver.Value, error)\n```\n\n```go\ntype TimedVersionGenerator interface {\n\tNext() TimedVersion\n}\n```\n\n```go\nfunc NewDefaultTimedVersionGenerator() TimedVersionGenerator\n```\n\n```go\ntype TimeoutQueue[T any] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (q *TimeoutQueue[T]) IterateAfter(timeout time.Duration) TimeoutQueueIterator[T]\n```\n\n```go\nfunc (q *TimeoutQueue[T]) IterateRemoveAfter(timeout time.Duration) TimeoutQueueIterator[T]\n```\n\n```go\nfunc (q *TimeoutQueue[T]) Oldest() (time.Time, bool)\n```\nOldest returns when the least recently reset item was reset, so a caller can sleep until it times out instead of polling.\n\n```go\nfunc (q *TimeoutQueue[T]) Remove(i *TimeoutQueueItem[T])\n```\n\n```go\nfunc (q *TimeoutQueue[T]) Reset(i *TimeoutQueueItem[T]) bool\n```\n\n```go\ntype TimeoutQueueItem[T any] struct {\n\tValue T\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype TimeoutQueueIterator[T any] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (i *TimeoutQueueIterator[T]) Item() *TimeoutQueueItem[T]\n```\n\n```go\nfunc (i *TimeoutQueueIterator[T]) Next() bool\n```\n\n```go\ntype Welford struct {\n\t// contains filtered or unexported fields\n}\n```\nWelford implements Welford's online algorithm for variance SEE: [https://en.wikipedia.org/wiki/Algorithms\\_for\\_calculating\\_variance#Welford's\\_online\\_algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm)\n\n```go\nfunc WelfordMerge(ws ...Welford) Welford\n```\n\n```go\nfunc (w Welford) Count() float64\n```\n\n```go\nfunc (w Welford) Mean() float64\n```\n\n```go\nfunc (w *Welford) Reset()\n```\n\n```go\nfunc (w Welford) StdDev() float64\n```\n\n```go\nfunc (w *Welford) Update(v float64)\n```\n\n```go\nfunc (w Welford) Value() (mean, variance, sampleVariance float64)\n```\n\n```go\nfunc (w Welford) Variance() float64\n```\n\n```go\ntype WorkerGroup struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (w *WorkerGroup) Go(fn func())\n```\n\n```go\nfunc (w *WorkerGroup) Wait()\n```\n\n","path":"github.com/livekit/protocol/utils","name":"utils","synopsis":"","isRedistributable":true}
