bool HasPassedTheGracePeriod(DateTime time, HeartbeatingEndpoint heartbeatingEndpoint)
        {
            if (!heartbeatingEndpoint.TimeOfLastHeartbeat.HasValue)
            {
                return(false);
            }

            if (!heartbeatingEndpoint.Active)
            {
                return(false);
            }

            var timeSinceLastHeartbeat = time - heartbeatingEndpoint.TimeOfLastHeartbeat;

            return(timeSinceLastHeartbeat >= GracePeriod);
        }
        HeartbeatingEndpoint GetEndpoint(EndpointDetails endpointDetails)
        {
            var existingEndpoint = TryFindEndpoint(endpointDetails);

            if (existingEndpoint == null)
            {
                existingEndpoint = new HeartbeatingEndpoint
                {
                    Host   = endpointDetails.Host,
                    HostId = endpointDetails.HostId,
                    Name   = endpointDetails.Name
                };

                endpoints.Add(existingEndpoint);
            }
            else
            {
                if (existingEndpoint.HostId == Guid.Empty && endpointDetails.HostId != Guid.Empty)
                {
                    existingEndpoint.HostId = endpointDetails.HostId;
                }
            }
            return(existingEndpoint);
        }
        bool HasPassedTheGracePeriod(DateTime time,HeartbeatingEndpoint heartbeatingEndpoint)
        {
            if (!heartbeatingEndpoint.TimeOfLastHeartbeat.HasValue)
            {
                return false;
            }

            if (!heartbeatingEndpoint.Active)
            {
                return false;
            }


            var timeSinceLastHeartbeat = time - heartbeatingEndpoint.TimeOfLastHeartbeat;

            return timeSinceLastHeartbeat >= GracePeriod;
        }
        HeartbeatingEndpoint GetEndpoint(EndpointDetails endpointDetails)
        {
            var existingEndpoint = TryFindEndpoint(endpointDetails);
            if (existingEndpoint == null)
            {
                existingEndpoint = new HeartbeatingEndpoint
                {
                    Host = endpointDetails.Host,
                    HostId = endpointDetails.HostId,
                    Name = endpointDetails.Name
                };

                endpoints.Add(existingEndpoint);
            }
            else
            {
                if (existingEndpoint.HostId == Guid.Empty && endpointDetails.HostId != Guid.Empty)
                {
                    existingEndpoint.HostId = endpointDetails.HostId;
                }
            }
            return existingEndpoint;
        }