{"id":18300512,"url":"https://github.com/eclipse-zenoh/zenoh-backend-filesystem","last_synced_at":"2025-04-07T07:03:58.822Z","repository":{"id":41872915,"uuid":"317943393","full_name":"eclipse-zenoh/zenoh-backend-filesystem","owner":"eclipse-zenoh","description":"Backend and Storages for zenoh using the file system","archived":false,"fork":false,"pushed_at":"2025-04-07T00:24:09.000Z","size":1250,"stargazers_count":16,"open_issues_count":1,"forks_count":15,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-07T01:25:12.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eclipse-zenoh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-02T17:43:00.000Z","updated_at":"2025-04-04T15:03:41.000Z","dependencies_parsed_at":"2023-10-04T15:00:47.718Z","dependency_job_id":"f359f510-e74b-44be-a82d-614cd7a8c00a","html_url":"https://github.com/eclipse-zenoh/zenoh-backend-filesystem","commit_stats":{"total_commits":159,"total_committers":9,"mean_commits":"17.666666666666668","dds":0.4528301886792453,"last_synced_commit":"318ce4dcf2e9c1f7e0f5a385800e126f863e2462"},"previous_names":[],"tags_count":104,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-zenoh%2Fzenoh-backend-filesystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-zenoh%2Fzenoh-backend-filesystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-zenoh%2Fzenoh-backend-filesystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-zenoh%2Fzenoh-backend-filesystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eclipse-zenoh","download_url":"https://codeload.github.com/eclipse-zenoh/zenoh-backend-filesystem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247577000,"owners_count":20961072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T15:12:42.085Z","updated_at":"2025-04-07T07:03:58.801Z","avatar_url":"https://github.com/eclipse-zenoh.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/eclipse-zenoh/zenoh/main/zenoh-dragon.png\" height=\"150\"\u003e\n\n[![CI](https://github.com/eclipse-zenoh/zenoh-backend-filesystem/workflows/CI/badge.svg)](https://github.com/eclipse-zenoh/zenoh-backend-filesystem/actions?query=workflow%3A%22CI%22)\n[![Discussion](https://img.shields.io/badge/discussion-on%20github-blue)](https://github.com/eclipse-zenoh/roadmap/discussions)\n[![Discord](https://img.shields.io/badge/chat-on%20discord-blue)](https://discord.gg/2GJ958VuHs)\n[![License](https://img.shields.io/badge/License-EPL%202.0-blue)](https://choosealicense.com/licenses/epl-2.0/)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n# Eclipse Zenoh\n\nThe Eclipse Zenoh: Zero Overhead Pub/sub, Store/Query and Compute.\n\nZenoh (pronounce _/zeno/_) unifies data in motion, data at rest and computations. It carefully blends traditional pub/sub with geo-distributed storages, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.\n\nCheck the website [zenoh.io](http://zenoh.io) and the [roadmap](https://github.com/eclipse-zenoh/roadmap) for more detailed information.\n\n-------------------------------\n\n# File system backend\n\nIn zenoh a backend is a storage technology (such as DBMS, time-series database, file system...) alowing to store the\nkeys/values publications made via zenoh and return them on queries.\nSee the [zenoh documentation](https://zenoh.io/docs/manual/abstractions/#storage) for more details.\n\nThis backend relies on the host's file system to implement the storages.\nIts library name (without OS specific prefix and extension) that zenoh will rely on to find it and load it is **`zenoh_backend_fs`**.\n\n:point_right: **Install latest release:** see [below](#how-to-install-it)\n\n:point_right: **Build \"main\" branch:** see [below](#how-to-build-it)\n\n-------------------------------\n\n## **Examples of usage**\n\nPrerequisites:\n\n- You have a zenoh router (`zenohd`) installed, and the `zenoh_backend_fs` library file is available in `~/.zenoh/lib`.\n- Declare the `ZENOH_BACKEND_FS_ROOT` environment variable to the directory where you want the files to be stored (or exposed from).\n  If you don't declare it, the `~/.zenoh/zenoh_backend_fs` directory will be used.\n\nYou can setup storages either at zenoh router startup via a configuration file, either at runtime via the zenoh admin space, using for instance the REST API.\n\n### **Setup via a JSON5 configuration file**\n\n- Create a `zenoh.json5` configuration file containing:\n\n  ```json5\n  {\n    plugins: {\n      // configuration of \"storage-manager\" plugin:\n      storage_manager: {\n        volumes: {\n          // configuration of a \"fs\" volume (the \"zenoh_backend_fs\" backend library will be loaded at startup)\n          fs: {},\n        },\n        storages: {\n          // configuration of a \"demo\" storage using the \"fs\" volume\n          demo: {\n            // the key expression this storage will subscribes to\n            key_expr: \"demo/example/**\",\n            // this prefix will be stripped from the received key when converting to file path\n            // this argument is optional.\n            strip_prefix: \"demo/example\",\n            volume: {\n              id: \"fs\",\n              // the key/values will be stored as files within this directory (relative to ${ZENOH_BACKEND_FS_ROOT})\n              dir: \"example\"\n            }\n          }\n        }\n      },\n      // Optionally, add the REST plugin\n      rest: { http_port: 8000 }\n    }\n  }\n  ```\n\n- Run the zenoh router with:  \n  `zenohd -c zenoh.json5`\n\n### **Setup at runtime via `curl` commands on the admin space**\n\n- Run the zenoh router, with write permissions to its admin space and with the REST plugin:  \n  `zenohd --adminspace-permissions=rw --rest-http-port=8000`\n- Add the \"fs\" backend (the \"zenoh_backend_fs\" library will be loaded):  \n  `curl -X PUT -H 'content-type:application/json' -d '{}' http://localhost:8000/@/router/local/config/plugins/storage_manager/volumes/fs`\n- Add the \"demo\" storage using the \"fs\" backend:  \n  `curl -X PUT -H 'content-type:application/json' -d '{key_expr:\"demo/example/**\",strip_prefix:\"demo/example\", volume: {id: \"fs\", dir:\"example\"}}' http://localhost:8000/@/router/local/config/plugins/storage_manager/storages/demo`\n\n### **Tests using the REST API**\n\nUsing `curl` to publish and query keys/values, you can:\n\n```bash\n# Put values that will be stored under ${ZENOH_BACKEND_FS_ROOT}/example\ncurl -X PUT -d \"TEST-1\" http://localhost:8000/demo/example/test-1\ncurl -X PUT -d \"B\" http://localhost:8000/demo/example/a/b\n\n# Retrive the values\ncurl http://localhost:8000/demo/example/**\n```\n\n\u003c!-- TODO: after release of eclipse/zenoh:0.6.0 update wrt. conf file and uncomment this:\n\n### **Usage with `eclipse/zenoh` Docker image**\nAlternatively, you can test the zenoh router in a Docker container:\n - Download the [docker-compose.yml](https://github.com/eclipse-zenoh/zenoh-backend-filesystem/blob/main/docker-compose.yml) file\n - In the same directory, create the `./zenoh_docker/lib` sub-directories and place the `libzenoh_backend_fs.so` library\n   for `x86_64-unknown-linux-musl` target within.\n - Also create a `./zenoh_filesystem/test` directory that will be used for the storage.\n - Start the containers running\n   ```bash\n   docker-compose up -d\n   ```\n - Run the `curl` commands above, and explore the resulting file in `./zenoh_filesystem/test`\n--\u003e\n\n-------------------------------\n\n## Configuration\n\n### Extra configuration for filesystem-backed volumes\n\nVolumes using the `fs` backend don't need any extra configuration at the volume level. Any volume can use the `fs` backend by specifying the value `\"fs\"` for the `backend` configuration key. A volume named `fs` will automatically be backed by the `fs` backend if no other backend is specified.\n\n-------------------------------\n\n### Storage-level configuration for filesystem-backed volumes\n\nStorages relying on a `fs` backed volume must/can specify additional configuration specific to that volume, as shown in the example [above](#setup-via-a-json5-configuration-file):\n\n- `dir` (**required**, string) : The directory that will be used to store data.\n\n- `read_only` (optional, boolean) : the storage will only answer to GET queries. It will not accept any PUT or DELETE message, and won't write any file. `false` by default.\n\n- `on_closure` (optional, string) : the strategy to use when the Storage is removed. There are 2 options:\n  - `\"do_nothing\"`: the storage's directory remains untouched (this is the default behaviour)\n  - `\"delete_all\"`: the storage's directory is deleted with all its content.\n\n- `follow_links` (optional, boolean) : If set to `true` the storage will follow the symbolic links. The default value is `false`.\n\n- `keep_mime_types` (optional, boolean) : When replying to a GET query with a file for which the zenoh encoding is not known, the storage guess its mime-type according to the file extension. If the mime-type doesn't correspond to a supported zenoh encoding, this option will drive the returned value:\n  - `true` (default value): a [Custom value](https://docs.rs/zenoh/latest/zenoh/enum.Value.html#variant.Custom)\n    is returned with the description set to the mime-type.\n  - `false`: a [Raw value](https://docs.rs/zenoh/latest/zenoh/enum.Value.html#variant.Raw) with\n    APP_OCTET_STREAM encoding is returned.\n\n-------------------------------\n\n## **Behaviour of the backend**\n\n### Mapping to file system\n\nEach **storage** will map to a directory with path: `${ZENOH_BACKEND_FS_ROOT}/\u003cdir\u003e`, where:\n\n- `${ZENOH_BACKEND_FS_ROOT}` is an environment variable that could be specified before zenoh router startup.\n   If this variable is not specified `${ZENOH_HOME}/zenoh_backend_fs` will be used\n   (where the default value of `${ZENOH_HOME}` is `~/.zenoh`).\n- `\u003cdir\u003e` is the `\"dir\"` property specified at storage creation.\nch zenoh **key/value** put into the storage will map to a file within the storage's directory where:\n- the file path will be `${ZENOH_BACKEND_FS_ROOT}/\u003cdir\u003e/\u003crelative_zenoh_key\u003e`, where `\u003crelative_zenoh_key\u003e`\n  will be the zenoh key, stripped from the `\"strip_prefix\"` property specified at storage creation.\n- the content of the file will be the value written as a RawValue. I.e. the same bytes buffer that has been\n  transported by zenoh. For UTF-8 compatible formats (StringUTF8, JSon, Integer, Float...) it means the file\n  will be readable as a text format.\n- the encoding and the timestamp of the key/value will be stored in a RocksDB database stored in the storage directory.\n\n### Behaviour on deletion\n\nOn deletion of a key, the corresponding file is removed. An entry with deletion timestamp is inserted in the\nRocksDB database (to avoid re-insertion of points with an older timestamp in case of un-ordered messages).  \nAt regular interval, a task cleans-up the RocksDB database from entries with old timestamps that don't have a\ncorresponding existing file.\n\n### Behaviour on GET\n\nOn GET operations, the storage searches for matching and existing files, and return their raw content as a reply.\nFor each, the encoding and timestamp are retrieved from the RocksDB database. But if no entry is found in the\ndatabase for a file (e.g. for files created without zenoh), the encoding is deduced from the file's extension\n(using [mime_guess](https://crates.io/crates/mime_guess)), and the timestamp is deduced from the file's\nmodification time.\n\n-------------------------------\n\n## How to install it\n\nTo install the latest release of this backend library, you can do as follows:\n\n### Manual installation (all platforms)\n\nAll release packages can be downloaded from:  \n\n- [https://download.eclipse.org/zenoh/zenoh-backend-filesystem/latest/](https://download.eclipse.org/zenoh/zenoh-backend-filesystem/latest/)\n\nEach subdirectory has the name of the Rust target. See the platforms each target corresponds to on [https://doc.rust-lang.org/stable/rustc/platform-support.html](https://doc.rust-lang.org/stable/rustc/platform-support.html)\n\nChoose your platform and download the `.zip` file.\nUnzip it in the same directory than `zenohd` or to any directory where it can find the backend library (e.g. /usr/lib or ~/.zenoh/lib)\n\n### Linux Debian\n\nAdd Eclipse Zenoh private repository to the sources list, and install the `zenoh-backend-filesystem` package:\n\n```bash\necho \"deb [trusted=yes] https://download.eclipse.org/zenoh/debian-repo/ /\" | sudo tee -a /etc/apt/sources.list.d/zenoh.list \u003e /dev/null\nsudo apt update\nsudo apt install zenoh-backend-filesystem\n```\n\n-------------------------------\n\n## How to build it\n\n\u003e :warning: **WARNING** :warning: : Zenoh and its ecosystem are under active development. When you build from git, make sure you also build from git any other Zenoh repository you plan to use (e.g. binding, plugin, backend, etc.). It may happen that some changes in git are not compatible with the most recent packaged Zenoh release (e.g. deb, docker, pip). We put particular effort in mantaining compatibility between the various git repositories in the Zenoh project.\n\nAt first, install [Clang](https://clang.llvm.org/) and [Cargo and Rust](https://doc.rust-lang.org/cargo/getting-started/installation.html). If you already have the Rust toolchain installed, make sure it is up-to-date with:\n\n```bash\nrustup update\n```\n\n\u003e :warning: **WARNING** :warning: : As Rust doesn't have a stable ABI, the backend library should be\nbuilt with the exact same Rust version than `zenohd`, and using for `zenoh` dependency the same version (or commit number) than 'zenohd'.\nOtherwise, incompatibilities in memory mapping of shared types between `zenohd` and the library can lead to a `\"SIGSEV\"` crash.\n\nTo know the Rust version you're `zenohd` has been built with, use the `--version` option.  \nExample:\n\n```bash\n$ zenohd --version\nThe zenoh router v0.6.0-beta.1 built with rustc 1.64.0 (a55dd71d5 2022-09-19)\n```\n\nHere, `zenohd` has been built with the rustc version `1.64.0`.  \nInstall and use this toolchain with the following command:\n\n```bash\nrustup default 1.64.0\n```\n\nAnd `zenohd` version corresponds to an un-released commit with id `1f20c86`. Update the `zenoh` dependency in Cargo.lock with this command:\n\n```bash\ncargo update -p zenoh --precise 1f20c86\n```\n\nThen build the backend with:\n\n```bash\ncargo build --release --all-targets\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipse-zenoh%2Fzenoh-backend-filesystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feclipse-zenoh%2Fzenoh-backend-filesystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipse-zenoh%2Fzenoh-backend-filesystem/lists"}