nixos/foundationdb: show an example python script in the documentation

Signed-off-by: Austin Seipp <aseipp@pobox.com>

Changed files
+37 -2
nixos
modules
services
databases
+37 -2
nixos/modules/services/databases/foundationdb.xml
···
<para><emphasis>Maintainer:</emphasis> Austin Seipp</para>
-
<para><emphasis>Available version(s):</emphasis> 5.1.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
···
<programlisting>
services.foundationdb.enable = true;
-
services.foundationdb.package = pkgs.foundationdb51; # FoundationDB 5.1.x
</programlisting>
</para>
···
...
fdb>
</programlisting>
</para>
···
<para><emphasis>Maintainer:</emphasis> Austin Seipp</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
···
<programlisting>
services.foundationdb.enable = true;
+
services.foundationdb.package = pkgs.foundationdb52; # FoundationDB 5.2.x
</programlisting>
</para>
···
...
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>