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.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 6.0.0
File Size Uploaded Provenance Actions
ds_service_client-6.0.0.tar.gz 21.8 kB Without provenance Details for ds_service_client-6.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 44.5 kB

Release files / ds_service_client-6.0.0.tar.gz

Download URL ds_service_client-6.0.0.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6e3bdae958dbc74fe36bbf424c34229d3169a12236b26773fdc4c758823226e4
BLAKE2b-256 checksum
How to use checksums
4e1546e1f7795ff913728fd7174fac42106e27a236b93e8b6fd6a55749a5e5c8
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.0.0-py3-none-any.whl

Download URL ds_service_client-6.0.0-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a80e14035a22a24dc55a5a22368a89fd1d6b2d0a1e6de16819621473d6f6d86c
BLAKE2b-256 checksum
How to use checksums
bc9d1b3afe0c2dee16220ffa99331efae9fad39e04337c591bdc63c8a1e373b8
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.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