This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: add first poc for a Kafka proxy #7
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
linters: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- errorlint | ||
- exportloopref | ||
- exhaustive | ||
- forbidigo | ||
- funlen | ||
- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- godot | ||
- gofumpt | ||
- goimports | ||
- revive | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ifshort | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- noctx | ||
- nolintlint | ||
- rowserrcheck | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
|
||
linters-settings: | ||
forbidigo: | ||
forbid: | ||
- fmt.Print.* # usually just used for debugging purpose |
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,12 @@ | ||
FROM golang:1.16 | ||
|
||
WORKDIR /go/src/app | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN go mod download | ||
|
||
COPY . . | ||
RUN make build | ||
|
||
EXPOSE 28002 | ||
ENTRYPOINT ["./bin/out/app"] |
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,57 @@ | ||
# Makefile based on https://gist.github.com/thomaspoignant/5b72d579bd5f311904d973652180c705 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
GOCMD=go | ||
GOTEST=$(GOCMD) test | ||
PROJECT_NAME := $(shell basename "$(PWD)") | ||
BINARY_NAME?=$(PROJECT_NAME) | ||
BIN_DIR?=bin | ||
TOOLS_DIR?=bin/tools | ||
|
||
GREEN := $(shell tput -Txterm setaf 2) | ||
YELLOW := $(shell tput -Txterm setaf 3) | ||
WHITE := $(shell tput -Txterm setaf 7) | ||
CYAN := $(shell tput -Txterm setaf 6) | ||
RESET := $(shell tput -Txterm sgr0) | ||
|
||
GOLANGCILINT_VERSION = 1.40.1 | ||
|
||
.PHONY: all test build vendor | ||
|
||
all: help | ||
|
||
## Build: | ||
build: ## Build your project and put the output binary in bin/out | ||
mkdir -p $(BIN_DIR) | ||
$(GOCMD) build -o bin/out/$(BINARY_NAME) . | ||
|
||
## Linting: | ||
lint: $(TOOLS_DIR)/golangci-lint ## Run linters | ||
$(TOOLS_DIR)/golangci-lint run | ||
|
||
## Test: | ||
test: ## Run the tests of the project | ||
$(GOTEST) -v -race ./... | ||
|
||
coverage: ## Run the tests of the project and export the coverage | ||
$(GOTEST) -cover -covermode=count -coverprofile=profile.cov ./... | ||
$(GOCMD) tool cover -func profile.cov | ||
|
||
## Help: | ||
help: ## Show this help. | ||
@echo '' | ||
@echo 'Usage:' | ||
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}' | ||
@echo '' | ||
@echo 'Targets:' | ||
@awk 'BEGIN {FS = ":.*?## "} { \ | ||
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \ | ||
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \ | ||
}' $(MAKEFILE_LIST) | ||
$(BIN_DIR): | ||
mkdir -p $(BIN_DIR) | ||
|
||
$(TOOLS_DIR): | ||
mkdir -p $(TOOLS_DIR) | ||
|
||
$(TOOLS_DIR)/golangci-lint: $(TOOLS_DIR) | ||
@wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | BINDIR=$(@D) sh -s v$(GOLANGCILINT_VERSION) > /dev/null 2>&1 |
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,40 @@ | ||
--- | ||
version: "3.5" | ||
|
||
services: | ||
zookeeper: | ||
image: confluentinc/cp-zookeeper:latest | ||
hostname: zookeeper | ||
container_name: zookeeper | ||
environment: | ||
ZOOKEEPER_CLIENT_PORT: 2181 | ||
|
||
broker: | ||
image: confluentinc/cp-kafka:latest | ||
hostname: broker | ||
container_name: broker | ||
depends_on: | ||
- zookeeper | ||
ports: | ||
- "9092:9092" # external connection | ||
environment: | ||
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181' | ||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT | ||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092 | ||
KAFKA_BROKER_ID: 1 | ||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | ||
KAFKA_LOG4J_ROOT_LOGLEVEL: ERROR | ||
KAFKA_LOG4J_LOGGERS: 'KafkaRequestHandler=TRACE,kafka.server.KafkaApis=TRACE,kafka.log.Log=TRACE,kafka.network.RequestChannel=TRACE,kafka.network.Processor=TRACE' | ||
|
||
proxy: | ||
hostname: proxy | ||
container_name: proxy | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
environment: | ||
EVENTGATEWAY_KAFKA_PROXY_BROKERS_MAPPING: 'localhost:9092,proxy:28002' | ||
EVENTGATEWAY_KAFKA_PROXY_BROKERS_DIAL_MAPPING: 'localhost:9092,broker:9092' | ||
EVENTGATEWAY_DEBUG: 'true' | ||
depends_on: | ||
- broker |
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,25 @@ | ||
module github.com/asyncapi/event-gateway | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 | ||
github.com/frankban/quicktest v1.11.3 // indirect | ||
github.com/grepplabs/kafka-proxy v0.2.8 | ||
github.com/kelseyhightower/envconfig v1.4.0 | ||
github.com/klauspost/compress v1.12.2 | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/pierrec/lz4 v2.6.0+incompatible | ||
github.com/pkg/errors v0.9.1 | ||
github.com/sirupsen/logrus v1.8.1 | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
github.com/xdg/scram v1.0.3 // indirect | ||
github.com/xdg/stringprep v1.0.3 // indirect | ||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect | ||
golang.org/x/net v0.0.0-20210427231257-85d9c07bbe3a // indirect | ||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | ||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
) | ||
|
||
replace github.com/grepplabs/kafka-proxy => github.com/smoya/kafka-proxy v0.2.9-0.20210623125118-a94cf71a065c | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the replace directive in order to use my forked version of grepplabs/kafka-proxy |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comes from https://github.com/asyncapi/template-for-go-projects