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:
@@ -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.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user