Vixen
02b45cc4
csharp
public sealed class DockerEngine

The six calls, hand-written. ADR-019.

Read the guide page for this →

Remarks

A SocketsHttpHandler with a ConnectCallback, and the rest is JSON. The Engine API is an ordinary HTTP API that happens to live on a unix socket, so the only unusual line in this file is the one that dials the socket instead of a TCP endpoint.

⚠ The handler is injectable, and that is what makes this testable. A test supplies one that answers with recorded Engine responses, so the placement backend's behaviour — labels, ports, ready detection, exit classification — is asserted without a daemon. What a test cannot assert is that the daemon really speaks this dialect, and that is what the nightly Docker leg is for.

Fields and properties (3)

  • public const string DefaultSocket

    Where the daemon listens on Linux and macOS.

  • public const string DefaultPipe

    Where it listens on Windows.

  • public const string ApiVersion

    The API version this client speaks. Pinned, because the Engine negotiates by URL prefix and an unpinned client silently changes dialect when the host is upgraded.

Methods (11)

  • public DockerEngine(string? endpoint = null)

    Opens a client on the platform's default endpoint.

  • public DockerEngine(HttpMessageHandler handler)

    Opens a client on a handler the caller built.

  • public Task<DockerPing> PingAsync(CancellationToken cancellation)

    Asks whether the daemon is there.

  • public Task<string> CreateAsync(DockerCreate create, CancellationToken cancellation)

    Creates a container.

  • public Task StartAsync(string id, CancellationToken cancellation)

    Starts one.

  • public Task StopAsync(string id, TimeSpan patience, CancellationToken cancellation)

    Stops one, politely and then not.

  • public Task RemoveAsync(string id, CancellationToken cancellation)

    Removes one.

  • public Task<IReadOnlyList<DockerContainer>> ListAsync(string label, CancellationToken cancellation)

    Lists the containers carrying a label.

  • public IAsyncEnumerable<string> FollowAsync(string id, CancellationToken cancellation)

    Follows a container's output, a line at a time.

  • public Task<int> WaitAsync(string id, CancellationToken cancellation)

    Waits for a container to exit.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (2)

  • DockerPlacementVixen.Live.Placement.Docker
  • DockerPlacementTestsVixen.Live.Placement.Docker.Tests