Esempio n. 1
0
        public static IApplicationInfoProperties SetReplicaTags([NotNull] this IApplicationInfoProperties properties, [NotNull] string replicaName, ReplicaTagKind replicaTagKind, TagCollection tags)
        {
            var propertyKey = new TagsPropertyKey(replicaName, replicaTagKind.ToString());

            if (properties.GetReplicaKindTags(propertyKey).Equals(tags))
            {
                return(properties);
            }

            return(tags?.Count > 0
                ? properties.Set(propertyKey.ToString(), tags.ToString())
                : properties.Remove(propertyKey.ToString()));
        }
 /// <summary>
 /// Clear all tags by given <paramref name="replicaName"/> in the <see cref="IApplicationInfoProperties"/> of the given <paramref name="application"/> and updates it in ServiceDiscovery.
 /// </summary>
 private static async Task <bool> ClearReplicaTagsAsync(this IServiceDiscoveryManager serviceDiscoveryManager, string environment, string application, string replicaName, ReplicaTagKind replicaTagKind)
 {
     return(await serviceDiscoveryManager.TryUpdateApplicationPropertiesAsync(
                environment,
                application,
                properties => properties.ClearReplicaTags(replicaName, replicaTagKind))
            .ConfigureAwait(false));
 }
 /// <summary>
 /// Modifies tags by given <paramref name="replicaName"/> in the <see cref="IApplicationInfoProperties"/> of the given <paramref name="application"/> using <paramref name="modifyTagsFunc"/> and updates it in ServiceDiscovery.
 /// </summary>
 private static async Task <bool> ModifyReplicaTagsAsync(this IServiceDiscoveryManager serviceDiscoveryManager, string environment, string application, string replicaName, ReplicaTagKind replicaTagKind, Func <TagCollection, TagCollection> modifyTagsFunc)
 {
     return(await serviceDiscoveryManager.TryUpdateApplicationPropertiesAsync(
                environment,
                application,
                properties => properties.ModifyReplicaTags(replicaName, replicaTagKind, modifyTagsFunc))
            .ConfigureAwait(false));
 }
 /// <summary>
 /// Remove given <paramref name="tagKeys"/> by <paramref name="replicaName"/> in the <see cref="IApplicationInfoProperties"/> of the given <paramref name="application"/> and updates it in ServiceDiscovery.
 /// </summary>
 private static async Task <bool> RemoveReplicaTagsAsync(this IServiceDiscoveryManager serviceDiscoveryManager, string environment, string application, string replicaName, ReplicaTagKind replicaTagKind, IEnumerable <string> tagKeys)
 {
     return(await serviceDiscoveryManager.TryUpdateApplicationPropertiesAsync(
                environment,
                application,
                properties => properties.RemoveReplicaTags(replicaName, replicaTagKind, tagKeys))
            .ConfigureAwait(false));
 }