< Summary

Information
Class: IceRpc.Transports.Coloc.Internal.ColocClientTransport
Assembly: IceRpc.Transports.Coloc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Transports.Coloc/Internal/ColocClientTransport.cs
Tag: 275_13775359185
Line coverage
94%
Covered lines: 36
Uncovered lines: 2
Coverable lines: 38
Total lines: 73
Line coverage: 94.7%
Branch coverage
83%
Covered branches: 10
Total branches: 12
Branch coverage: 83.3%
Method coverage
100%
Covered methods: 4
Total methods: 4
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%
CreateConnection(...)75%8.07889.47%
ConnectAsync()100%44100%
.ctor(...)100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Transports.Coloc/Internal/ColocClientTransport.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Collections.Concurrent;
 4using System.IO.Pipelines;
 5using System.Net.Security;
 6
 7namespace IceRpc.Transports.Coloc.Internal;
 8
 9/// <summary>Implements <see cref="IDuplexClientTransport" /> for the coloc transport.</summary>
 10internal class ColocClientTransport : IDuplexClientTransport
 11{
 12    /// <inheritdoc/>
 105913    public string Name => ColocTransport.Name;
 14
 15    private readonly ConcurrentDictionary<ServerAddress, ColocListener> _listeners;
 16    private readonly ColocTransportOptions _options;
 17
 18    /// <inheritdoc/>
 19    public IDuplexConnection CreateConnection(
 20        ServerAddress serverAddress,
 21        DuplexConnectionOptions duplexConnectionOptions,
 22        SslClientAuthenticationOptions? clientAuthenticationOptions)
 101123    {
 101124        if (clientAuthenticationOptions is not null)
 025        {
 026            throw new NotSupportedException("The Coloc client transport does not support SSL.");
 27        }
 28
 101129        if ((serverAddress.Transport is string transport && transport != ColocTransport.Name) ||
 101130            !ColocTransport.CheckParams(serverAddress))
 431        {
 432            throw new ArgumentException(
 433                $"The server address '{serverAddress}' contains parameters that are not valid for the Coloc client trans
 434                nameof(serverAddress));
 35        }
 36
 100737        serverAddress = serverAddress with { Transport = Name };
 38
 100739        var localPipe = new Pipe(new PipeOptions(
 100740            pool: duplexConnectionOptions.Pool,
 100741            minimumSegmentSize: duplexConnectionOptions.MinSegmentSize,
 100742            pauseWriterThreshold: _options.PauseWriterThreshold,
 100743            resumeWriterThreshold: _options.ResumeWriterThreshold,
 100744            useSynchronizationContext: false));
 100745        return new ClientColocConnection(serverAddress, localPipe, ConnectAsync);
 46
 47        // The client connection connect operation calls this method to queue a connection establishment request with
 48        // the listener. The returned task is completed once the listener accepts the connection establishment request.
 49        Task<PipeReader> ConnectAsync(PipeReader clientPipeReader, CancellationToken cancellationToken)
 94950        {
 94951            if (_listeners.TryGetValue(serverAddress, out ColocListener? listener) &&
 94952                listener.TryQueueConnect(
 94953                    clientPipeReader,
 94954                    cancellationToken,
 94955                    out Task<PipeReader>? serverPipeReaderTask))
 93156            {
 93157                return serverPipeReaderTask;
 58            }
 59            else
 1860            {
 1861                throw new IceRpcException(IceRpcError.ConnectionRefused);
 62            }
 93163        }
 100764    }
 65
 97866    internal ColocClientTransport(
 97867        ConcurrentDictionary<ServerAddress, ColocListener> listeners,
 97868        ColocTransportOptions options)
 97869    {
 97870        _listeners = listeners;
 97871        _options = options;
 97872    }
 73}