Skip to content

Commit

Permalink
feat(tika): init
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol authored and shivaraj-bh committed Jul 15, 2024
1 parent e5c2e7c commit f041f87
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/tika.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Tika

[Tika](https://tika.apache.org/) is a content analysis toolkit as a service that can detect and extract metadata and
text from over a thousand different file types.

## Getting Started

```nix
# In `perSystem.process-compose.<name>`
{
services.tika."instance-name" = {
enable = true;
port = 9998;
host = "127.0.0.1";
};
}
```
1 change: 1 addition & 0 deletions nix/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ in
./tempo.nix
./weaviate.nix
./searxng.nix
./tika.nix
];
}
55 changes: 55 additions & 0 deletions nix/services/tika.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{ pkgs, lib, name, config, ... }:
let
inherit (lib) types literalExpression;
in
{
options = {
package = lib.mkPackageOption pkgs "tika" { };

host = lib.mkOption {
description = "Apache Tika bind address";
default = "127.0.0.1";
example = "0.0.0.0";
type = types.str;
};

port = lib.mkOption {
description = "Apache Tika port to listen on";
default = 9998;
type = types.port;
};

configFile = lib.mkOption {
type = types.nullOr types.path;
default = null;
description = ''
The Apache Tika configuration (XML) file to use.
'';
example = literalExpression "./tika/tika-config.xml";
};
};

config = {
outputs = {
settings = {
processes = {
"${name}" = {
command = "${lib.getExe config.package} --host ${config.host} --port ${toString config.port} ${lib.optionalString (config.configFile != null) "--config ${config.configFile}"}";
availability.restart = "on_failure";
readiness_probe = {
http_get = {
host = config.host;
port = config.port;
};
initial_delay_seconds = 2;
period_seconds = 10;
timeout_seconds = 4;
success_threshold = 1;
failure_threshold = 5;
};
};
};
};
};
};
}
17 changes: 17 additions & 0 deletions nix/services/tika_test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ pkgs, ... }:
{
services.tika."tika1" = {
enable = true;
};

settings.processes.test = {
command = pkgs.writeShellApplication {
runtimeInputs = [ pkgs.curl ];
text = ''
curl http://127.0.0.1:9998
'';
name = "tika-test";
};
depends_on."tika1".condition = "process_healthy";
};
}
1 change: 1 addition & 0 deletions test/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"${inputs.services-flake}/nix/services/pgadmin_test.nix"
"${inputs.services-flake}/nix/services/tempo_test.nix"
"${inputs.services-flake}/nix/services/weaviate_test.nix"
"${inputs.services-flake}/nix/services/tika_test.nix"
]));
};
};
Expand Down

0 comments on commit f041f87

Please sign in to comment.