Ejemplo n.º 1
0
        public IDisposable RespondAsync <TRequest, TResponse>(Func <TRequest, Task <TResponse> > responder, Action <IResponderConfiguration> configure) where TRequest : class where TResponse : class
        {
            Preconditions.CheckNotNull(responder, "responder");
            Preconditions.CheckNotNull(configure, "configure");

            return(rpc.Respond(responder, configure));
        }
Ejemplo n.º 2
0
        public virtual IDisposable RespondAsync <TRequest, TResponse>(Func <TRequest, Task <TResponse> > responder)
            where TRequest : class
            where TResponse : class
        {
            Preconditions.CheckNotNull(responder, "responder");

            return(rpc.Respond(responder));
        }
Ejemplo n.º 3
0
        public virtual void RespondAsync <TRequest, TResponse>(Func <TRequest, Task <TResponse> > responder)
            where TRequest : class
            where TResponse : class
        {
            Preconditions.CheckNotNull(responder, "responder");

            rpc.Respond(responder);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 메세지 응답
        /// </summary>
        /// <param name="responder">메세지 응답시 실행될 Func</param>
        /// <param name="queueName">메세지 큐 이름</param>
        public IDisposable Reply(Func <byte[], byte[]> responder, string queueName)
        {
            Preconditions.CheckNotNull(responder, "responder");
            Func <byte[], Task <byte[]> > taskResponder =
                request => Task <byte[]> .Factory.StartNew(_ => responder(request), null);

            return(rpc.Respond(taskResponder, configure => { }, queueName));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Set up a responder for an RPC service.
        /// </summary>
        /// <typeparam name="TRequest">The request type</typeparam>
        /// <typeparam name="TResponse">The response type</typeparam>
        /// <param name="rpc">The rpc instance</param>
        /// <param name="responder">A function that performs the response</param>
        /// <param name="cancellationToken">The cancellation token</param>
        public static IDisposable Respond <TRequest, TResponse>(
            this IRpc rpc,
            Func <TRequest, Task <TResponse> > responder,
            CancellationToken cancellationToken = default
            )
        {
            Preconditions.CheckNotNull(rpc, "rpc");

            return(rpc.Respond(responder, c => { }, cancellationToken));
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Set up a responder for an RPC service.
        /// </summary>
        /// <typeparam name="TRequest">The request type</typeparam>
        /// <typeparam name="TResponse">The response type</typeparam>
        /// <param name="rpc">The rpc instance</param>
        /// <param name="responder">A function that performs the response</param>
        /// <param name="configure">A function that performs the configuration</param>
        /// <param name="cancellationToken">The cancellation token</param>
        public static IDisposable Respond <TRequest, TResponse>(
            this IRpc rpc,
            Func <TRequest, Task <TResponse> > responder,
            Action <IResponderConfiguration> configure,
            CancellationToken cancellationToken = default
            )
        {
            Preconditions.CheckNotNull(rpc, "rpc");

            return(rpc.Respond <TRequest, TResponse>((r, c) => responder(r), configure, cancellationToken));
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Set up a responder for an RPC service.
        /// </summary>
        /// <typeparam name="TRequest">The request type</typeparam>
        /// <typeparam name="TResponse">The response type</typeparam>
        /// <param name="rpc">The rpc instance</param>
        /// <param name="responder">A function that performs the response</param>
        /// <param name="cancellationToken">The cancellation token</param>
        public static IDisposable Respond <TRequest, TResponse>(
            this IRpc rpc,
            Func <TRequest, TResponse> responder,
            CancellationToken cancellationToken = default
            )
        {
            Preconditions.CheckNotNull(rpc, "rpc");

            var asyncResponder = TaskHelpers.FromFunc <TRequest, TResponse>((m, c) => responder(m));

            return(rpc.Respond(asyncResponder, c => { }, cancellationToken));
        }