Skip to content

refactor: extract process wiring modules#2188

Merged
yohamta0 merged 4 commits into
mainfrom
refactor/process-wiring-modules
May 21, 2026
Merged

refactor: extract process wiring modules#2188
yohamta0 merged 4 commits into
mainfrom
refactor/process-wiring-modules

Conversation

@yohamta0

@yohamta0 yohamta0 commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • extract command process wiring into internal/cmd/process modules for server, scheduler, worker, DAG store, coordinator, and agent stores
  • keep cmd.Context as a thin adapter around role-specific process wiring
  • move worker static coordinator/shared-nothing client selection behind process wiring

Testing

  • make lint
  • make test TEST_TARGET=./internal/cmd/...
  • go test ./internal/cmd/... -count=1
  • git diff --check

Summary by CodeRabbit

  • Refactor

    • Consolidated initialization and wiring for server, coordinator, scheduler, worker, and data/store components into a centralized internal module, improving startup consistency and reliability.
    • Streamlined optional feature activation (event collection, notifications, incident monitors, license-gated features) for more predictable behavior.
  • Tests

    • Updated tests to exercise and validate the new centralized helpers and runtime wiring.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 70d300da-6461-4717-a1e0-57549d87de45

📥 Commits

Reviewing files that changed from the base of the PR and between ab5b5f4 and 6a9e342.

📒 Files selected for processing (10)
  • internal/cmd/context.go
  • internal/cmd/process/agent_stores.go
  • internal/cmd/process/coordinator.go
  • internal/cmd/process/dag_store.go
  • internal/cmd/process/scheduler.go
  • internal/cmd/process/server.go
  • internal/cmd/process/worker.go
  • internal/cmd/worker.go
  • internal/cmd/worker_test.go
  • internal/intg/embed/embed_test.go

📝 Walkthrough

Walkthrough

Refactors internal/cmd to extract server, scheduler, coordinator, DAG store, and agent store construction into internal/cmd/process; context.go and worker wiring now delegate to these new constructors, and tests/embedded integration updated accordingly.

Changes

Component wiring consolidation

Layer / File(s) Summary
Process package foundations: stores and coordinator
internal/cmd/process/dag_store.go, internal/cmd/process/agent_stores.go, internal/cmd/process/coordinator.go
DAGStoreConfig and NewDAGStore construct file-backed DAG storage; AgentStores and NewAgentStores bundle agent-related stores with optional OAuth and context resolution; NewCoordinatorClient builds coordinator clients with TLS validation.
Server process construction
internal/cmd/process/server.go
ServerConfig and NewServer orchestrate frontend server initialization: cache/store creation, DAG definition caching, telemetry collection, coordinator wiring, and optional license/heartbeat/lease store API options.
Scheduler process construction
internal/cmd/process/scheduler.go
SchedulerConfig and NewScheduler construct the scheduler with caching, stores, and event services; newNotificationMonitor and newIncidentMonitor wire encrypted notification/incident system integration.
Worker coordinator client construction
internal/cmd/process/worker.go
BuildWorkerCoordinatorClientConfig and NewWorkerCoordinatorClient encapsulate worker-specific coordinator setup supporting static or service-discovery modes with useRemoteHandler flag.
Context refactoring to delegate to cmdprocess
internal/cmd/context.go
NewServer, NewCoordinatorClient, NewScheduler, dagStore, and agentStores methods replace in-file wiring with thin wrappers delegating to cmdprocess constructors; imports updated.
Worker and test updates
internal/cmd/worker.go, internal/cmd/worker_test.go
createCoordinatorClient delegates to cmdprocess.NewWorkerCoordinatorClient; tests updated to call cmdprocess.BuildWorkerCoordinatorClientConfig.
Embedded test binary resolution
internal/intg/embed/embed_test.go
Adds helper to resolve binary paths via exec.LookPath and updates embedded YAML steps to reference resolved whoami binary.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • dagucloud/dagu#2081: Refactors scheduler and GitHub dispatch worker initialization overlapping scheduler/GitHub-dispatch wiring.
  • dagucloud/dagu#2041: Adds worker heartbeat store wiring into frontend API options; related to frontend/server API option consolidation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: extracting process wiring modules from the command context.
Description check ✅ Passed The description covers the main objectives (extraction of process wiring modules and keeping cmd.Context as adapter) and lists comprehensive testing commands, but omits the standard PR template sections for individual change list and related issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/process-wiring-modules

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/cmd/process/worker.go`:
- Around line 24-35: The static coordinator config created with
coordinator.DefaultConfig() populates TLS/insecure fields but omits the peer
retry settings; update coordCliCfg before calling coordCliCfg.Validate() to copy
cfg.Core.Peer.MaxRetries and cfg.Core.Peer.RetryInterval into coordCliCfg (e.g.,
set coordCliCfg.MaxRetries = cfg.Core.Peer.MaxRetries and
coordCliCfg.RetryInterval = cfg.Core.Peer.RetryInterval) so the static worker
path respects the configured retry behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e946be19-183f-4be9-b4fd-b76ef1395083

📥 Commits

Reviewing files that changed from the base of the PR and between f361a1f and 8988c1a.

📒 Files selected for processing (9)
  • internal/cmd/context.go
  • internal/cmd/process/agent_stores.go
  • internal/cmd/process/coordinator.go
  • internal/cmd/process/dag_store.go
  • internal/cmd/process/scheduler.go
  • internal/cmd/process/server.go
  • internal/cmd/process/worker.go
  • internal/cmd/worker.go
  • internal/cmd/worker_test.go

Comment thread internal/cmd/process/worker.go
@yohamta0

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0 yohamta0 force-pushed the refactor/process-wiring-modules branch from 3d2c3f8 to 6a9e342 Compare May 21, 2026 08:43
@yohamta0

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0 yohamta0 merged commit 1e40d7e into main May 21, 2026
10 checks passed
@yohamta0 yohamta0 deleted the refactor/process-wiring-modules branch May 21, 2026 10:51
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.

1 participant