Skip to content

Commit

Permalink
feat: Added kafka connect service
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexnortung committed Oct 31, 2024
1 parent 873ee03 commit 5b46148
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/modules/services/kafka-connect.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ pkgs, lib, config, ... }:

let
kafkaCfg = config.services.kafka;
cfg = config.services.kafka.connect;
types = lib.types;

in
{
options.services.kafka.connect = {
enable = lib.mkEnableOption "Kafka Connect";
};

config =
let
pkg = kafkaCfg.package;
stateDir = config.env.DEVENV_STATE + "/kafka/connect";
storageFile = stateDir + "/connect.offsets";

configFile = pkgs.writeText "connect-standalone.properties" ''
bootstrap.servers=localhost:9092
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=true
value.converter.schemas.enable=true
offset.storage.file.filename=${storageFile}
offset.flush.interval.ms=10000
'';

startKafkaConnect = pkgs.writeShellScriptBin "start-kafka-connect" ''
mkdir -p ${stateDir}
${pkg}/bin/connect-standalone.sh ${configFile}
'';
in
lib.mkIf cfg.enable (lib.mkIf kafkaCfg.enable {

processes.kafka-connect.exec = "${startKafkaConnect}/bin/start-kafka-connect";
});
}

0 comments on commit 5b46148

Please sign in to comment.