config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const CONFIG = "./bmux.config.json"

Variables

This section is empty.

Functions

func Address

func Address() string

func BufferSize

func BufferSize() int

func Create

func Create(override *Config) error

Create writes a configuration file with either default values or overrides provided by the user.

The file is written in JSON format with indentation for readability.

Returns an error if marshaling or writing to the file fails.

Example usage:

err := config.Create(&config.Config{Port: "8080"})

func EnableKeepAlive

func EnableKeepAlive() bool

func EnablePacketLogging

func EnablePacketLogging() bool

func Experimental

func Experimental() bool

func IdleTimeout

func IdleTimeout() int

func Load

func Load() error

Load reads the configuration file from disk, parses the JSON content, and loads it into the package-level Config variable `c`.

If the config file does not exist, it will attempt to create one with default values.

Returns an error if reading or unmarshalling the file fails.

Example usage:

err := config.Load()
if err != nil {
    // handle error
}

func LogLevel

func LogLevel() string

func MaxConnections

func MaxConnections() int

func New

func New() error

New initializes the package configuration by loading the config file, if it hasn't already been loaded.

Returns an error if loading the configuration fails.

Example usage:

err := config.New()
if err != nil {
    // handle error
}

func Port

func Port() string

func ReadTimeout

func ReadTimeout() int

func ShutdownTimeout

func ShutdownTimeout() int

func WriteTimeout

func WriteTimeout() int

Types

type Config

type Config struct {
	Port                string `json:"port"`                // TCP listening port
	Address             string `json:"address"`             // TCP bind address
	Experimental        bool   `json:"experimental"`        // Enable experimental routes
	LogLevel            string `json:"logLevel"`            // Logging level (info, debug, etc.)
	BufferSize          int    `json:"bufferSize"`          // Size in bytes for read buffer
	MaxConnections      int    `json:"maxConnections"`      // Maximum simultaneous connections
	ReadTimeout         int    `json:"readTimeout"`         // Read timeout in seconds
	WriteTimeout        int    `json:"writeTimeout"`        // Write timeout in seconds
	IdleTimeout         int    `json:"idleTimeout"`         // Idle connection timeout in seconds
	ShutdownTimeout     int    `json:"shutdownTimeout"`     // Graceful shutdown timeout in seconds
	EnableKeepAlive     bool   `json:"enableKeepAlive"`     // Whether to enable TCP keep-alive
	EnablePacketLogging bool   `json:"enablePacketLogging"` // whether packet logging middleware should be enabled
}

Config defines TCP/server-level configuration options.

Jump to

Keyboard shortcuts

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