public static bool TryGetStatus(this ServicePingMessage ping, out bool isActive)
 {
     if (!TryGetValue(ping, StatusKey, out var value))
     {
         isActive = false;
         return(false);
     }
     isActive = value == StatusActiveValue;
     return(true);
 }
 public static bool TryGetMessageLogEnableFlag(this ServicePingMessage ping, out bool enableMessageLog)
 {
     if (TryGetValue(ping, DiagnosticLogsMessagingTypeKey, out var value))
     {
         enableMessageLog = value == MessagingLogEnableValue;
         return(true);
     }
     enableMessageLog = default;
     return(false);
 }
Beispiel #3
0
 public static bool TryGetClientCount(this ServicePingMessage ping, out int clientCount)
 {
     if (!TryGetValue(ping, ClientCountKey, out var value) || !int.TryParse(value, out var count))
     {
         clientCount = 0;
         return(false);
     }
     clientCount = count;
     return(true);
 }
        public static bool TryGetServerIds(this ServicePingMessage ping, out HashSet <string> serverIds, out long updatedTime)
        {
            // servers ping format: { "servers", "1234567890:server1;server2;server3" }
            if (!TryGetValue(ping, ServersKey, out var value) || string.IsNullOrEmpty(value) ||
                !long.TryParse(value.Substring(0, value.IndexOf(":")), out updatedTime))
            {
                serverIds   = null;
                updatedTime = DateTime.MinValue.Ticks;
                return(false);
            }
            var servers = value.Substring(value.IndexOf(":") + 1);

            serverIds = new HashSet <string>(servers.Split(new char[] { ServerListSeparator }, StringSplitOptions.RemoveEmptyEntries));
            return(true);
        }
 public static bool TryGetServersTag(this ServicePingMessage ping, out string serversTag, out long updatedTime)
 {
     // servers ping format: { "servers", "1234567890:server1;server2;server3" }
     if (TryGetValue(ping, ServersKey, out var value) && !string.IsNullOrEmpty(value))
     {
         var indexPos = value.IndexOf(":");
         if (long.TryParse(value.Substring(0, indexPos), out updatedTime))
         {
             serversTag = value.Substring(indexPos + 1);
             return(true);
         }
     }
     serversTag  = string.Empty;
     updatedTime = DateTime.MinValue.Ticks;
     return(false);
 }
 public static bool TryGetRebalance(this ServicePingMessage ping, out string target) =>
 TryGetValue(ping, TargetKey, out target);
 public static bool TryGetOffline(this ServicePingMessage ping, out string instanceId) =>
 TryGetValue(ping, OfflineKey, out instanceId);