using System;
using System.Collections.Generic;
namespace ZB.MOM.WW.CBDDC.Core.Network;
///
/// Represents a peer node in a distributed network, including its unique identifier, network address, and last seen
/// timestamp.
///
public class PeerNode
{
///
/// Initializes a new instance of the PeerNode class with the specified node identifier, network address, and last
/// seen timestamp.
///
/// The unique identifier for the peer node. Cannot be null or empty.
/// The network address of the peer node. Cannot be null or empty.
/// The date and time when the peer node was last seen, expressed as a DateTimeOffset.
/// The type of the peer node. Defaults to LanDiscovered.
/// The role of the peer node. Defaults to Member.
/// The peer node configuration
/// The list of collections this peer is interested in.
public PeerNode(
string nodeId,
string address,
DateTimeOffset lastSeen,
PeerType type = PeerType.LanDiscovered,
NodeRole role = NodeRole.Member,
PeerNodeConfiguration? configuration = null,
IEnumerable? interestingCollections = null)
{
NodeId = nodeId;
Address = address;
LastSeen = lastSeen;
Type = type;
Role = role;
Configuration = configuration;
InterestingCollections = new List(interestingCollections ?? []).AsReadOnly();
}
///
/// Gets the unique identifier for the node.
///
public string NodeId { get; }
///
/// Gets the address associated with the current instance.
///
public string Address { get; }
///
/// Gets the date and time when the entity was last observed or updated.
///
public DateTimeOffset LastSeen { get; }
///
/// Gets the configuration settings for the peer node.
///
public PeerNodeConfiguration? Configuration { get; }
///
/// Gets the type of the peer node (LanDiscovered, StaticRemote, or CloudRemote).
///
public PeerType Type { get; }
///
/// Gets the role assigned to this node within the cluster.
///
public NodeRole Role { get; }
///
/// Gets the list of collections this peer is interested in.
///
public IReadOnlyList InterestingCollections { get; }
}