public static TopicName Create( string capabilityRootId, string topicName, TopicAvailability topicAvailability ) { var cleanTopicName = CleanString(topicName); if (cleanTopicName.Length < 1) { throw new TopicNameTooShortException(); } var topicAvailableSection = topicAvailability is TopicAvailabilityPublic ? "pub." : ""; var combinedString = topicAvailableSection + CreatePrefix(capabilityRootId) + "." + cleanTopicName; if (combinedString.Length > MAX_TOPIC_NAME_LENGTH) { throw new TopicNameTooLongException(combinedString.ToLower(), MAX_TOPIC_NAME_LENGTH); } var charStringInLowerCase = combinedString.ToLower(); return(new TopicName(charStringInLowerCase)); }
public static Topic Create( Guid capabilityId, Guid kafkaClusterId, string capabilityRootId, string name, string description, int partitions, string availability, Dictionary <string, object> configurations ) { const int lowerAllowedPartitions = 1; const int upperAllowedPartitions = 12; if (partitions < lowerAllowedPartitions || upperAllowedPartitions < partitions) { throw new PartitionsCountNotAllowedException( lowerAllowedPartitions, upperAllowedPartitions, partitions ); } if (description.Length > 1000) { throw new TopicDescriptionTooLongException(); } var topicAvailability = TopicAvailability.FromString(availability); var topicName = TopicName.Create( capabilityRootId, name, topicAvailability ); var topic = new Topic( TopicId.Create(), capabilityId: capabilityId, kafkaClusterId: kafkaClusterId, name: topicName, description: description, partitions: partitions, created: DateTime.UtcNow, lastModified: DateTime.UtcNow, configurations: configurations ); topic.RaiseEvent(new TopicCreated(topic)); return(topic); }