< 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: 701_22528036593
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/>
 54113    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)
 51423    {
 51424        if (clientAuthenticationOptions is not null)
 025        {
 026            throw new NotSupportedException("The Coloc client transport does not support SSL.");
 27        }
 28
 51429        if ((serverAddress.Transport is string transport && transport != ColocTransport.Name) ||
 51430            !ColocTransport.CheckParams(serverAddress))
 231        {
 232            throw new ArgumentException(
 233                $"The server address '{serverAddress}' contains parameters that are not valid for the Coloc client trans
 234                nameof(serverAddress));
 35        }
 36
 51237        serverAddress = serverAddress with { Transport = Name };
 38
 51239        var localPipe = new Pipe(new PipeOptions(
 51240            pool: duplexConnectionOptions.Pool,
 51241            minimumSegmentSize: duplexConnectionOptions.MinSegmentSize,
 51242            pauseWriterThreshold: _options.PauseWriterThreshold,
 51243            resumeWriterThreshold: _options.ResumeWriterThreshold,
 51244            useSynchronizationContext: false));
 51245        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)
 48350        {
 48351            if (_listeners.TryGetValue(serverAddress, out ColocListener? listener) &&
 48352                listener.TryQueueConnect(
 48353                    clientPipeReader,
 48354                    cancellationToken,
 48355                    out Task<PipeReader>? serverPipeReaderTask))
 47456            {
 47457                return serverPipeReaderTask;
 58            }
 59            else
 960            {
 961                throw new IceRpcException(IceRpcError.ConnectionRefused);
 62            }
 47463        }
 51264    }
 65
 49766    internal ColocClientTransport(
 49767        ConcurrentDictionary<ServerAddress, ColocListener> listeners,
 49768        ColocTransportOptions options)
 49769    {
 49770        _listeners = listeners;
 49771        _options = options;
 49772    }
 73}