Skip to content

Commit

Permalink
elasticmq: init
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Dec 10, 2023
1 parent 6de79a6 commit ca86468
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/elasticmq/.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -ex

devenv up &
DEVENV_PID=$!
export DEVENV_PID

function stop() {
pkill -P "$DEVENV_PID"
}

trap stop EXIT

timeout 60 bash -c 'until echo > /dev/tcp/localhost/9325; do sleep 0.5; done'

QUEUE_NAME=$(curl http://localhost:9325/statistics/queues -s | jq .[].name -r)

if [[ "$QUEUE_NAME" != "test-queue" ]]; then
echo "The queue is not created"
exit 1
fi
10 changes: 10 additions & 0 deletions examples/elasticmq/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ pkgs, ... }:

{
services.elasticmq.enable = true;
services.elasticmq.settings = ''
queues {
test-queue {}
}
'';
}
3 changes: 3 additions & 0 deletions examples/elasticmq/devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
28 changes: 28 additions & 0 deletions src/modules/services/elasticmq.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{ pkgs, lib, config, ... }:

let
cfg = config.services.elasticmq;
types = lib.types;
in
{
options.services.elasticmq = {
enable = lib.mkEnableOption "elasticmq-server";

package = lib.mkOption {
type = types.package;
description = "Which package of elasticmq-server-bin to use";
default = pkgs.elasticmq-server-bin;
defaultText = lib.literalExpression "pkgs.elasticmq-server-bin";
};

settings = lib.mkOption {
type = types.lines;
default = "";
description = "Configuration for elasticmq-server";
};
};

config = lib.mkIf cfg.enable {
processes.elasticmq-server.exec = "JAVA_TOOL_OPTIONS=\"-Dconfig.file=${pkgs.writeText "elasticmq-server.conf" cfg.settings}\" ${cfg.package}/bin/elasticmq-server";
};
}

0 comments on commit ca86468

Please sign in to comment.