MCPcopy Create free account
hub / github.com/IBM/sarama / CreateTopic

Method CreateTopic

admin.go:336–378  ·  view source on GitHub ↗
(topic string, detail *TopicDetail, validateOnly bool)

Source from the content-addressed store, hash-verified

334}
335
336func (ca *clusterAdmin) CreateTopic(topic string, detail *TopicDetail, validateOnly bool) error {
337 if topic == "" {
338 return ErrInvalidTopic
339 }
340
341 if detail == nil {
342 return errors.New("you must specify topic details")
343 }
344
345 topicDetails := map[string]*TopicDetail{
346 topic: detail,
347 }
348
349 request := NewCreateTopicsRequest(
350 ca.conf.Version,
351 topicDetails,
352 ca.conf.Admin.Timeout,
353 validateOnly,
354 )
355
356 return ca.retryOnControllerError(func() error {
357 b, err := ca.Controller()
358 if err != nil {
359 return err
360 }
361
362 rsp, err := b.CreateTopics(request)
363 if err != nil {
364 return err
365 }
366
367 topicErr, ok := rsp.TopicErrors[topic]
368 if !ok {
369 return ErrIncompleteResponse
370 }
371
372 if !errors.Is(topicErr.Err, ErrNoError) {
373 return topicErr
374 }
375
376 return nil
377 })
378}
379
380func (ca *clusterAdmin) DescribeTopics(topics []string) (metadata []*TopicMetadata, err error) {
381 var response *MetadataResponse

Callers

nothing calls this directly

Calls 5

ControllerMethod · 0.95
NewCreateTopicsRequestFunction · 0.85
CreateTopicsMethod · 0.80
IsMethod · 0.80

Tested by

no test coverage detected