Table of Contents

Class ChildConnection

Namespace
RDCore.SDK.Client.Connection
Assembly
RDCore.SDK.dll

Owns one supervised child process, its transport pipe, and its LanguageClient, and drives them through the ConnectionState lifecycle, including restart-with-backoff.

public sealed class ChildConnection : IDisposable
Inheritance
ChildConnection
Implements
Inherited Members

Constructors

ChildConnection(IRDCoreServerProcess, ILanguageServerProtocolTransportLayer, ILogger<ChildConnection>, TimeProvider?)

Owns one supervised child process, its transport pipe, and its LanguageClient, and drives them through the ConnectionState lifecycle, including restart-with-backoff.

public ChildConnection(IRDCoreServerProcess serverProcess, ILanguageServerProtocolTransportLayer transportLayer, ILogger<ChildConnection> logger, TimeProvider? clock = null)

Parameters

serverProcess IRDCoreServerProcess

The child process.

transportLayer ILanguageServerProtocolTransportLayer

Makes the pipe the connection meets the child on.

logger ILogger<ChildConnection>

The logger.

clock TimeProvider

The clock the delay before a restart is kept by; the system's when null.

Properties

Channel

The live language client as a channel of the platform protocol (RDCorePlatformClient). Throws until the connection is Ready.

public IRDCorePlatformChannel Channel { get; }

Property Value

IRDCorePlatformChannel

Client

The live language client. Throws until the connection is Ready.

public ILanguageClient Client { get; }

Property Value

ILanguageClient

PlatformInfo

The result of the rdcore/platform/initialize handshake, once the connection is Ready.

public PlatformInitializeResult? PlatformInfo { get; }

Property Value

PlatformInitializeResult

ProcessId

The operating-system identifier of the child process; 0 before it is started.

public int ProcessId { get; }

Property Value

int

State

The current lifecycle state of the connection.

public ConnectionState State { get; }

Property Value

ConnectionState

Methods

ConnectAsync(ChildConnectionRequest, CancellationToken)

Drives the connection from NotStarted to Ready. Initial failures are not retried: the state becomes Faulted and the exception is rethrown.

public Task ConnectAsync(ChildConnectionRequest request, CancellationToken token)

Parameters

request ChildConnectionRequest

The connection inputs.

token CancellationToken

Cancels the connection attempt.

Returns

Task

Dispose()

Cancels any in-flight connection work and disposes the process, pipe, and client.

public void Dispose()

SendNotificationAsync<TParams>(TParams, CancellationToken)

Sends a notification over the connection.

public Task SendNotificationAsync<TParams>(TParams notification, CancellationToken token) where TParams : IRequest

Parameters

notification TParams

The notification parameters.

token CancellationToken

Cancels before the notification is sent.

Returns

Task

Type Parameters

TParams

The notification parameter type.

SendRequestAsync<TParams, TResult>(TParams, CancellationToken)

Sends a request over the connection.

public Task<TResult> SendRequestAsync<TParams, TResult>(TParams request, CancellationToken token) where TParams : IRequest<TResult>

Parameters

request TParams

The request parameters.

token CancellationToken

Cancels the request.

Returns

Task<TResult>

Type Parameters

TParams

The request parameter type.

TResult

The response type.

Exceptions

ServerProtocolSdkException

The child process exited before it answered: a connection that restarts does not send the request again.

ShutdownAsync()

Graceful teardown: LSP shutdown request, then exit notification, then a bounded wait for the process, then a kill. Suppresses restart. Idempotent.

public Task ShutdownAsync()

Returns

Task

WaitForExitAsync()

Completes when the child process exits.

public Task WaitForExitAsync()

Returns

Task

WaitForReadyAsync(CancellationToken)

Completes once the connection is Ready (waiting through any in-progress restart); faults once the connection is terminally Exited, is shutting down, or is disposed.

public Task WaitForReadyAsync(CancellationToken token)

Parameters

token CancellationToken

Cancels the wait.

Returns

Task

Remarks

A connection whose child process has exited is not Ready from the moment its exit is seen, before its state says so: what completes this wait is the process a request sent next goes to, and not the one that a request in flight was lost with.

Exceptions

ServerProtocolSdkException

The connection has exited, or is shutting down.

ObjectDisposedException

The connection is disposed, or is disposed while the wait waits.

WaitForTerminalAsync()

Completes once the connection is terminally Exited (restart, if any, exhausted).

public Task WaitForTerminalAsync()

Returns

Task

Events

StateChanged

Raised on every state transition.

public event Action<ConnectionState>? StateChanged

Event Type

Action<ConnectionState>