github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/topic/topicoptions/topicoptions_create.go (about) 1 package topicoptions 2 3 import ( 4 "sort" 5 "time" 6 7 "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic" 8 "github.com/ydb-platform/ydb-go-sdk/v3/topic/topictypes" 9 ) 10 11 // CreateOption type for options of topic create 12 type CreateOption interface { 13 ApplyCreateOption(request *rawtopic.CreateTopicRequest) 14 } 15 16 // CreateWithMeteringMode set metering mode for the topic 17 func CreateWithMeteringMode(mode topictypes.MeteringMode) CreateOption { 18 return withMeteringMode(mode) 19 } 20 21 // CreateWithMinActivePartitions set min active partitions for the topic 22 func CreateWithMinActivePartitions(count int64) CreateOption { 23 return withMinActivePartitions(count) 24 } 25 26 // CreateWithPartitionCountLimit set partition count limit for the topic 27 func CreateWithPartitionCountLimit(count int64) CreateOption { 28 return withPartitionCountLimit(count) 29 } 30 31 // CreateWithRetentionPeriod set retention time interval for the topic. 32 func CreateWithRetentionPeriod(retentionPeriod time.Duration) CreateOption { 33 return withRetentionPeriod(retentionPeriod) 34 } 35 36 // CreateWithRetentionStorageMB set retention size for the topic. 37 func CreateWithRetentionStorageMB(retentionStorageMB int64) CreateOption { 38 return withRetentionStorageMB(retentionStorageMB) 39 } 40 41 // CreateWithSupportedCodecs set supported codecs for the topic 42 func CreateWithSupportedCodecs(codecs ...topictypes.Codec) CreateOption { 43 sort.Slice(codecs, func(i, j int) bool { 44 return codecs[i] < codecs[j] 45 }) 46 47 return withSupportedCodecs(codecs) 48 } 49 50 // CreateWithPartitionWriteSpeedBytesPerSecond set write size limit for partitions of the topic 51 func CreateWithPartitionWriteSpeedBytesPerSecond(partitionWriteSpeedBytesPerSecond int64) CreateOption { 52 return withPartitionWriteSpeedBytesPerSecond(partitionWriteSpeedBytesPerSecond) 53 } 54 55 // CreateWithPartitionWriteBurstBytes set burst limit for partitions of the topic 56 func CreateWithPartitionWriteBurstBytes(partitionWriteBurstBytes int64) CreateOption { 57 return withPartitionWriteBurstBytes(partitionWriteBurstBytes) 58 } 59 60 // CreateWithAttributes set attributes for the topic. 61 func CreateWithAttributes(attributes map[string]string) CreateOption { 62 return withAttributes(attributes) 63 } 64 65 // CreateWithConsumer create new consumers with the topic 66 func CreateWithConsumer(consumers ...topictypes.Consumer) CreateOption { 67 sort.Slice(consumers, func(i, j int) bool { 68 return consumers[i].Name < consumers[j].Name 69 }) 70 71 return withAddConsumers(consumers) 72 }