in src/Epam.Kafka.PubSub/Common/PubSubContext.cs [99:135]
internal SubscriptionMonitor AddSubscription(string name)
{
lock (this._syncObj)
{
if (this._replications.Contains(name))
{
throw new InvalidOperationException($"Subscription with name '{name}' cannot be added because name already used by Replication.");
}
if (this._subscriptions.ContainsKey(name))
{
throw new InvalidOperationException($"Subscription with name '{name}' already added.");
}
if (!RegexHelper.PunSubNameRegex.IsMatch(name))
{
throw new InvalidOperationException(
$"Subscription name '{name}' not match '{RegexHelper.PunSubNameRegex}'.");
}
if (this._subscriptions.Count < MaxSubscriptionsCount)
{
this._subscriptions.Add(name, new SubscriptionMonitor(this, name));
}
else
{
throw new InvalidOperationException($"Max subscriptions count of {MaxSubscriptionsCount} exceeded.");
}
if (!this._bulkheads.IsEmpty)
{
throw new InvalidOperationException();
}
return this._subscriptions[name];
}
}