/// <summary> /// Initializes a new instance. /// </summary> /// <param name="options"></param> /// <param name="host"></param> /// <param name="connector"></param> /// <param name="logger"></param> public KStaticDiscovery(IOptions <KStaticDiscoveryOptions> options, IKHost <TNodeId> host, IKConnector <TNodeId> connector, ILogger logger) { this.options = options ?? throw new ArgumentNullException(nameof(options)); this.host = host ?? throw new ArgumentNullException(nameof(host)); this.connector = connector ?? throw new ArgumentNullException(nameof(connector)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="host"></param> /// <param name="handler"></param> /// <param name="http"></param> /// <param name="logger"></param> public KHttpProtocol(IKHost <TNodeId> host, IKRequestHandler <TNodeId> handler, ITypedHttpClientFactory <KHttpProtocol <TNodeId> > http, ILogger logger) { this.host = host ?? throw new ArgumentNullException(nameof(host)); this.handler = handler ?? throw new ArgumentNullException(nameof(handler)); this.http = http ?? throw new ArgumentNullException(nameof(http)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="host"></param> /// <param name="invoker"></param> /// <param name="logger"></param> /// <param name="k"></param> public KBucket(IKHost <TNodeId> host, IKInvoker <TNodeId> invoker, ILogger logger, int k) { this.host = host ?? throw new ArgumentNullException(nameof(host)); this.invoker = invoker ?? throw new ArgumentNullException(nameof(invoker)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.k = k; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="host"></param> /// <param name="formats"></param> /// <param name="protocol"></param> /// <param name="server"></param> public KademliaMiddleware(IKHost <TNodeId> host, IEnumerable <IKMessageFormat <TNodeId> > formats, KHttpProtocol <TNodeId> protocol, IServer server) { this.host = host ?? throw new ArgumentNullException(nameof(host)); this.formats = formats ?? throw new ArgumentNullException(nameof(formats)); this.protocol = protocol ?? throw new ArgumentNullException(nameof(protocol)); this.server = server ?? throw new ArgumentNullException(nameof(server)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="host"></param> /// <param name="router"></param> /// <param name="store"></param> /// <param name="logger"></param> public KRequestHandler(IKHost <TNodeId> host, IKRouter <TNodeId> router, IKStore <TNodeId> store, ILogger logger) { this.host = host ?? throw new ArgumentNullException(nameof(host)); this.router = router ?? throw new ArgumentNullException(nameof(router)); this.store = store ?? throw new ArgumentNullException(nameof(store)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="host"></param> /// <param name="router"></param> /// <param name="invoker"></param> /// <param name="lookup"></param> /// <param name="logger"></param> public KConnector(IKHost <TNodeId> host, IKRouter <TNodeId> router, IKInvoker <TNodeId> invoker, IKLookup <TNodeId> lookup, ILogger logger) { this.host = host ?? throw new ArgumentNullException(nameof(host)); this.router = router ?? throw new ArgumentNullException(nameof(router)); this.invoker = invoker ?? throw new ArgumentNullException(nameof(invoker)); this.lookup = lookup ?? throw new ArgumentNullException(nameof(lookup)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="options"></param> /// <param name="host"></param> /// <param name="formats"></param> /// <param name="handler"></param> /// <param name="logger"></param> public KUdpProtocol(IOptions <KUdpOptions> options, IKHost <TNodeId> host, IEnumerable <IKMessageFormat <TNodeId> > formats, IKRequestHandler <TNodeId> handler, ILogger logger) { this.options = options ?? throw new ArgumentNullException(nameof(options)); this.host = host ?? throw new ArgumentNullException(nameof(host)); this.formats = formats ?? throw new ArgumentNullException(nameof(formats)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); server = new KUdpServer <TNodeId>(options, host, formats, handler, new KUdpSerializer <TNodeId>(formats, magic), logger); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="options"></param> /// <param name="host"></param> /// <param name="formats"></param> /// <param name="handler"></param> /// <param name="logger"></param> public KUdpServer(IOptions <KUdpOptions> options, IKHost <TNodeId> host, IEnumerable <IKMessageFormat <TNodeId> > formats, IKRequestHandler <TNodeId> handler, IKUdpSerializer <TNodeId> serializer, ILogger logger) { this.host = host ?? throw new ArgumentNullException(nameof(host)); this.formats = formats ?? throw new ArgumentNullException(nameof(formats)); this.handler = handler ?? throw new ArgumentNullException(nameof(handler)); this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); queue = new KRequestResponseQueue <TNodeId, ulong>(logger, options.Value.Timeout); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="options"></param> /// <param name="host"></param> /// <param name="formats"></param> /// <param name="connector"></param> /// <param name="handler"></param> /// <param name="logger"></param> public KUdpMulticastDiscovery(IOptions <KUdpOptions> options, IKHost <TNodeId> host, IEnumerable <IKMessageFormat <TNodeId> > formats, IKConnector <TNodeId> connector, IKRequestHandler <TNodeId> handler, ILogger logger) { this.options = options ?? throw new ArgumentNullException(nameof(options)); this.host = host ?? throw new ArgumentNullException(nameof(host)); this.formats = formats ?? throw new ArgumentNullException(nameof(formats)); this.connector = connector ?? throw new ArgumentNullException(nameof(connector)); this.handler = handler ?? throw new ArgumentNullException(nameof(handler)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); serializer = new KUdpSerializer <TNodeId>(formats, magic); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="options"></param> /// <param name="host"></param> /// <param name="invoker"></param> /// <param name="logger"></param> public KFixedTableRouter(IOptions <KFixedTableRouterOptions> options, IKHost <TNodeId> host, IKInvoker <TNodeId> invoker, ILogger logger) { this.options = options ?? throw new ArgumentNullException(nameof(options)); this.host = host ?? throw new ArgumentNullException(nameof(host)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); logger.LogInformation("Initializing Fixed Table Router with {NodeId}.", host.SelfId); buckets = new KBucket <TNodeId> [Unsafe.SizeOf <TNodeId>() * 8]; for (var i = 0; i < buckets.Length; i++) { buckets[i] = new KBucket <TNodeId>(host, invoker, logger, options.Value.K); } }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="host"></param> /// <param name="policy"></param> public KInvoker(IKHost <TNodeId> host, IKInvokerPolicy <TNodeId> policy) { this.host = host ?? throw new ArgumentNullException(nameof(host)); this.policy = policy ?? throw new ArgumentNullException(nameof(policy)); }