Documentation
¶
Index ¶
- Constants
- func Address() string
- func BufferSize() int
- func Create(override *Config) error
- func EnableKeepAlive() bool
- func EnablePacketLogging() bool
- func Experimental() bool
- func IdleTimeout() int
- func Load() error
- func LogLevel() string
- func MaxConnections() int
- func New() error
- func Port() string
- func ReadTimeout() int
- func ShutdownTimeout() int
- func WriteTimeout() int
- type Config
Constants ¶
const CONFIG = "./bmux.config.json"
Variables ¶
This section is empty.
Functions ¶
func BufferSize ¶
func BufferSize() int
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 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 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 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.