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 is accessible via gRPC.

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 RPCs, 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

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 RPC, its arguments and error statuses, and the exact semantics of each data structure.
Python client reference DsServiceClient and DsServiceClientAsync: constructors, method names, the mapping from a gRPC status to an exception, and examples.
Server helper reference DsServiceServer, which starts a private ds-service process and stops it on close().
About the architecture The three pieces, 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, and why there is no fault tolerance.
About the static musl build Why the static image exists and why its Conan profile differs.

Developer documentation

Document What it covers
How to build the ds-service server Requirements, the Conan and CMake build, how to install and run the binary, and the static musl build.
Developer notes A map of the source, the build and the test suite, the generated code, and the invariants that span C++ and Python.

License

MIT. See LICENSE.

Metadata

Release files for ds-service-client 6.1.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 6.1.0
File Size Uploaded Provenance Actions
ds_service_client-6.1.0.tar.gz 21.8 kB Without provenance Details for ds_service_client-6.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ds-service-client 6.1.0
File Interpreter ABI Platform Actions
ds_service_client-6.1.0-py3-none-any.whl Python 3 none any Details for ds_service_client-6.1.0-py3-none-any.whl

Total release size: 44.5 kB

Release files / ds_service_client-6.1.0.tar.gz

Download URL ds_service_client-6.1.0.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
269ab56659041e9a3f2cc1b26cd7c6011c1cf5fbd807ff7fe3beee4ee19662eb
BLAKE2b-256 checksum
How to use checksums
3451aeef6f64e5f392c221f151700b9eedbd6fbb0ef77d90144c3799c7bdc12d
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-6.1.0-py3-none-any.whl

Download URL ds_service_client-6.1.0-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
931c0d88f168ce273cd5453181c9a86da95107218ff6ef72c4eab7180f56b9dc
BLAKE2b-256 checksum
How to use checksums
3ce44e0ef7c974af868da6f178672f946c3a698dd33b2d95c597e3862bef34db
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 6.1.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