From f42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Sat, 4 Aug 2018 16:56:05 -0500 Subject: nixos/foundationdb: show an example python script in the documentation Signed-off-by: Austin Seipp --- nixos/modules/services/databases/foundationdb.xml | 39 +++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'nixos/modules/services/databases') diff --git a/nixos/modules/services/databases/foundationdb.xml b/nixos/modules/services/databases/foundationdb.xml index 1f60470aa3f8..0b305c3fdf18 100644 --- a/nixos/modules/services/databases/foundationdb.xml +++ b/nixos/modules/services/databases/foundationdb.xml @@ -12,7 +12,7 @@ Maintainer: Austin Seipp -Available version(s): 5.1.x +Available version(s): 5.1.x, 5.2.x, 6.0.x FoundationDB (or "FDB") is a distributed, open source, high performance, transactional key-value store. It can store petabytes of data and deliver @@ -26,7 +26,7 @@ exceptional performance while maintaining consistency and ACID semantics services.foundationdb.enable = true; -services.foundationdb.package = pkgs.foundationdb51; # FoundationDB 5.1.x +services.foundationdb.package = pkgs.foundationdb52; # FoundationDB 5.2.x @@ -70,6 +70,41 @@ fdb> +You can also now write programs using the available client libraries. +For example, the following Python program can be run in order to grab the cluster status, +as a quick example. (This example uses nix-shell shebang +support to automatically supply the necessary Python modules). + + +a@link> cat fdb-status.py +#! /usr/bin/env nix-shell +#! nix-shell -i python -p python pythonPackages.foundationdb52 + +from __future__ import print_function + +import fdb +import json + +def main(): + fdb.api_version(520) + db = fdb.open() + + @fdb.transactional + def get_status(tr): + return str(tr['\xff\xff/status/json']) + + obj = json.loads(get_status(db)) + print('FoundationDB available: %s' % obj['client']['database_status']['available']) + +if __name__ == "__main__": + main() +a@link> chmod +x fdb-status.py +a@link> ./fdb-status.py +FoundationDB available: True +a@link> + + + FoundationDB is run under the foundationdb user and group by default, but this may be changed in the NixOS configuration. The systemd unit foundationdb.service controls the -- cgit 1.4.1