feat(k8s): add Kubernetes Helm chart for emailks service
- Create Helm chart structure with Chart.yaml and values.yaml - Add deployment template with container configuration and environment variables - Implement service template for gRPC port exposure - Add service account template with security configuration - Include horizontal pod autoscaler template for scaling capabilities - Add helper templates for naming and label management - Configure SMTP settings as configurable parameters in values.yaml - Set up resource limits and requests for container performance - Implement liveness and readiness probes for health checks - Add support for existing secrets and custom configurations
This commit is contained in:
@@ -68,18 +68,7 @@ impl JobStatusStore {
|
||||
guard.remove(&id);
|
||||
}
|
||||
|
||||
pub fn all_done(&self, ids: &[u64]) -> bool {
|
||||
let guard = match self.inner.read() {
|
||||
Ok(g) => g,
|
||||
Err(_) => return false,
|
||||
};
|
||||
ids.iter().all(|id| {
|
||||
matches!(
|
||||
guard.get(id).map(|e| e.status),
|
||||
Some(SendStatus::Sent | SendStatus::Failed)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
fn write(&self, id: u64, status: SendStatus, error: Option<String>) {
|
||||
let mut guard = match self.inner.write() {
|
||||
@@ -105,14 +94,15 @@ fn prune_statuses(entries: &mut HashMap<u64, JobStatusEntry>) {
|
||||
let now = Instant::now();
|
||||
entries.retain(|_, entry| now.duration_since(entry.updated_at) <= STATUS_TTL);
|
||||
|
||||
while entries.len() >= MAX_STATUS_ENTRIES {
|
||||
let Some(oldest_id) = entries
|
||||
// Evict at most one entry per write to avoid O(n²) behaviour under load.
|
||||
// Repeated writes will gradually shrink the map if it stays above capacity.
|
||||
if entries.len() >= MAX_STATUS_ENTRIES {
|
||||
if let Some(oldest_id) = entries
|
||||
.iter()
|
||||
.min_by_key(|(_, entry)| entry.updated_at)
|
||||
.map(|(id, _)| *id)
|
||||
else {
|
||||
break;
|
||||
};
|
||||
entries.remove(&oldest_id);
|
||||
{
|
||||
entries.remove(&oldest_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user