/* * Copyright (c) 2023 Vaughn Nugent * * Library: VNLib * Package: VNLib.Data.Caching.Extensions * File: CacheNodeConfiguration.cs * * CacheNodeConfiguration.cs is part of VNLib.Data.Caching.Extensions which is part of the larger * VNLib collection of libraries and utilities. * * VNLib.Data.Caching.Extensions is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * VNLib.Data.Caching.Extensions is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ using System; namespace VNLib.Data.Caching.Extensions { public class CacheNodeConfiguration: CacheClientConfiguration, ICachePeerAdvertisment { /// /// The address for clients to connect to /// public Uri? ConnectEndpoint { get; private set; } /// /// Whether or not to advertise ourself to peer nodes /// public bool BroadcastAdverisment { get; private set; } /// /// Define the endpoint for clients to connect to to discover /// other discovertable nodes /// public Uri? DiscoveryEndpoint { get; private set; } /// /// Sets the full address of our cache endpoint for clients to connect to /// /// The uri clients will attempt to connect to public CacheNodeConfiguration WithCacheEndpoint(Uri connectUri) { ConnectEndpoint = connectUri; return this; } public CacheNodeConfiguration EnableAdvertisment(bool enable, Uri? discoveryEndpoint) { BroadcastAdverisment = enable; DiscoveryEndpoint = discoveryEndpoint; return this; } /// public string NodeId { get; private set; } = null!; /// /// Specifies the current server's cluster node id. If this /// is a server connection attempting to listen for changes on the /// remote server, this id must be set and unique /// /// The cluster node id of the current server /// Chainable fluent object /// public CacheClientConfiguration WithNodeId(string nodeId) { NodeId = nodeId ?? throw new ArgumentNullException(nameof(nodeId)); return this; } } }