platform

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MTU = 1200

MTU is a safe maximum size of a UDP packet.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalDialer

type LocalDialer struct {
	Dialer net.Dialer
}

func (*LocalDialer) DialUDP

func (d *LocalDialer) DialUDP(ctx context.Context, port int) (net.Conn, error)

type Queue added in v0.3.0

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue is a simple FIFO queue backed by a ring buffer. Zero value is a Queue backed by empty slice.

func (*Queue[T]) Peek added in v0.3.0

func (rb *Queue[T]) Peek() (T, bool)

Peek returns the first element of the queue without removing it, or false if the queue is empty.

func (*Queue[T]) Pop added in v0.3.0

func (rb *Queue[T]) Pop() (T, bool)

Pop removes and returns the first element of the queue, or false if the queue is empty.

func (*Queue[T]) Push added in v0.3.0

func (rb *Queue[T]) Push(item T)

Push adds an element to the end of the queue.

type TTLMap added in v0.3.0

type TTLMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

TTLMap is a map where items are evicted after they are not accessed for a certain duration.

func NewTTLMap added in v0.3.0

func NewTTLMap[K comparable, V any](ttl time.Duration) *TTLMap[K, V]

NewTTLMap creates a new TTLMap with the given time-to-live for items.

func (*TTLMap[K, V]) GetOrSet added in v0.3.0

func (m *TTLMap[K, V]) GetOrSet(k K, newV func() V) V

GetOrSet gets a value for a key or creates a new one if it doesn't exist. It also evicts expired items.

Directories

Path Synopsis
Package udp provides a UDP-based implementation of net.Conn.
Package udp provides a UDP-based implementation of net.Conn.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL