Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ api-keys:
# Enable debug logging
debug: false

# When true, disable high-overhead HTTP middleware features to reduce per-request memory usage under high concurrency.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The new commercial-mode setting is a great addition for performance-sensitive deployments. However, it's important to note that this setting is only applied when the server starts. Changes to this value in the configuration file will not be applied dynamically during runtime via hot-reloading. It would be beneficial to clarify this in the comment to avoid confusion for users who might expect it to be hot-reloadable like other settings.

I suggest updating the comment to reflect this.

# When true, disable high-overhead HTTP middleware features to reduce per-request memory usage under high concurrency. This setting only takes effect on server startup.

commercial-mode: false

# Open OAuth URLs in incognito/private browser mode.
# Useful when you want to login with a different account without logging out from your current session.
# Default: false (but Kiro auth defaults to true for multi-account support)
Expand Down
16 changes: 9 additions & 7 deletions internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ func NewServer(cfg *config.Config, authManager *auth.Manager, accessManager *sdk
// Resolve logs directory relative to the configuration file directory.
var requestLogger logging.RequestLogger
var toggle func(bool)
if optionState.requestLoggerFactory != nil {
requestLogger = optionState.requestLoggerFactory(cfg, configFilePath)
}
if requestLogger != nil {
engine.Use(middleware.RequestLoggingMiddleware(requestLogger))
if setter, ok := requestLogger.(interface{ SetEnabled(bool) }); ok {
toggle = setter.SetEnabled
if !cfg.CommercialMode {
if optionState.requestLoggerFactory != nil {
requestLogger = optionState.requestLoggerFactory(cfg, configFilePath)
}
if requestLogger != nil {
engine.Use(middleware.RequestLoggingMiddleware(requestLogger))
if setter, ok := requestLogger.(interface{ SetEnabled(bool) }); ok {
toggle = setter.SetEnabled
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type Config struct {
// Debug enables or disables debug-level logging and other debug features.
Debug bool `yaml:"debug" json:"debug"`

// CommercialMode disables high-overhead HTTP middleware features to minimize per-request memory usage.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to my comment on config.example.yaml, it's worth clarifying in the code documentation that CommercialMode is a startup-only configuration. This will help future developers understand its behavior without having to trace its usage.

Suggested change
// CommercialMode disables high-overhead HTTP middleware features to minimize per-request memory usage.
// CommercialMode disables high-overhead HTTP middleware features to minimize per-request memory usage. This setting only takes effect on server startup.

CommercialMode bool `yaml:"commercial-mode" json:"commercial-mode"`

// LoggingToFile controls whether application logs are written to rotating files or stdout.
LoggingToFile bool `yaml:"logging-to-file" json:"logging-to-file"`

Expand Down