Compare commits

..

6 commits

3 changed files with 24 additions and 18 deletions

View file

@ -20,9 +20,6 @@
languages.java.maven.enable = true; languages.java.maven.enable = true;
languages.nix.enable = true; languages.nix.enable = true;
# https://devenv.sh/processes/
# processes.cargo-watch.exec = "cargo-watch";
scripts = scripts =
let let
datasource = "-Dspring.datasource.url=jdbc:postgresql://${config.services.postgres.listen_addresses}:5432"; datasource = "-Dspring.datasource.url=jdbc:postgresql://${config.services.postgres.listen_addresses}:5432";
@ -49,36 +46,40 @@
"distributed-init".exec = '' "distributed-init".exec = ''
cd ${config.env.DEVENV_ROOT}/flex-training-flexinale cd ${config.env.DEVENV_ROOT}/flex-training-flexinale
mvn test -Dtest=testdata.AllTestDataLoader -pl flexinale-distributed -am mvn test -Dtest=testdata.AllTestDataLoader -pl flexinale-distributed -am
mvn test -Dtest=testdata.FKKsVTestDataLoader -pl flexinale-distributed -am
''; '';
"distributed-portal".exec = '' "distributed-portal".exec = ''
java ${datasource}/distributed-besucherportal \ java ${datasource}/distributed-besucherportal \
-Dbootstrap.servers=localhost:29092 \ -Dbootstrap.servers=localhost:9092 \
-Dspring.kafka.consumer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
-Dspring.kafka.producer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-besucherportal/target/flexinale-distributed-besucherportal-2024.3.0-spring-boot-fat-jar.jar -jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-besucherportal/target/flexinale-distributed-besucherportal-2024.3.0-spring-boot-fat-jar.jar
''; '';
"distributed-backoffice".exec = '' "distributed-backoffice".exec = ''
java ${datasource}/distributed-backoffice \ java ${datasource}/distributed-backoffice \
-Dbootstrap.servers=localhost:29092 \ -Dbootstrap.servers=localhost:9092 \
-Dspring.kafka.consumer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
-Dspring.kafka.producer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-backoffice/target/flexinale-distributed-backoffice-2024.3.0-spring-boot-fat-jar.jar -jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-backoffice/target/flexinale-distributed-backoffice-2024.3.0-spring-boot-fat-jar.jar
''; '';
"distributed-ticketing".exec = '' "distributed-ticketing".exec = ''
java ${datasource}/distributed-ticketing \ java ${datasource}/distributed-ticketing \
-Dbootstrap.servers=localhost:29092 \ -Dbootstrap.servers=localhost:9092 \
-Dspring.kafka.consumer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
-Dspring.kafka.producer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-ticketing/target/flexinale-distributed-ticketing-2024.3.0-spring-boot-fat-jar.jar -jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-ticketing/target/flexinale-distributed-ticketing-2024.3.0-spring-boot-fat-jar.jar
''; '';
}; };
services.apache-kafka = { services.kafka = {
enable = true; enable = true;
clusterId = "foobar"; clusterId = "foobar";
settings = { settings = {
"broker.id" = 1; "broker.id" = 1;
"node.id" = 1; "node.id" = 1;
"offsets.topic.replication.factor" = 1;
"transaction.state.log.replication.factor" = 1;
"transaction.state.log.min.isr" = 1;
"process.roles" = [ "process.roles" = [
"broker" "broker"
"controller" "controller"
@ -124,6 +125,11 @@
]); ]);
}; };
# https://devenv.sh/processes/
processes.distributed-portal.exec = config.scripts.distributed-portal.exec;
processes.distributed-backoffice.exec = config.scripts.distributed-backoffice.exec;
processes.distributed-ticketing.exec = config.scripts.distributed-ticketing.exec;
# https://devenv.sh/tests/ # https://devenv.sh/tests/
enterTest = '' enterTest = ''
echo "Running tests" echo "Running tests"

View file

@ -5,7 +5,7 @@
... ...
}: }:
let let
cfg = config.services.apache-kafka; cfg = config.services.kafka;
# The `javaProperties` generator takes care of various escaping rules and # The `javaProperties` generator takes care of various escaping rules and
# generation of the properties file, but we'll handle stringly conversion # generation of the properties file, but we'll handle stringly conversion
@ -56,7 +56,7 @@ let
''; '';
in in
{ {
options.services.apache-kafka = { options.services.kafka = {
enable = lib.mkEnableOption "Apache Kafka event streaming broker"; enable = lib.mkEnableOption "Apache Kafka event streaming broker";
settings = lib.mkOption { settings = lib.mkOption {
@ -100,7 +100,7 @@ in
See [listeners](https://kafka.apache.org/documentation/#brokerconfigs_listeners). See [listeners](https://kafka.apache.org/documentation/#brokerconfigs_listeners).
''; '';
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
default = [ "PLAINTEXT://localhost:29092" ]; default = [ "PLAINTEXT://localhost:9092" ];
}; };
}; };
}; };
@ -181,13 +181,13 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.apache-kafka.configFiles.serverProperties = generator "server.properties" stringlySettings; services.kafka.configFiles.serverProperties = generator "server.properties" stringlySettings;
scripts.kaf.exec = '' scripts.kaf.exec = ''
exec ${pkgs.kaf}/bin/kaf --config ${kafConfig} "$@" exec ${pkgs.kaf}/bin/kaf --config ${kafConfig} "$@"
''; '';
processes.apache-kafka = { processes.kafka = {
exec = "${startScript}"; exec = "${startScript}";
# process-compose = { # process-compose = {