summary refs log tree commit diff
path: root/nixos/modules/services/databases
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2018-08-04 16:56:05 -0500
committerAustin Seipp <aseipp@pobox.com>2018-08-04 16:56:16 -0500
commitf42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2 (patch)
tree4632535bf506108e7e2f91e92ca1dab1e96a8521 /nixos/modules/services/databases
parentaa79ae0c6425fa673401e845493c99e717ad4a69 (diff)
downloadnixlib-f42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2.tar
nixlib-f42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2.tar.gz
nixlib-f42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2.tar.bz2
nixlib-f42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2.tar.lz
nixlib-f42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2.tar.xz
nixlib-f42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2.tar.zst
nixlib-f42f0a1c48de7df84b3220bd72ecd3eb2b85e5a2.zip
nixos/foundationdb: show an example python script in the documentation
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'nixos/modules/services/databases')
-rw-r--r--nixos/modules/services/databases/foundationdb.xml39
1 files changed, 37 insertions, 2 deletions
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 @@
 
 <para><emphasis>Maintainer:</emphasis> Austin Seipp</para>
 
-<para><emphasis>Available version(s):</emphasis> 5.1.x</para>
+<para><emphasis>Available version(s):</emphasis> 5.1.x, 5.2.x, 6.0.x</para>
 
 <para>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
 
 <programlisting>
 services.foundationdb.enable = true;
-services.foundationdb.package = pkgs.foundationdb51; # FoundationDB 5.1.x
+services.foundationdb.package = pkgs.foundationdb52; # FoundationDB 5.2.x
 </programlisting>
 </para>
 
@@ -70,6 +70,41 @@ fdb>
 </programlisting>
 </para>
 
+<para>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 <command>nix-shell</command> shebang
+support to automatically supply the necessary Python modules).
+
+<programlisting>
+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>
+</programlisting>
+</para>
+
 <para>FoundationDB is run under the <command>foundationdb</command> user and
 group by default, but this may be changed in the NixOS configuration. The
 systemd unit <command>foundationdb.service</command> controls the