Documentation
¶
Index ¶
- func AsTemplate(s string) (*template.Template, bool)
- func Base64PCMToWAV(base64PCM string, sampleRate int, channels int, bitsPerSample int) ([]byte, error)
- func DecodeJSON(r io.Reader, v any) error
- func EnvironmentVariables() map[string]string
- func ExecuteTemplate(t *template.Template, data map[string]any) (string, error)
- func Ptr[T any](val T) *T
- func TryAndParseAsTemplate(s string, data map[string]any) string
- func WeightedRandomIndex(weights []int) int
- type RawMessage
- type TTLSyncMap
- func (m *TTLSyncMap) Clear()
- func (m *TTLSyncMap) Delete(key interface{})
- func (m *TTLSyncMap) Get(key interface{}) (interface{}, bool)
- func (m *TTLSyncMap) GetOrSet(key, value interface{}) (actual interface{}, loaded bool)
- func (m *TTLSyncMap) Len() int
- func (m *TTLSyncMap) Range(f func(key, value interface{}) bool)
- func (m *TTLSyncMap) Refresh(key interface{}) bool
- func (m *TTLSyncMap) Set(key, value interface{})
- func (m *TTLSyncMap) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64PCMToWAV ¶ added in v0.1.11
func Base64PCMToWAV( base64PCM string, sampleRate int, channels int, bitsPerSample int, ) ([]byte, error)
Base64PCMToWAV converts base64-encoded PCM audio into a WAV byte slice.
func EnvironmentVariables ¶
func ExecuteTemplate ¶
func WeightedRandomIndex ¶
Types ¶
type RawMessage ¶
type RawMessage []byte
RawMessage mirrors the behavior of encoding/json.RawMessage while keeping the project on the sonic JSON implementation.
func (*RawMessage) MarshalJSON ¶
func (m *RawMessage) MarshalJSON() ([]byte, error)
func (*RawMessage) UnmarshalJSON ¶
func (m *RawMessage) UnmarshalJSON(data []byte) error
type TTLSyncMap ¶
type TTLSyncMap struct {
// contains filtered or unexported fields
}
TTLSyncMap is a thread-safe map with automatic cleanup of expired entries
func NewTTLSyncMap ¶
func NewTTLSyncMap(ttl time.Duration, cleanupInterval time.Duration) *TTLSyncMap
NewTTLSyncMap creates a new TTL sync map with the specified TTL and cleanup interval ttl: time to live for each entry cleanupInterval: how often to check for expired entries (should be <= ttl)
func (*TTLSyncMap) Delete ¶
func (m *TTLSyncMap) Delete(key interface{})
Delete removes a key-value pair from the map
func (*TTLSyncMap) Get ¶
func (m *TTLSyncMap) Get(key interface{}) (interface{}, bool)
Get retrieves a value by key, returns (value, true) if found and not expired, (nil, false) otherwise
func (*TTLSyncMap) GetOrSet ¶
func (m *TTLSyncMap) GetOrSet(key, value interface{}) (actual interface{}, loaded bool)
GetOrSet retrieves a value by key if it exists and is not expired, otherwise sets the new value and returns it
func (*TTLSyncMap) Len ¶
func (m *TTLSyncMap) Len() int
Len returns the number of non-expired entries in the map
func (*TTLSyncMap) Range ¶
func (m *TTLSyncMap) Range(f func(key, value interface{}) bool)
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration. Only non-expired entries are included.
func (*TTLSyncMap) Refresh ¶
func (m *TTLSyncMap) Refresh(key interface{}) bool
Refresh updates the expiration time of an existing entry
func (*TTLSyncMap) Set ¶
func (m *TTLSyncMap) Set(key, value interface{})
Set stores a key-value pair with TTL
func (*TTLSyncMap) Stop ¶
func (m *TTLSyncMap) Stop()
Stop stops the cleanup goroutine and releases resources Call this when you're done with the map to prevent goroutine leaks