Compare commits

..

2 Commits

Author SHA1 Message Date
d7d10ab2a4
feature: consumer code 2023-06-25 10:14:27 +02:00
fc28a7678c
feature: develop kafka producer 2023-06-25 10:14:20 +02:00
3 changed files with 10 additions and 6 deletions

View File

@ -1,15 +1,18 @@
.PHONY: build .PHONY: build-producer build-consumer run dependencies infrastructure-local infrastructure-prod topic-scram topic-ssl consume-topic
ACTION=apply ACTION=apply
build: dependencies build-producer: dependencies
go build -o out/kafka ./cmd/main.go go build -o out/kafka-producer ./cmd/producer.go
build-consumer: dependencies
go built -o out/kafka-consumer ./cmd/consumer.go
dependencies: dependencies:
go mod tidy go mod tidy
run: run:
./out/kafka -c ./configuration.yaml ./out/kafka-producer -c ./configuration.yaml
infrastructure-local: infrastructure-local:
cd manifest && \ cd manifest && \

View File

@ -2,6 +2,7 @@ package main
import ( import (
. "antoine-roux.tk/kafka/internal/configuration" . "antoine-roux.tk/kafka/internal/configuration"
"fmt"
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
"log" "log"
_ "net/http/pprof" _ "net/http/pprof"
@ -29,7 +30,7 @@ func main() {
_, _, err := producer.SendMessage(&sarama.ProducerMessage{ _, _, err := producer.SendMessage(&sarama.ProducerMessage{
Topic: string(application.EmitterTopic), Topic: string(application.EmitterTopic),
Key: nil, Key: nil,
Value: sarama.StringEncoder("test"), Value: sarama.StringEncoder(fmt.Sprintf("test number %d", i)),
}) })
if err != nil { if err != nil {
log.Printf("Message delivery error %s\n", err) log.Printf("Message delivery error %s\n", err)

View File

@ -13,7 +13,7 @@ kafka:
# k view-secret -n streaming kafka-user user.key # k view-secret -n streaming kafka-user user.key
key: <client pem key> key: <client pem key>
# k view-secret kafka-dev-listener-certificate ca.crt # k view-secret cluster-development-cluster-ca-cert ca.crt
ca: <server root certificate> ca: <server root certificate>
group-name: some-consumer-name group-name: some-consumer-name
topics: topics: