Ejemplo n.º 1
0
        public IUnaryMethodCall <TResponse> CallUnary <TRequest, TResponse>(MethodCallDescriptor descriptor, TRequest request, ContextLinkageOptions contextLinkageOptions = default)
        {
            _log.Debug("Starting unary call: {0}", descriptor);
            var call = new UnaryMethodCall <TRequest, TResponse>(() => _outcomingInvocationFactory.CreateAsync <TRequest, TResponse>(descriptor, request, contextLinkageOptions));

            call.Start();
            return(call);
        }
Ejemplo n.º 2
0
        public IUnaryMethodCall CallUnary <TRequest>(MethodCallDescriptor descriptor, TRequest request)
        {
            _log.Debug("Starting unary call: {0}", descriptor);
            var call = new UnaryMethodCall <TRequest, Nothing>(() => _outcomingInvocationFactory.CreateAsync <TRequest, Nothing>(descriptor, request));

            call.Start();
            return(call);
        }
        public void CallDescriptorConstructionWorksWithNoArguments()
        {
            // --- Act
            var descriptor = new MethodCallDescriptor(this, typeof(MethodDescriptorTest)
                                                      .GetMethod("ConstructionWorksWithNoArguments"), null);

            // --- Assert
            descriptor.ArgumentCount.ShouldEqual(0);
        }
Ejemplo n.º 4
0
 internal DiscoveredMethod(
     ProvidedMethodReference providedMethod,
     Maybe <string> title,
     string inputMessageId,
     string outputMessageId,
     MethodType type,
     MethodCallDescriptor callDescriptor)
 {
     ProvidedMethod  = providedMethod;
     Title           = title;
     InputMessageId  = inputMessageId;
     OutputMessageId = outputMessageId;
     Type            = type;
     CallDescriptor  = callDescriptor;
 }
        public async ValueTask <IOutcomingInvocation <TRequest, TResponse> > CreateAsync <TRequest, TResponse>(
            MethodCallDescriptor methodCall, Maybe <TRequest> request = default, Maybe <ContextLinkageOptions> contextLinkageOptions = default)
        {
            var channel = await _connection.CreateChannelAsync().ConfigureAwait(false);

            InvocationMethodDescriptor methodDescriptor = null;
            InvocationTargetDescriptor targetDescriptor = null;

            if (methodCall.Method.HasValue)
            {
                var method = methodCall.Method.Value;
                methodDescriptor = new InvocationMethodDescriptor(method.Service.Id, method.Name, method.Service.Alias);
            }
            if (methodCall.ProvidedMethod.HasValue)
            {
                var method = methodCall.ProvidedMethod.Value;
                methodDescriptor = new InvocationMethodDescriptor(method.ProvidedService.ServiceId, method.Name, method.ProvidedService.ServiceId);
                targetDescriptor = new InvocationTargetDescriptor(method.ProvidedService.ApplicationId, method.ProvidedService.ConnectionId, method.ProvidedService.ServiceAlias);
            }
            var descriptor = new OutcomingInvocationDescriptor(methodDescriptor, targetDescriptor, contextLinkageOptions);
            var invocation = new OutcomingInvocation <TRequest, TResponse>(
                descriptor,
                channel,
                _protocol,
                GetMarshaller <TRequest>(),
                GetMarshaller <TResponse>());

            invocation.Start();
            if (request.HasValue)
            {
                await invocation.Out.WriteAsync(request.Value).ConfigureAwait(false);

                invocation.Out.TryComplete();
            }
            return(invocation);
        }
Ejemplo n.º 6
0
 internal MethodReference(ServiceReference service, string name)
 {
     Service        = service;
     Name           = name;
     CallDescriptor = new MethodCallDescriptor(this);
 }
 internal ProvidedMethodReference(ProvidedServiceReference providedService, string methodName)
 {
     ProvidedService = providedService;
     Name            = methodName;
     CallDescriptor  = new MethodCallDescriptor(this);
 }
Ejemplo n.º 8
0
        public IDuplexStreamingMethodCall <TRequest, TResponse> CallDuplexStreaming <TRequest, TResponse>(MethodCallDescriptor descriptor)
        {
            _log.Debug("Starting duplex streaming call: {0}", descriptor);
            var call = new DuplexStreamingMethodCall <TRequest, TResponse>(() => _outcomingInvocationFactory.CreateAsync <TRequest, TResponse>(descriptor));

            call.Start();
            return(call);
        }
Ejemplo n.º 9
0
        public IServerStreamingMethodCall <TResponse> CallServerStreaming <TRequest, TResponse>(MethodCallDescriptor descriptor, TRequest request)
        {
            _log.Debug("Starting server streaming call: {0}", descriptor);
            var call = new ServerStreamingMethodCall <TRequest, TResponse>(() => _outcomingInvocationFactory.CreateAsync <TRequest, TResponse>(descriptor, request));

            call.Start();
            return(call);
        }
Ejemplo n.º 10
0
        public IClientStreamingMethodCall <TRequest, TResponse> CallClientStreaming <TRequest, TResponse>(MethodCallDescriptor descriptor, ContextLinkageOptions contextLinkageOptions = default)
        {
            _log.Debug("Starting client streaming call: {0}", descriptor);
            var call = new ClientStreamingMethodCall <TRequest, TResponse>(() => _outcomingInvocationFactory.CreateAsync <TRequest, TResponse>(descriptor, contextLinkageOptions: contextLinkageOptions));

            call.Start();
            return(call);
        }
Ejemplo n.º 11
0
        public IDuplexStreamingMethodCall <TRequest, TResponse> CallDuplexStreaming <TRequest, TResponse>(MethodCallDescriptor descriptor, ContextLinkageOptions contextLinkageOptions = default)
        {
            CheckConnectionState();
            _log.Debug("Starting duplex streaming call: {0}", descriptor);
            var call = new DuplexStreamingMethodCall <TRequest, TResponse>(() => _outcomingInvocationFactory.CreateAsync <TRequest, TResponse>(descriptor, contextLinkageOptions: contextLinkageOptions));

            call.Start();
            return(call);
        }