MCPcopy
hub / github.com/redpanda-data/console / createClient

Method createClient

backend/pkg/factory/kafka/kafka.go:105–124  ·  view source on GitHub ↗

createClient creates a Kafka client based on the provided Kafka configuration.

()

Source from the content-addressed store, hash-verified

103
104// createClient creates a Kafka client based on the provided Kafka configuration.
105func (f *CachedClientProvider) createClient() (*kgo.Client, error) {
106 kgoOpts, err := NewKgoConfig(f.cfg.Kafka, f.logger, f.cfg.MetricsNamespace, f.registry)
107 if err != nil {
108 return nil, apierrors.NewConnectError(
109 connect.CodeInternal,
110 fmt.Errorf("failed to build Kafka config: %w", err),
111 apierrors.NewErrorInfo(commonv1alpha1.Reason_REASON_SERVER_ERROR.String()),
112 )
113 }
114
115 kgoClient, err := kgo.NewClient(kgoOpts...)
116 if err != nil {
117 return nil, err
118 }
119
120 // Track client creation with factory metrics
121 f.factoryMetrics.IncrementActiveClients()
122
123 return kgoClient, nil
124}
125
126// NewKgoConfig creates a new Config for the Kafka Client as exposed by the franz-go library.
127// If TLS certificates can't be read an error will be returned.

Callers 1

GetKafkaClientMethod · 0.95

Calls 3

NewKgoConfigFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected