Skip to content

[Compute Separation] M2b: ConnectedWorkerFunctionMetadataProvider #11644

@brettsam

Description

@brettsam

Today, WorkerFunctionMetadataProvider calls IWebHostRpcWorkerChannelManager.InitializeChannelAsync() when no channels exist — that spawns a process. For external workers, we need a parallel implementation that waits for an inbound connection instead.

Dependencies: M2 (#11643)

Problem

ScriptHost.InitializeAsync() → GetFunctionsMetadata()
  → WorkerFunctionMetadataProvider.GetFunctionMetadataAsync()
    → _channelManager.GetChannels() — no channels!
      → _channelManager.InitializeChannelAsync()  ← SPAWNS PROCESS

This happens before RpcFunctionInvocationDispatcher.InitializeAsync() runs, so the new ConnectedWorkerInvocationDispatcher alone doesn't prevent the process spawn.

Solution

New IWorkerFunctionMetadataProvider implementation swapped via DI:

                     IWorkerFunctionMetadataProvider
                        /                    \
    WorkerFunctionMetadataProvider    ConnectedWorkerFunctionMetadataProvider
    (existing — starts processes)     (new — waits for inbound connection)

Acceptance Criteria

  • Implements IWorkerFunctionMetadataProvider
  • Blocks until external worker connects (2-minute timeout, matching ScriptTypeLocator)
  • Returns validated metadata via standard GetFunctionMetadata() RPC
  • Handles worker opt-out (UseDefaultMetadataIndexing)
  • Caches results; returns cached on non-refresh calls
  • WorkerFunctionMetadataProvider is unchanged
  • Unit tests

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions