Add notification delivery interval config and server timeouts#283
Merged
Conversation
… add bodylimit+timeout middleware - newRuntime: wire into tests that seed store directly (TestSweepWorkerStatuses, TestEvaluateAndNotifyAlerts, TestNotificationOutboxRetries); add TestNewRuntime to cover the constructor path explicitly - Bug: notificationDeliveryLoopSettings was reusing AlertEvaluationInterval, making WORKERFLEET_ALERT_EVALUATION_INTERVAL silently control both loops; add NotificationDeliveryInterval field with independent env var WORKERFLEET_NOTIFICATION_DELIVERY_INTERVAL (default 30s) - Security: add MaxBodyBytes (default 2 MiB) and HandlerTimeout (default 30s) to ServerConfig; wire bodylimit.Middleware + timeout.Middleware in newCoreApp, matching the standard-service middleware chain - Remove WorkerDetail = WorkerView no-op type alias; replace all references with WorkerView directly https://claude.ai/code/session_01PKdanD7JDusUQdTVCgF3Cv
…Rebalance The atomic "drop if running" pattern in triggerRebalance caused dropped rebalance requests when multiple consumers joined quickly. A rebalance triggered by c3 could be silently discarded while the rebalance for c1/c2 was running, leaving c3 with zero partitions assigned. Replace rebalancing atomic.Bool with a mutex-protected running+pending pair. When a rebalance is already in progress the incoming request sets a pending flag; the running goroutine re-runs the rebalance loop before releasing ownership, guaranteeing every join/leave is eventually reflected. https://claude.ai/code/session_01PKdanD7JDusUQdTVCgF3Cv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces configuration for notification delivery loop timing and adds HTTP server-level timeout and body size limits to improve operational control and security.
Key changes:
NotificationDeliveryIntervalconfig to decouple notification delivery timing from alert evaluationWORKERFLEET_NOTIFICATION_DELIVERY_INTERVALenvironment variable supportHandlerTimeoutandMaxBodyBytestoServerConfigwith environment variable overridesnewRuntime()for cleaner test setupWorkerDetailtype alias in favor of directWorkerViewusageType of change
Scope and boundaries
Touched (directories/packages):
internal/app/config.go— Runtime and server configurationinternal/app/server_config.go— Server configuration loadinginternal/app/app.go— Middleware wiringinternal/app/types.go— Type alias removalinternal/app/service.go— Return type consistencyinternal/app/*_test.go— Test refactoring to usenewRuntime()internal/handler/— Test stub updatesenv.example— Configuration documentationOut of scope:
Safe refactor zone declaration
Plan
Objective:
Approach:
NotificationDeliveryIntervalfield toRuntimeConfigwith default 30snotificationDeliveryLoopSettings()to use the new field instead ofAlertEvaluationIntervalHandlerTimeoutandMaxBodyBytestoServerConfigwith sensible defaultsbodylimitandtimeoutmiddleware from plumegonewRuntime()helper instead of fullBootstrap()WorkerDetailtype aliasPublic API impact:
ServerConfigstruct gains two new fields (backward compatible with defaults)RuntimeConfig.NotificationDeliveryIntervaladded (new field, backward compatible)WorkerDetailtype alias removed (internal type, no public impact)Risks / invariants:
Verification
Required checks
go test ./...— All existing tests pass with refactored test setupconfig_test.goTestRuntimeLoopSettingsRemainIndependentverifies notification delivery uses correct intervalLoadServerConfigtests verify timeout and body bytes parsingEvidence:
TestLoadConfigParsesRuntimeSettingsvalidatesWORKERFLEET_NOTIFICATION_DELIVERY_INTERVALparsingTestRuntimeLoopSettingsRemainIndependentconfirms notification delivery loop usesNotificationDeliveryInterval(14s) notAlertEvaluationInterval(13s)TestNewRuntimevalidates refactored runtime initializationTestSweepWorkerStatusesMarksExpiredHeartbeatOfflineand alert tests use simplifiednewRuntime()setuphttps://claude.ai/code/session_01PKdanD7JDusUQdTVCgF3Cv