ports

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

type Allocator struct {
	// contains filtered or unexported fields
}

Allocator manages dynamic port allocation for simulators

func NewAllocator

func NewAllocator(modbusBase, mqttBase, ocppBase int) *Allocator

NewAllocator creates a new port allocator with the given base ports

func (*Allocator) Allocate

func (a *Allocator) Allocate(protocol Protocol) int

Allocate allocates the next available port for the given protocol Returns 0 if no port is available

func (*Allocator) AllocateAvailable

func (a *Allocator) AllocateAvailable(protocol Protocol) int

AllocateAvailable allocates the next available port that is free on the OS Returns 0 if no port is available

func (*Allocator) AllocateAvailableString

func (a *Allocator) AllocateAvailableString(protocol string) int

AllocateAvailableString allocates a port using a string protocol name and checks OS availability

func (*Allocator) AllocateString

func (a *Allocator) AllocateString(protocol string) int

AllocateString allocates a port using a string protocol name This maintains backward compatibility with existing code

func (*Allocator) AllocatedCount

func (a *Allocator) AllocatedCount() int

AllocatedCount returns the number of currently allocated ports

func (*Allocator) GetBasePorts

func (a *Allocator) GetBasePorts() (modbus, mqtt, ocpp int)

GetBasePorts returns the configured base ports for each protocol

func (*Allocator) IsAllocated

func (a *Allocator) IsAllocated(port int) bool

IsAllocated returns whether a port is currently allocated

func (*Allocator) IsAvailable

func (a *Allocator) IsAvailable(port int) bool

IsAvailable returns true if the port is free on the OS

func (*Allocator) Release

func (a *Allocator) Release(port int)

Release releases a previously allocated port

func (*Allocator) Reserve

func (a *Allocator) Reserve(port int) bool

Reserve reserves a specific port if available

type Protocol

type Protocol string

Protocol represents a supported protocol type

const (
	ProtocolModbus Protocol = "modbus"
	ProtocolMQTT   Protocol = "mqtt"
	ProtocolOCPP   Protocol = "ocpp"
)

Jump to

Keyboard shortcuts

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