コード例 #1
0
        /// <summary>
        /// Initiates a bootstrap connection to the specified endpoints.
        /// </summary>
        /// <param name="targets"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async ValueTask ConnectAsync(KProtocolEndpointSet <TNodeId> targets, CancellationToken cancellationToken = default)
        {
            logger.LogInformation("Bootstrapping network with connection to {Endpoints}.", targets);

            // ping node, which ensures availability and populates tables upon response
            var r = await invoker.PingAsync(targets, cancellationToken);

            if (r.Status == KResponseStatus.Failure)
            {
                throw new KProtocolException(KProtocolError.EndpointNotAvailable, "Unable to bootstrap off of the specified endpoints. No response.");
            }

            await router.UpdateAsync(r.Header.Sender, targets, cancellationToken);

            await lookup.LookupNodeAsync(host.SelfId, cancellationToken);
        }
コード例 #2
0
 public ValueTask <KResponse <TNodeId, KStoreResponse <TNodeId> > > StoreAsync(KProtocolEndpointSet <TNodeId> endpoints, in TNodeId key, KStoreRequestMode mode, in KValueInfo?value, CancellationToken cancellationToken = default)
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="endpoints"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public ValueTask <KResponse <TNodeId, KPingResponse <TNodeId> > > PingAsync(KProtocolEndpointSet <TNodeId> endpoints, CancellationToken cancellationToken = default)
 {
     return(policy.InvokeAsync <KPingRequest <TNodeId>, KPingResponse <TNodeId> >(endpoints, new KPingRequest <TNodeId>(host.Endpoints.ToArray())));
 }
コード例 #4
0
 /// <summary>
 /// Attempts to execute the specified method against the provided endpoints.
 /// </summary>
 /// <param name="endpoints"></param>
 /// <param name="request"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public ValueTask <KResponse <TNodeId, TResponse> > InvokeAsync <TRequest, TResponse>(KProtocolEndpointSet <TNodeId> endpoints, in TRequest request, CancellationToken cancellationToken)