Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranVanBelle committed Dec 18, 2024
1 parent e76d1d5 commit b32f2a3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 20 deletions.
70 changes: 52 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,58 @@
version: "3.8"

services:
zookeeper:
image: confluentinc/cp-zookeeper
hostname: zookeeper
ports:
- 2182:2181
environment:
SERVICE_NAME: zookeeper
ZOOKEEPER_CLIENT_PORT: 2181

kafka:
image: confluentinc/cp-kafka:latest
hostname: localhost
# Redpanda cluster
redpanda-1:
image: docker.redpanda.com/redpandadata/redpanda:v23.1.1
container_name: redpanda-1
command:
- redpanda
- start
- --smp
- '1'
- --reserve-memory
- 0M
- --overprovisioned
- --node-id
- '1'
- --kafka-addr
- PLAINTEXT://0.0.0.0:29092,OUTSIDE://0.0.0.0:9092
- --advertise-kafka-addr
- PLAINTEXT://redpanda-1:29092,OUTSIDE://localhost:9092
- --pandaproxy-addr
- PLAINTEXT://0.0.0.0:28082,OUTSIDE://0.0.0.0:8082
- --advertise-pandaproxy-addr
- PLAINTEXT://redpanda-1:28082,OUTSIDE://localhost:8082
- --rpc-addr
- 0.0.0.0:33145
- --advertise-rpc-addr
- redpanda-1:33145
ports:
# - 8081:8081
- 8082:8082
- 9092:9092
links:
- zookeeper:zookeeper
- 9644:9644
- 28082:28082
- 29092:29092

redpanda-console:
image: docker.redpanda.com/redpandadata/console:v2.2.2
container_name: redpanda-console
entrypoint: /bin/sh
command: -c "echo \"$$CONSOLE_CONFIG_FILE\" > /tmp/config.yml; /app/console"
environment:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://$KAFKA_TEST_BROKER:9092"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_CREATE_TOPICS:
CONFIG_FILEPATH: /tmp/config.yml
CONSOLE_CONFIG_FILE: |
kafka:
brokers: ["kafka:9092"]
schemaRegistry:
enabled: false
redpanda:
adminApi:
enabled: false
connect:
enabled: false
ports:
- 8080:8080
depends_on:
- redpanda-1
3 changes: 3 additions & 0 deletions src/Kafka/Admin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Kafka.Internal.Setup

import Kafka.Types
import Kafka.Admin.AdminProperties
import Kafka.Admin.Types

data KAdmin = KAdmin {
adminKafka :: !Kafka
Expand All @@ -24,3 +25,5 @@ newKAdmin properties = liftIO $ do
Left err -> pure $ Left $ KafkaError err
Right kafka -> pure $ Right $ KAdmin (Kafka kafka) kafkaConfig

--- CREATE TOPIC ---

25 changes: 23 additions & 2 deletions src/Kafka/Admin/Types.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
module Kafka.Admin.Types where

import Data.Map

import Kafka.Types
import Kafka.Internal.Setup

data KafkaAdmin = KafkaAdmin {
adminProperties :: !Kafka
, kpKafkaConf :: !KafkaConf
kcKafkaPtr :: !Kafka
, kcKafkaConf :: !KafkaConf
}

instance HasKafka KafkaAdmin where
getKafka = kcKafkaPtr
{-# INLINE getKafka #-}

instance HasKafkaConf KafkaAdmin where
getKafkaConf = kcKafkaConf
{-# INLINE getKafkaConf #-}

newtype PartitionsCount = PartitionsCount { unPartitionsCount :: Int } deriving (Show, Eq)
newtype ReplicationFactor = ReplicationFactor { unReplicationFactor :: Int } deriving (Show, Eq)

data NewTopic = NewTopic {
topicName :: TopicName
, topicPartitions :: PartitionsCount
, topicReplicationFactor :: ReplicationFactor
, topicConfig :: Map String String
} deriving (Show)

0 comments on commit b32f2a3

Please sign in to comment.