You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Network/Models/MicroserviceInfo.cs

77 lines
2.6 KiB

6 years ago
using System;
using System.Runtime.Serialization;
namespace ZeroLevel.Network.Microservices
{
[Serializable]
[DataContract]
public sealed class MicroserviceInfo :
IEquatable<MicroserviceInfo>
{
public const string DEFAULT_GROUP_NAME = "__service_default_group__";
public const string DEFAULT_TYPE_NAME = "__service_default_type__";
/// <summary>
6 years ago
/// Service key, must be unique within the business functionality.
/// two services with same key will be horizontally balanced
6 years ago
/// </summary>
[DataMember]
public string ServiceKey { get; set; }
/// <summary>
6 years ago
/// The group can determine the services working in the same domain
6 years ago
/// </summary>
[DataMember]
public string ServiceGroup { get; set; } = DEFAULT_GROUP_NAME;
/// <summary>
6 years ago
/// The type of service, for filtering, determines membership in a subgroup.
6 years ago
/// </summary>
[DataMember]
public string ServiceType { get; set; } = DEFAULT_TYPE_NAME;
/// <summary>
6 years ago
/// Protocol on which access to the service API is allowed
6 years ago
/// </summary>
[DataMember]
public string Protocol { get; set; }
/// <summary>
6 years ago
/// Connection point, address
6 years ago
/// </summary>
[DataMember]
public string Endpoint { get; set; }
/// <summary>
6 years ago
/// Service version
6 years ago
/// </summary>
[DataMember]
public string Version { get; set; }
public bool Equals(MicroserviceInfo other)
{
if (other == null) return false;
if (object.ReferenceEquals(this, other)) return true;
if (string.Compare(this.ServiceKey, other.ServiceKey, true) != 0) return false;
if (string.Compare(this.ServiceGroup, other.ServiceGroup, true) != 0) return false;
if (string.Compare(this.ServiceType, other.ServiceType, true) != 0) return false;
if (string.Compare(this.Endpoint, other.Endpoint, true) != 0) return false;
if (string.Compare(this.Version, other.Version, true) != 0) return false;
if (string.Compare(this.Protocol, other.Protocol, true) != 0) return false;
return true;
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return this.ServiceKey.GetHashCode() ^ this.Protocol.GetHashCode() ^ this.Endpoint.GetHashCode();
}
public override string ToString()
{
return $"{ServiceKey} ({Version})";
}
}
}

Powered by TurnKey Linux.