Skip to main content

ds-service: An in-memory data structure server

Futuristic banner image.

ds-service is a small, in-memory data structure server that clients reach over the network, through gRPC today.

ds-service runs a single server process that holds shared state in memory and lets many distributed clients and workers coordinate using it. Use it when several processes must coordinate, on one machine or across a cluster. It covers four cases:

  • The processes hand work to each other.
  • The processes share intermediate results.
  • The processes take turns on a resource.
  • The processes agree on a number.

The state only has to live as long as the run does.

Presently, it provides six data structures: a key-value store, a task queue, a journal store, a time series store, named mutexes, and counters. Each is a separate key space with its own set of operations, described in the data structure reference.

Installation

The server is a single statically linked binary. Download the latest release, make it executable, and put it somewhere on your PATH:

curl -sSL -o ds-service \
    https://github.com/parantapa/ds-service/releases/latest/download/ds-service
chmod +x ds-service

It links against musl with no dynamic dependencies, so it runs on any x86-64 Linux host.

The Python client needs Python 3.12 or newer. It comes from PyPI:

pip install ds-service-client

PyPI has a prebuilt wheel for x86-64 Linux. On any other platform, pip builds the client from source, which needs a C++23 toolchain and takes several minutes.

The C++ client comes from source only. See the C++ client reference.

To build the server from source instead, see how to build the server.

Usage

Start a server:

ds-service --address 127.0.0.1:5051

Then, from any process that can reach it:

from ds_service_client import DsServiceClient

with DsServiceClient("127.0.0.1:5051") as client:
    client.map_set("greeting", b"hello")
    assert client.map_get("greeting") == b"hello"

    client.task_add("job-1", parent_task_ids=[], queue="work", priority=1.0, function=b"greet", input=b"world")

    task = client.task_get(worker_id="worker-a", queue="work")
    client.task_done(task.task_id, worker_id="worker-a", output=b"hello world")

    assert client.task_get_output("job-1") == b"hello world"

Documentation

User documentation

Document What it covers
Run your first tasks through ds-service Start a server, store a value, and take a task from Ready to Finished. Start here.
How to write a worker The claim-work-report loop, mutexes around shared resources, progress reporting, and the asyncio variant.
Data structure reference Every operation, its arguments and error codes, and the exact semantics of each data structure.
Python client reference DsServiceClient and DsServiceClientAsync: constructors, method names, return types, the mapping from a failure to an exception, threads and processes, and examples.
C++ client reference ds::connect and ds::Client: headers, options, methods, errors, and an example.
Server helper reference DsServiceServer, which starts a private ds-service process and stops it on close().
About the architecture The pieces and the transport boundary between them, why the server does not persist state, one lock per structure, and why there are two Python clients.
About the task queue Task ownership, what canceling does and does not do, how failure and cancellation pass to dependents, why there is no fault tolerance, and why the server reclaims nothing.

Developer documentation

Document What it covers
How to build the ds-service server Requirements, the Conan and CMake build, the options that select the server, the C++ client and the Python module, the tests, how to install and run the binary, and the static musl build.
About the static musl build Why the static image exists and why its Conan profile differs.
Developer notes A map of the source, the build and the test suites, the generated code, the transport boundary, and the invariants that span C++ and Python.

License

MIT. See LICENSE.

Metadata

Release files for ds-service-client 7.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ds-service-client 7.0.0
File Size Uploaded Provenance Actions
ds_service_client-7.0.0.tar.gz 66.4 kB Without provenance Details for ds_service_client-7.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ds-service-client 7.0.0
File Interpreter ABI Platform Actions
ds_service_client-7.0.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for ds_service_client-7.0.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Total release size: 4.9 MB

Release files / ds_service_client-7.0.0.tar.gz

Download URL ds_service_client-7.0.0.tar.gz
Size 66.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d6a9e05f0905e268b928cc1014b75a637fd8202b7068a3e0324e8f421af6fc88
BLAKE2b-256 checksum
How to use checksums
1d89b97c4af107f197dac8845b5659f6e7f276c5d465a38848a6f85f2d036618
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / ds_service_client-7.0.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL ds_service_client-7.0.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.8 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
652451186c454c69e41518b77726b002fc0347a852bddf6c08a84cbe4a7dbbb4
BLAKE2b-256 checksum
How to use checksums
e44f8e15f30db494aee20ac3b713ff57f1bbb9f6bc0de70f56f47be268172588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for ds-service-client 7.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page