예제 #1
0
        /// <summary>
        ///     Request a connection to the local docker API.
        /// </summary>
        /// <param name="dockerApi">
        ///     The Docker API extension for Akka.NET.
        /// </param>
        /// <param name="replyTo">
        ///     The actor to which the reply will be sent.
        /// </param>
        /// <param name="correlationId">
        ///     A message correlation Id that will be returned with the response.
        /// </param>
        /// <remarks>
        ///     If successful, a reference to the <see cref="Client"/> actor will be delivered via a <see cref="Connected"/> message.
        ///     Otherwise, a <see cref="ConnectFailed"/> message will be delivered.
        /// </remarks>
        public static void RequestConnectLocal(this DockerApi dockerApi, IActorRef replyTo = null, string correlationId = null)
        {
            if (dockerApi == null)
            {
                throw new ArgumentNullException(nameof(dockerApi));
            }

            replyTo = replyTo ?? ActorCell.GetCurrentSenderOrNoSender();
            if (replyTo.IsNobody())
            {
                throw new InvalidOperationException("Cannot determine the actor to receive the reply.");
            }

            dockerApi.Manager.Tell(
                Connect.Local(correlationId),
                sender: replyTo
                );
        }