Skip to content

Commit 6ec0bae

Browse files
committed
(refactor): make TOPICS singular
1 parent 9d7585e commit 6ec0bae

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

.envrc.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ export SNOWSQL_SCHEMA=public
2020
export RPK_BROKERS=localhost:19092
2121
export COMPOSE_PROJECT_NAME=grpc-todo-app
2222
# The redpanda schema registry (internal to docker )
23-
export RP_SCHEMA_REGISTRY_INTERNAL=http://redpanda-0:8081
23+
export RP_SCHEMA_REGISTRY_INTERNAL=http://redpanda-0:18081
24+
# The redpanda schema registry (external to docker)
25+
export SCHEMA_REGISTRY=http://localhost:18081
2426
# Kafka Connect URL
2527
export KAFKA_CONNECT_URI=localhost:18083
2628
# gRPC service port
2729
export PORT=9090
2830
# Redpanda Brokers
2931
export BROKERS="$RPK_BROKERS"
3032
# Topic to store the Todo
31-
export TOPICS=todo-list
33+
export TOPIC=todo-list
3234
# Running environment, typically used for grpcURL
3335
export ENV=dev
3436
# The consumer group used while consuming messages

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ An output similar to this,
294294
295295
> **IMPORTANT**: Ensure the required environment variables are set. The following command expects the following variables
296296
>
297-
> - `$TOPICS`
297+
> - `$TOPIC`
298298
> - `$SNOWSQL_ACCOUNT`
299299
> - `$TODOAPP_USER`
300300
> - `$TODOAPP_USER_RSA_PRIVATE_KEY`
@@ -371,7 +371,7 @@ snowsql -u $TODOAPP_USER \
371371
--private-key-path="$DEMO_HOME/keys/rsa_key.p8" \
372372
--warehouse $SNOWSQL_WAREHOUSE \
373373
--dbname $TODOAPP_DATABASE \
374-
--variable redpanda_topic=$TOPICS \
374+
--variable redpanda_topic=$TOPIC \
375375
--filename "$DEMO_HOME/etc/snowflake/todo_list_query.sql"
376376
```
377377
@@ -429,7 +429,7 @@ snowsql -u $TODOAPP_USER \
429429
--warehouse $SNOWSQL_WAREHOUSE \
430430
--dbname $TODOAPP_DATABASE \
431431
--variable todo_warehouse=$SNOWSQL_WAREHOUSE \
432-
--variable topic_name=$TOPICS \
432+
--variable topic_name=$TOPIC \
433433
--variable table_name=$TODOS_TABLE \
434434
--filename "$DEMO_HOME/etc/snowflake/dynamic_table.sql"
435435
```

cmd/server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
config := config.New()
4343
client, err := kgo.NewClient(
4444
kgo.SeedBrokers(config.Seeds...),
45-
kgo.ConsumeTopics(config.Topics...),
45+
kgo.ConsumeTopics(config.Topic),
4646
kgo.DefaultProduceTopic(config.DefaultProducerTopic()),
4747
kgo.ConsumerGroup(config.ConsumerGroupID),
4848
kgo.AllowAutoTopicCreation(),

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Config struct {
1111
ConsumerGroupID string `env:"CONSUMER_GROUP_ID"`
1212
Port uint16 `env:"PORT" envDefault:"9090"`
1313
Seeds []string `env:"BROKERS" envSeparator:"," envDefault:"localhost:19092"`
14-
Topics []string `env:"TOPICS" envSeparator:","`
14+
Topic string `env:"TOPIC" `
1515
SchemaRegistry string `env:"SCHEMA_REGISTRY" envDefault:"localhost:18081"`
1616
SchemaURL string `env:"SCHEMA_URL" envDefault:"https://raw.githubusercontent.com/kameshsampath/demo-protos/main/todo/todo.proto"`
1717
}
@@ -36,5 +36,5 @@ func New() *Config {
3636

3737
// DefaultProducerTopic gets the default topic that will be used as the producer topic
3838
func (c *Config) DefaultProducerTopic() string {
39-
return c.Topics[0]
39+
return c.Topic
4040
}

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3.7"
21
name: grpc-todo-app
32
networks:
43
_network:
@@ -124,7 +123,7 @@ services:
124123
environment:
125124
- PORT=9090
126125
- BROKERS=redpanda-0:9092
127-
- TOPICS=todo-list
126+
- TOPIC=todo-list
128127
- ENV=dev
129128
- CONSUMER_GROUP_ID=grpc-todo-app
130129
- SCHEMA_REGISTRY=redpanda-0:8081

etc/config/todolist-snow-sink.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"config": {
44
"connector.class": "com.snowflake.kafka.connector.SnowflakeSinkConnector",
55
"tasks.max": "8",
6-
"topics": "${TOPICS}",
7-
"snowflake.topic2table.map": "${TOPICS}:${TODO_LIST_TABLE}",
6+
"topics": "${TOPIC}",
7+
"snowflake.topic2table.map": "${TOPIC}:${TODO_LIST_TABLE}",
88
"buffer.count.records": "10",
99
"buffer.flush.time": "10",
1010
"buffer.size.bytes": "500",

0 commit comments

Comments
 (0)