in src/Epam.Kafka.PubSub/Common/PubSubContext.cs [137:173]
internal PublicationMonitor AddPublication(string name)
{
lock (this._syncObj)
{
if (this._replications.Contains(name))
{
throw new InvalidOperationException($"Publication with name '{name}' cannot be added because name already used by Replication.");
}
if (this._publications.ContainsKey(name))
{
throw new InvalidOperationException($"Publication with name '{name}' already added.");
}
if (!RegexHelper.PunSubNameRegex.IsMatch(name))
{
throw new InvalidOperationException(
$"Publication name '{name}' not match '{RegexHelper.PunSubNameRegex}'.");
}
if (this._publications.Count < MaxPublicationsCount)
{
this._publications.Add(name, new PublicationMonitor(this, name));
}
else
{
throw new InvalidOperationException($"Max publications count of {MaxPublicationsCount} exceeded.");
}
if (!this._bulkheads.IsEmpty)
{
throw new InvalidOperationException();
}
return this._publications[name];
}
}