feat(collector): add websocket
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
FR-2.3: Database Writer with Batch Processing
|
||||
Buffers audio metrics and writes in batches (50 records or 5 seconds)
|
||||
Buffers audio metrics and writes in batches
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional
|
||||
from typing import List, Optional, final
|
||||
from dataclasses import dataclass
|
||||
|
||||
import asyncpg
|
||||
@@ -32,8 +32,8 @@ class DatabaseWriter:
|
||||
"""
|
||||
|
||||
BATCH_SIZE = 50
|
||||
BATCH_TIMEOUT = 5.0 # seconds
|
||||
SILENCE_THRESHOLD_DB = -30.0 # dB below = silence
|
||||
BATCH_TIMEOUT: float = 5.0 # seconds
|
||||
SILENCE_THRESHOLD_DB: float = -30.0 # dB below = silence
|
||||
|
||||
def __init__(self, db_url: str):
|
||||
self.db_url = db_url
|
||||
@@ -124,7 +124,6 @@ class DatabaseWriter:
|
||||
f"silence={is_silence} (buffer={len(self.buffer)})"
|
||||
)
|
||||
|
||||
# Flush if batch size reached
|
||||
if len(self.buffer) >= self.BATCH_SIZE:
|
||||
await self.flush()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user