MCPcopy
hub / github.com/elastic/go-elasticsearch / CreateTopic

Method CreateTopic

_examples/bulk/kafka/producer/producer.go:82–94  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

80}
81
82func (p *Producer) CreateTopic(ctx context.Context) error {
83 conn, err := net.Dial("tcp", p.BrokerURL)
84 if err != nil {
85 return err
86 }
87
88 return kafka.NewConn(conn, "", 0).CreateTopics(
89 kafka.TopicConfig{
90 Topic: p.TopicName,
91 NumPartitions: p.TopicParts,
92 ReplicationFactor: 1,
93 })
94}
95
96func (p *Producer) generateMessage(t time.Time) []byte {
97 var (

Callers 1

mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected