-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Eray Ates <[email protected]>
- Loading branch information
Showing
6 changed files
with
90 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log/slog" | ||
"sync" | ||
|
||
"github.com/worldline-go/initializer" | ||
"github.com/worldline-go/wkafka" | ||
) | ||
|
||
var ( | ||
kafkaConfig = wkafka.Config{ | ||
Brokers: []string{"localhost:9092"}, | ||
} | ||
) | ||
|
||
func main() { | ||
initializer.Init(run) | ||
} | ||
|
||
func run(ctx context.Context, _ *sync.WaitGroup) error { | ||
client, err := wkafka.NewClient(kafkaConfig) | ||
if err != nil { | ||
return err | ||
Check failure on line 25 in example/admin/main.go GitHub Actions / sonarcloud
Check failure on line 25 in example/admin/main.go GitHub Actions / sonarcloud
|
||
} | ||
defer client.Close() | ||
|
||
admClient := client.Admin() | ||
|
||
resp, err := admClient.CreateTopic(ctx, -1, -1, nil, "test-1234") | ||
if err != nil { | ||
return err | ||
Check failure on line 33 in example/admin/main.go GitHub Actions / sonarcloud
Check failure on line 33 in example/admin/main.go GitHub Actions / sonarcloud
|
||
} | ||
|
||
slog.Info("topic created", | ||
slog.String("topic", resp.Topic), | ||
slog.Int64("partitions", int64(resp.NumPartitions)), | ||
slog.Int64("replicas", int64(resp.ReplicationFactor)), | ||
) | ||
|
||
// list topics | ||
topics, err := admClient.ListTopics(ctx) | ||
if err != nil { | ||
return err | ||
Check failure on line 45 in example/admin/main.go GitHub Actions / sonarcloud
Check failure on line 45 in example/admin/main.go GitHub Actions / sonarcloud
|
||
} | ||
|
||
slog.Info("all topics", slog.Any("topics", topics.Names())) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters