Skip to content

Conversation

@takaokouji
Copy link

Summary

Implements configurable Mesh v2 parameters to support cost reduction efforts outlined in issue #79.

Changes

  • webpack.config.js: Injected 4 new environment variables:
    • MESH_CONNECTION_TIMEOUT_MS
    • MESH_DATA_UPDATE_INTERVAL_MS
    • MESH_EVENT_BATCH_INTERVAL_MS
    • MESH_HOST_HEARTBEAT_INTERVAL_MS
  • mesh-service.js: Updated to use these variables with legacy fallbacks.

Cost Reduction Strategy

These changes allow us to tune the following parameters in production without code changes:

  • Reduce connection timeout (e.g., 25 mins).
  • Increase data update interval (e.g., 1000ms).
  • Increase event batch interval (e.g., 1000ms).
  • Increase heartbeat interval (e.g., 60s).

Verification

  • Unit tests passed.
  • Lint passed.

takaokouji and others added 8 commits January 3, 2026 18:13
- Added environment variables for connection timeout, data update interval, event batch interval.
- Added environment variable for host heartbeat interval.
- Updated mesh-service.js to use these variables with default fallbacks.
- Updated webpack.config.js to inject these variables.
- Added parseEnvInt helper for unified parsing and validation
- Added descriptive comments and default values for Mesh v2 configuration
- Updated .env.example with missing Mesh v2 parameters
- Renamed MESH_CONNECTION_TIMEOUT_MS to MESH_MAX_CONNECTION_TIME_SECONDS (unit: seconds)
- Renamed MESH_HOST_HEARTBEAT_INTERVAL_MS to MESH_HOST_HEARTBEAT_INTERVAL_SECONDS (unit: seconds)
- Added MESH_MEMBER_HEARTBEAT_INTERVAL_SECONDS (unit: seconds)
- Updated implementation to handle seconds and convert to ms where needed
- Updated .env.example and webpack.config.js
….env

- Updated default intervals to match .env.example (1000ms for data/event, 60s/120s for heartbeats)
- Added .env to .gitignore and untracked existing .env file
- Removed CONNECTION_TIMEOUT fallback in mesh-service.js
- startConnectionTimer now relies solely on expiresAt from server
- Removed variable from .env.example and webpack.config.js
- Added heartbeatIntervalSeconds to CREATE_GROUP mutation
- Updated createGroup, renewHeartbeat, and joinGroup to capture interval from server
- Updated startHeartbeat to use server interval instead of environment variables
- Removed MESH_HOST_HEARTBEAT_INTERVAL_SECONDS and MESH_MEMBER_HEARTBEAT_INTERVAL_SECONDS
- Fixed unit tests failing due to immediate group expiration when expiresAt was in the past.
- Added missing heartbeatIntervalSeconds to mock responses.

Co-Authored-By: Gemini <noreply@google.com>
- Suppressed info/debug logs in Mesh V2 tests for better readability.
- Kept info enabled in extension_mesh_v2_service.js for log verification.

Co-Authored-By: Gemini <noreply@google.com>
@takaokouji takaokouji merged commit fbc7949 into develop Jan 4, 2026
1 check passed
@takaokouji takaokouji deleted the feature/issue-79-mesh-v2-cost-reduction branch January 4, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants