Skip to content

[Compute Separation] M1: Extract WorkerChannelBase from GrpcWorkerChannel#11652

Merged
brettsam merged 4 commits intodevfrom
brettsam/process
Mar 18, 2026
Merged

[Compute Separation] M1: Extract WorkerChannelBase from GrpcWorkerChannel#11652
brettsam merged 4 commits intodevfrom
brettsam/process

Conversation

@brettsam
Copy link
Copy Markdown
Member

Summary

Pure refactor — extract all gRPC protocol logic from GrpcWorkerChannel (1,860 lines) into a new abstract base class WorkerChannelBase, leaving only process-management code (~124 lines) in GrpcWorkerChannel.

Virtual hooks added for M2: WorkerProcessId, OnDisposing(), DisposeWorkerResources(), BeginInboundProcessing().

Resolves #11641

Changes

  • WorkerChannelBase.cs (new, ~1,833 lines) — abstract base class with all gRPC protocol logic, message processing, invocation handling, capabilities, shared memory, logging, nested classes
  • GrpcWorkerChannel.cs (1,860 → ~124 lines) — sealed class inheriting WorkerChannelBase, contains only: _rpcWorkerProcess field, slim constructor, StartWorkerProcessAsync, StopWorkerProcess, dispose hooks, FileEvent subscription
  • GrpcWorkerChannel.Log.cs — Logger class moved to base

Testing

  • 85/85 GrpcWorkerChannelTests pass without any test modifications
  • 3,215/3,217 full unit suite pass (2 pre-existing CPU-count failures unrelated to this change)
  • Zero new build warnings

@brettsam brettsam requested a review from a team as a code owner March 13, 2026 18:32
Copilot AI review requested due to automatic review settings March 13, 2026 18:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the gRPC worker channel implementation by extracting the bulk of GrpcWorkerChannel logic into a new WorkerChannelBase, leaving GrpcWorkerChannel as a small sealed implementation that wires in the concrete worker process and file-watcher subscription.

Changes:

  • Introduce WorkerChannelBase to host common channel/message-processing, invocation, and capability logic.
  • Update GrpcWorkerChannel to inherit from WorkerChannelBase and override only process-specific behaviors.
  • Remove the GrpcWorkerChannel.Log.cs partial by relocating the logger helpers into the new base class.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/WebJobs.Script.Grpc/Channel/WorkerChannelBase.cs New shared base class containing the worker channel core logic and logger helpers.
src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs Simplified concrete channel implementation deriving from WorkerChannelBase.
src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.Log.cs Deleted; logger helpers moved into WorkerChannelBase.

brettsam and others added 4 commits March 18, 2026 11:28
TestGrpcWorkerChannel in ApplicationInsightsTestFixture inherits from
GrpcWorkerChannel to override UpdateCapabilities for testing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ispose(bool) override

Address PR feedback:
- Rename WorkerChannelBase -> WorkerChannel (naming nit)
- Remove OnDisposing() virtual hook to avoid race with _disposing flag
- GrpcWorkerChannel now overrides Dispose(bool) directly, calling
  StopWorkerProcess() before base cleanup
- Set _disposing = true before Dispose(true) in base class

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@brettsam brettsam merged commit 5c2e481 into dev Mar 18, 2026
11 checks passed
@brettsam brettsam deleted the brettsam/process branch March 18, 2026 16:24
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.

[Compute Separation] M1: Extract WorkerChannelBase from GrpcWorkerChannel

4 participants