using Nacos.V2;
using Nacos.V2.Common;
namespace Ocelot.Provider.Nacos.NacosClient.V2;
public class NacosAspNetOptions : NacosSdkOptions
{
///
/// the name of the service.
///
public string ServiceName { get; set; }
///
/// the name of the group.
///
public string GroupName { get; set; } = Constants.DEFAULT_GROUP;
///
/// the name of the cluster.
///
/// The name of the cluster.
public string ClusterName { get; set; } = Constants.DEFAULT_CLUSTER_NAME;
///
/// the ip of this instance
///
public string Ip { get; set; }
///
/// Select an IP that matches the prefix as the service registration IP
/// like the config of spring.cloud.inetutils.preferred-networks
///
public string PreferredNetworks { get; set; }
///
/// the port of this instance
///
public int Port { get; set; }
///
/// the weight of this instance.
///
public double Weight { get; set; } = 100;
///
/// if you just want to subscribe, but don't want to register your service, set it to false.
///
public bool RegisterEnabled { get; set; } = true;
///
/// the metadata of this instance
///
public Dictionary Metadata { get; set; } = new Dictionary();
///
/// If instance is enabled to accept request. The default value is true.
///
public bool InstanceEnabled { get; set; } = true;
///
/// If instance is ephemeral.The default value is true.
///
public bool Ephemeral { get; set; } = true;
///
/// whether your service is a https service.
///
public bool Secure { get; set; } = false;
///
/// Load Balance Strategy
///
public string LBStrategy { get; set; } = LBStrategyName.WeightRandom.ToString();
public NacosSdkOptions BuildSdkOptions()
{
return new NacosSdkOptions
{
AccessKey = this.AccessKey,
ConfigUseRpc = this.ConfigUseRpc,
ContextPath = this.ContextPath,
DefaultTimeOut = this.DefaultTimeOut,
EndPoint = this.EndPoint,
ListenInterval = this.ListenInterval,
Namespace = this.Namespace,
NamingLoadCacheAtStart = this.NamingLoadCacheAtStart,
NamingUseRpc = this.NamingUseRpc,
Password = this.Password,
SecretKey = this.SecretKey,
ServerAddresses = this.ServerAddresses,
UserName = this.UserName,
};
}
}