Skip to content

Commit 9eb534d

Browse files
committed
Add a Kafka producer (#14)
Move data to the external directory Add .gitattributes Update Makefile
1 parent 421d351 commit 9eb534d

File tree

22 files changed

+368
-55
lines changed

22 files changed

+368
-55
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ test:
4646

4747
.PHONY: lint
4848
lint:
49-
go mod tidy
5049
golangci-lint run ./...
5150

51+
.PHONY: tidy
52+
tidy:
53+
go mod tidy
54+
5255
.PHONY: style
5356
style:
5457
find . -iname *.go | xargs gofmt -w

buf.gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ plugins:
1818
opt:
1919
- lang=go
2020
- name: swagger
21-
out: swagger
21+
out: external/swagger
2222
opt:
2323
- allow_merge=true
2424
- merge_file_name=api

cmd/reddit-feed-api/main.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"flag"
5-
"fmt"
65

76
"github.com/arttet/reddit-feed-api/internal/config"
87
"github.com/arttet/reddit-feed-api/internal/database"
@@ -47,15 +46,7 @@ func main() {
4746
zap.String("version", cfg.Project.Version),
4847
)
4948

50-
dsn := fmt.Sprintf("host=%v port=%v user=%v password=%v dbname=%v sslmode=%v",
51-
cfg.Database.Host,
52-
cfg.Database.Port,
53-
cfg.Database.User,
54-
cfg.Database.Password,
55-
cfg.Database.Name,
56-
cfg.Database.SslMode,
57-
)
58-
49+
dsn := cfg.Database.String()
5950
db, err := database.NewConnection(dsn, cfg.Database.Driver)
6051
if err != nil {
6152
logger.Fatal("database initialization", zap.Error(err))

config-dev.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ project:
22
name: Reddit Feed API
33
debug: true
44
environment: development
5-
swaggerDir: swagger
5+
swaggerDir: external/swagger
66

77
grpc:
88
host: 0.0.0.0
@@ -23,7 +23,7 @@ logger:
2323
- logs.json
2424
errorOutputPaths:
2525
- stdout
26-
- errors.json
26+
- logs.json
2727
encoderConfig:
2828
messageKey: message
2929
levelKey: level
@@ -59,3 +59,10 @@ status:
5959
readinessPath: /ready
6060
swaggerPath: /swagger/
6161
versionPath: /version
62+
63+
kafka:
64+
capacity: 512
65+
topic: reddit-feed-events
66+
groupId: reddit-feed-api
67+
brokers:
68+
- localhost:9092

config.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
project:
22
name: Reddit Feed API
3-
debug: false
3+
debug: true
44
environment: production
5-
swaggerDir: swagger
5+
swaggerDir: external/swagger
66

77
grpc:
88
host: 0.0.0.0
@@ -55,3 +55,11 @@ status:
5555
readinessPath: /ready
5656
swaggerPath: /swagger/
5757
versionPath: /version
58+
59+
kafka:
60+
capacity: 512
61+
topic: reddit-feed-events
62+
groupId: reddit-feed-api
63+
brokers:
64+
- kafka:9092
65+
- localhost:9094

docker-compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ services:
6060
- reddit-network
6161
volumes:
6262
# - pgdata:/var/lib/postgresql/data
63-
- ./scripts/init-database.sh:/docker-entrypoint-initdb.d/init-database.sh
63+
- ./external/scripts/init-database.sh:/docker-entrypoint-initdb.d/init-database.sh
6464

6565
jaeger:
6666
image: jaegertracing/all-in-one
@@ -89,7 +89,7 @@ services:
8989
networks:
9090
- reddit-network
9191
volumes:
92-
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
92+
- "./external/prometheus.yml:/etc/prometheus/prometheus.yml"
9393

9494
zookeeper:
9595
image: confluentinc/cp-zookeeper
@@ -151,7 +151,7 @@ services:
151151
- 8080:8080
152152
restart: always
153153
volumes:
154-
- ./swagger:/docs
154+
- ./external/swagger:/docs
155155
environment:
156156
SWAGGER_JSON: /docs/api.swagger.json
157157
depends_on:
File renamed without changes.

0 commit comments

Comments
 (0)