Exemplo n.º 1
0
        public IRequestClient <T> CreateRequestClient <T>(RequestTimeout timeout)
            where T : class
        {
            if (EndpointConvention.TryGetDestinationAddress <T>(out var destinationAddress))
            {
                return(CreateRequestClient <T>(destinationAddress, timeout));
            }

            return(new RequestClient <T>(_context, _context.GetRequestEndpoint <T>(), timeout.Or(_context.DefaultTimeout)));
        }
Exemplo n.º 2
0
        public async Task <IRequestSendEndpoint <TMessage> > GetServiceSendEndpoint(ClientFactoryContext clientFactoryContext, TMessage message,
                                                                                    ConsumeContext consumeContext = default, CancellationToken cancellationToken = default)
        {
            // TODO use the message to generate the hash key

            var correlationId = NewId.NextGuid();

            var endpointInfo = _distribution.GetNode(correlationId.ToByteArray());

            if (endpointInfo == null)
            {
                await Link(cancellationToken).ConfigureAwait(false);

                endpointInfo = _distribution.GetNode(correlationId.ToByteArray());
            }

            var endpointAddress = endpointInfo?.EndpointAddress ?? await _serviceAddress.Task.ConfigureAwait(false);

            return(clientFactoryContext.GetRequestEndpoint <TMessage>(endpointAddress, consumeContext));
        }
Exemplo n.º 3
0
        public async Task <IRequestSendEndpoint <TMessage> > GetServiceSendEndpoint(ClientFactoryContext clientFactoryContext, TMessage message,
                                                                                    ConsumeContext consumeContext = default, CancellationToken cancellationToken = default)
        {
            // TODO use the message to generate the hash key

            // var correlationId = NewId.NextGuid();
            //
            // var endpointInfo = _distribution.GetNode(correlationId.ToByteArray());
            // if (endpointInfo == null)
            // {
            //     await Link(cancellationToken).ConfigureAwait(false);
            //
            //     endpointInfo = _distribution.GetNode(correlationId.ToByteArray());
            // }

            var endpointAddress = _serviceAddress.Task.IsCompletedSuccessfully()
                ? _serviceAddress.Task.Result
                : await _serviceAddress.Task.ConfigureAwait(false);

            // TODO may want to switch this up so that it includes the InstanceContext is a specific node selected
            return(clientFactoryContext.GetRequestEndpoint <TMessage>(endpointAddress, consumeContext));
        }