feat(logging): add home request-log forwarding support

- Introduced `SetHomeEnabled` to enable/disable request-log forwarding to the home control plane.
- Implemented `forwardRequestLogToHome` for non-streaming logs and `homeStreamingLogWriter` for real-time streaming logs.
- Enhanced `FileRequestLogger` to bypass local logging when home forwarding is enabled.
- Updated server configuration to dynamically toggle home request-log forwarding based on changes.
- Added corresponding unit tests to ensure correct forwarding behavior and fallback mechanisms.
This commit is contained in:
Luis Pater
2026-05-09 23:39:59 +08:00
parent 41f4ee7c7d
commit 1abf8625d8
4 changed files with 450 additions and 1 deletions
+11
View File
@@ -20,6 +20,7 @@ const (
redisChannelConfig = "config"
redisKeyModels = "models"
redisKeyUsage = "usage"
redisKeyRequestLog = "request-log"
homeReconnectInterval = time.Second
)
@@ -261,6 +262,16 @@ func (c *Client) LPushUsage(ctx context.Context, payload []byte) error {
return c.cmd.LPush(ctx, redisKeyUsage, payload).Err()
}
func (c *Client) RPushRequestLog(ctx context.Context, payload []byte) error {
if err := c.ensureClients(); err != nil {
return err
}
if len(payload) == 0 {
return nil
}
return c.cmd.RPush(ctx, redisKeyRequestLog, payload).Err()
}
// StartConfigSubscriber connects to home, fetches config once via GET config, then subscribes to
// the "config" channel to receive runtime config updates.
//