Documentation
¶
Index ¶
- Constants
- func Address() string
- func Create(override *Config) error
- func EnableMulticore() bool
- func Experimental() bool
- func HeadSize() int
- func Load(override *Config) error
- func LogLevel() string
- func MaxConnections() int
- func New(override *Config) error
- func Port() int
- func ReadTimeout() int
- func ShutdownTimeout() int
- type Config
Constants ¶
const CONFIG_PATH = "./bmux.config.json"
Variables ¶
This section is empty.
Functions ¶
func Create ¶
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 Load ¶
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 MaxConnections ¶
func MaxConnections() int
func New ¶
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 ReadTimeout ¶
func ReadTimeout() int
func ShutdownTimeout ¶
func ShutdownTimeout() int
Types ¶
type Config ¶
type Config struct {
Port int `json:"port"` // TCP listening port (defaults to 30000)
Address string `json:"address"` // TCP 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)
ReadTimeout int `json:"readTimeout"` // Read timeout in seconds (defaults to 15)
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 TCP-level configuration options.