config

package
v1.1.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func Address

func Address() string

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 EnableMulticore

func EnableMulticore() bool

func Experimental

func Experimental() bool

func HeadSize

func HeadSize() int

func Load

func Load(override *Config) 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(override *Config) 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() int

func Protocol added in v1.1.7

func Protocol() string

func ShutdownTimeout

func ShutdownTimeout() int

Types

type Config

type Config struct {
	Port            int    `json:"port"`            // Listening port (defaults to 30000)
	Protocol        string `json:"protocol"`        // What protocol to use (defaults to tcp://)
	Address         string `json:"address"`         // Bind address (defaults to 0.0.0.0)
	Experimental    bool   `json:"experimental"`    // Enable experimental routes (defaults to false)
	LogLevel        string `json:"logLevel"`        // Logging level (defaults to info)
	MaxConnections  int    `json:"maxConnections"`  // Maximum simultaneous connections (defaults to 1024)
	HeadSize        int    `json:"headSize"`        // The size of the header in bytes (defaults to 3)
	ShutdownTimeout int    `json:"shutdownTimeout"` // Graceful shutdown timeout in seconds (defaults to 15)
	EnableMulticore bool   `json:"enableMulticore"` // Whether to use multiple cores for the server (defaults to true)
}

Config defines network-level configuration options.

Jump to

Keyboard shortcuts

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