-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readme updated: daemon run instructions added, obsolete info removed #67
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
mode: 'router', | ||
plugins_loading: { | ||
enabled: true, | ||
search_dirs: ['./target/debug', '~/.zenoh/lib', '/usr/lib'] | ||
}, | ||
plugins: { | ||
remote_api: { | ||
"__config__": "zenoh-plugin-remote-api/EXAMPLE_CONFIG.json5" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,104 +1,166 @@ | ||||||||||||||||||||||
<img src="https://raw.githubusercontent.com/eclipse-zenoh/zenoh/master/zenoh-dragon.png" height="150"> | ||||||||||||||||||||||
|
||||||||||||||||||||||
> :warning: **This is a WIP Active development project**: Experiment with with it, but it is **Not** production Ready! | ||||||||||||||||||||||
> :warning: **This is a WIP Active development project**: Experiment with it, but it is **Not** production ready! | ||||||||||||||||||||||
|
||||||||||||||||||||||
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue)](https://discord.gg/2GJ958VuHs) | ||||||||||||||||||||||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||||||||||||||||||||||
|
||||||||||||||||||||||
# Eclipse Zenoh Typescript / Javascript API | ||||||||||||||||||||||
|
||||||||||||||||||||||
The Eclipse Zenoh: Zero Overhead Pub/sub, Store/Query and Compute. | ||||||||||||||||||||||
The Eclipse Zenoh: Zero Overhead Pub/sub, Store/Query, and Compute. | ||||||||||||||||||||||
|
||||||||||||||||||||||
Zenoh (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. | ||||||||||||||||||||||
Zenoh (pronounced _/zeno/_) unifies data in motion, data at rest, and computations. It carefully blends traditional pub/sub with | ||||||||||||||||||||||
geo-distributed storage, queries, and computations, while retaining a level of time and space efficiency that is well beyond any | ||||||||||||||||||||||
of the mainstream stacks. | ||||||||||||||||||||||
|
||||||||||||||||||||||
Check the website [zenoh.io](http://zenoh.io) and the [roadmap](https://github.com/eclipse-zenoh/roadmap) for more detailed information. | ||||||||||||||||||||||
|
||||||||||||||||||||||
--- | ||||||||||||||||||||||
|
||||||||||||||||||||||
# Typescript/Javascript API | ||||||||||||||||||||||
## Typescript/Javascript API | ||||||||||||||||||||||
|
||||||||||||||||||||||
This repository provides a Typscript / Javascript binding through the use of the `remote-api-plugin` in this repo. | ||||||||||||||||||||||
The long term plan is to use zenoh [Zenoh written in Rust](https://github.com/eclipse-zenoh/zenoh) to target WASM. | ||||||||||||||||||||||
In its current state, it is not possible to compile Zenoh (Rust) to target WASM, and will need to undergo a fair amount of refactoring before that can happen. | ||||||||||||||||||||||
This repository provides a Typescript / Javascript binding through the use of the `remote-api-plugin` in this repo. | ||||||||||||||||||||||
The long-term plan is to use zenoh [Zenoh written in Rust](https://github.com/eclipse-zenoh/zenoh) to target WASM. | ||||||||||||||||||||||
In its current state, it is not possible to compile Zenoh (Rust) to target WASM, and it will need to undergo a fair | ||||||||||||||||||||||
amount of refactoring before that can happen. | ||||||||||||||||||||||
|
||||||||||||||||||||||
Docs can be accessed at [Docs Link](https://eclipse-zenoh.github.io/zenoh-ts/) | ||||||||||||||||||||||
|
||||||||||||||||||||||
--- | ||||||||||||||||||||||
|
||||||||||||||||||||||
## How to build it | ||||||||||||||||||||||
## How to build and run it | ||||||||||||||||||||||
|
||||||||||||||||||||||
> :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 maintaining compatibility between the various git repositories in the Zenoh project. | ||||||||||||||||||||||
> :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 into maintaining | ||||||||||||||||||||||
compatibility between the various git repositories in the Zenoh project. | ||||||||||||||||||||||
|
||||||||||||||||||||||
## Building the Typescript project | ||||||||||||||||||||||
### Executing the `zenohd` with `zenoh-plugin-remote-api` plugin | ||||||||||||||||||||||
|
||||||||||||||||||||||
1. Make sure that the following utilities are available on your platform. | ||||||||||||||||||||||
- [NPM](https://www.npmjs.com/package/npm) | ||||||||||||||||||||||
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable) | ||||||||||||||||||||||
- [Typescript](https://www.typescriptlang.org/download/) | ||||||||||||||||||||||
The `zenohd` router and its plugins should be built with the same Zenoh sources, the same version of the Rust compiler, and with the | ||||||||||||||||||||||
same set of features. This requirement exists because the router and plugins share common Rust structures, and Rust doesn't guarantee | ||||||||||||||||||||||
ABI compatibility of the memory representation of these structures. | ||||||||||||||||||||||
|
||||||||||||||||||||||
2. Navigate to the directory `zenoh-ts` | ||||||||||||||||||||||
Therefore one of these methods is recommended to ensure that plugin and router are compatible: | ||||||||||||||||||||||
|
||||||||||||||||||||||
3. Run the commands: | ||||||||||||||||||||||
1. Install the latest release of `zenohd` and `zenoh-plugin-remote-api` | ||||||||||||||||||||||
|
||||||||||||||||||||||
```bash | ||||||||||||||||||||||
yarn install | ||||||||||||||||||||||
# | ||||||||||||||||||||||
yarn run build | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
Ubuntu: | ||||||||||||||||||||||
|
||||||||||||||||||||||
```sh | ||||||||||||||||||||||
echo "deb [trusted=yes] https://download.eclipse.org/zenoh/debian-repo/ /" | sudo tee -a /etc/apt/sources.list.d/zenoh.list > /dev/null | ||||||||||||||||||||||
sudo apt update | ||||||||||||||||||||||
sudo apt install zenohd | ||||||||||||||||||||||
sudo apt install zenoh-plugin-remote-api | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
Mac-OS: | ||||||||||||||||||||||
|
||||||||||||||||||||||
```sh | ||||||||||||||||||||||
brew tap eclipse-zenoh/homebrew-zenoh | ||||||||||||||||||||||
brew install zenoh | ||||||||||||||||||||||
brew install zenoh-plugin-remote-api | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
## Building the Rust Plugin | ||||||||||||||||||||||
Run the installed zenoh router with example config | ||||||||||||||||||||||
|
||||||||||||||||||||||
1. Make sure that the following utilities are available on your platform. | ||||||||||||||||||||||
- [Cargo + Rust Compiler](https://rustup.rs/) | ||||||||||||||||||||||
```sh | ||||||||||||||||||||||
zenohd --config EXAMPLE_CONFIG.json5 | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
Expected output is like: | ||||||||||||||||||||||
|
||||||||||||||||||||||
2. Navigate to `zenoh-plugin-remote-api` | ||||||||||||||||||||||
```txt | ||||||||||||||||||||||
zenohd: zenohd v1.0.3 built with rustc 1.75.0 (82e1608df 2023-12-21) | ||||||||||||||||||||||
zenoh::net::runtime: Using ZID: f7bc54e0941036422ec08ebac6fbdb40 | ||||||||||||||||||||||
zenoh::api::loader: Loading plugin "remote_api" | ||||||||||||||||||||||
zenoh::api::loader: Starting plugin "remote_api" | ||||||||||||||||||||||
zenoh::api::loader: Successfully started plugin remote_api from "/usr/lib/libzenoh_plugin_remote_api.so" | ||||||||||||||||||||||
zenoh::api::loader: Finished loading plugins | ||||||||||||||||||||||
zenoh::net::runtime::orchestrator: Zenoh can be reached at: tcp/.... | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
3. Run `cargo build` | ||||||||||||||||||||||
1. Build both the plugin and the router from the sources: | ||||||||||||||||||||||
|
||||||||||||||||||||||
## **Examples of usage** | ||||||||||||||||||||||
Build the plugin `zenoh-plugin-remote-api` | ||||||||||||||||||||||
|
||||||||||||||||||||||
### Running the Rust Plugin | ||||||||||||||||||||||
```sh | ||||||||||||||||||||||
cargo build | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
Prerequisites: | ||||||||||||||||||||||
- You have a zenoh router (`zenohd`) installed, and the `zenoh_plugin_remote_api` library file is available in `~/.zenoh/lib`. | ||||||||||||||||||||||
Build and run the zenohd from the same sources which were used for the plugin. | ||||||||||||||||||||||
The zenohd dependency is specified in the `[workspace.metadata.bin]` section in Cargo.toml which is processed by the 3rd party tool [cargo-run-bin](https://crates.io/crates/cargo-run-bin). | ||||||||||||||||||||||
|
||||||||||||||||||||||
### **Setup via a JSON5 configuration file** | ||||||||||||||||||||||
```sh | ||||||||||||||||||||||
cargo install cargo-run-bin | ||||||||||||||||||||||
cargo bin zenohd --config EXAMPLE_CONFIG.json5 | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
- Create a `zenoh.json5` configuration file containing for example: | ||||||||||||||||||||||
```json5 | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
plugins: { | ||||||||||||||||||||||
// configuration of "storage_manager" plugin: | ||||||||||||||||||||||
remote_api: { | ||||||||||||||||||||||
"websocket_port": "10000", | ||||||||||||||||||||||
// secure_websocket configuration is optional | ||||||||||||||||||||||
"secure_websocket": { | ||||||||||||||||||||||
"certificate_path" : "/path/to/certificate", | ||||||||||||||||||||||
"private_key_path" : "/path/to/private_key" | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
// Optionally, add the REST plugin | ||||||||||||||||||||||
rest: { http_port: 8000 } | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
- Run the zenoh router with: | ||||||||||||||||||||||
`zenohd -c zenoh.json5` | ||||||||||||||||||||||
Expected output is like: | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||||||||||||||||||||||
|
||||||||||||||||||||||
## Adding Typescript to your application | ||||||||||||||||||||||
```txt | ||||||||||||||||||||||
zenohd: zenohd vc764bf9b built with rustc 1.75.0 (82e1608df 2023-12-21) | ||||||||||||||||||||||
zenoh::net::runtime: Using ZID: bb3fb16628f57e92f92accf2f5c81511 | ||||||||||||||||||||||
zenoh::api::loader: Loading plugin "remote_api" | ||||||||||||||||||||||
zenoh::api::loader: Starting plugin "remote_api" | ||||||||||||||||||||||
zenoh::api::loader: Successfully started plugin remote_api from "./target/debug\\zenoh_plugin_remote_api.dll" | ||||||||||||||||||||||
zenoh::api::loader: Finished loading plugins | ||||||||||||||||||||||
zenoh::net::runtime::orchestrator: Zenoh can be reached at: tcp/... | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
The TypeScript library can be install from the command line: | ||||||||||||||||||||||
### Building the library | ||||||||||||||||||||||
|
||||||||||||||||||||||
`npm install @eclipse-zenoh/[email protected]` | ||||||||||||||||||||||
1. Make sure that the following utilities are available on your platform. | ||||||||||||||||||||||
|
||||||||||||||||||||||
Or added via package.json | ||||||||||||||||||||||
- [NPM](https://www.npmjs.com/package/npm) | ||||||||||||||||||||||
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable) | ||||||||||||||||||||||
- [Typescript](https://www.typescriptlang.org/download/) | ||||||||||||||||||||||
|
||||||||||||||||||||||
`"@eclipse-zenoh/zenoh-ts": "0.0.8" ` | ||||||||||||||||||||||
2. Navigate to the directory `zenoh-ts` | ||||||||||||||||||||||
|
||||||||||||||||||||||
1. Run the commands: | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed - it all shoud be 1. 1. 1. - md does numbering automatically |
||||||||||||||||||||||
|
||||||||||||||||||||||
```sh | ||||||||||||||||||||||
yarn install | ||||||||||||||||||||||
yarn run build | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
Note: In order to add this library to your project you must log into the github npm repository, | ||||||||||||||||||||||
please refer to this link for more information [Accessing github NPM](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token) | ||||||||||||||||||||||
### Build and run the command line examples | ||||||||||||||||||||||
|
||||||||||||||||||||||
This library is currently compatible with browsers, but not with NodeJS due to websocket library limitations. | ||||||||||||||||||||||
To run the command line examples use the javascript runtime [deno](https://deno.com/) which is expected to be consistent with the browser. | ||||||||||||||||||||||
|
||||||||||||||||||||||
[zenoh]: https://github.com/eclipse-zenoh/zenoh | ||||||||||||||||||||||
1. Install [deno](https://deno.com/) | ||||||||||||||||||||||
1. Navigate to the `zenoh-ts/examples/deno` directory | ||||||||||||||||||||||
1. Install the `zenoh-ts` library by running `yarn install` | ||||||||||||||||||||||
1. Run zenohd with the remote_api plugin, configured to websocket port 10000, as described above | ||||||||||||||||||||||
1. Run the examples by running `yarn example <PATH TO EXAMPLE>`, i.e. `yarn example src/z_sub.ts` | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing. Though yes, I agree that if user read this with e.g. vim, better to make correct numberring. Fixed |
||||||||||||||||||||||
|
||||||||||||||||||||||
To run publisher and subscriber examples: | ||||||||||||||||||||||
|
||||||||||||||||||||||
```sh | ||||||||||||||||||||||
yarn example src/pub.rs | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
```sh | ||||||||||||||||||||||
yarn example src/sub.rs | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
yarn example src/z_sub.ts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
The subscriber should start to receive messages from publisher: | ||||||||||||||||||||||
|
||||||||||||||||||||||
```text | ||||||||||||||||||||||
>> [Subscriber] Received PUT ('demo/example/zenoh-ts-pub': '[0] 122,101,110,111,104') | ||||||||||||||||||||||
>> [Subscriber] Received PUT ('demo/example/zenoh-ts-pub': '[1] 122,101,110,111,104') | ||||||||||||||||||||||
>> [Subscriber] Received PUT ('demo/example/zenoh-ts-pub': '[2] 122,101,110,111,104') | ||||||||||||||||||||||
``` | ||||||||||||||||||||||
|
||||||||||||||||||||||
This will start an instance of Deno running the example. | ||||||||||||||||||||||
The application will attempt to connect to a `websocket_port` : `10000` where the Remote API plugin is expected to be running. | ||||||||||||||||||||||
|
||||||||||||||||||||||
### Adding Typescript to your application | ||||||||||||||||||||||
|
||||||||||||||||||||||
The latest version of zenoh-ts library can be installed from npm: | ||||||||||||||||||||||
|
||||||||||||||||||||||
```sh | ||||||||||||||||||||||
npm install @eclipse-zenoh/zenoh-ts | ||||||||||||||||||||||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
{ | ||
mode: 'router', | ||
plugins_loading: { | ||
enabled: true, | ||
search_dirs: ['./target/debug', '~/.zenoh/lib'] | ||
}, | ||
plugins: { | ||
remote_api: { | ||
websocket_port: '10000', | ||
secure_websocket: { | ||
certificate_path: 'path/to/certificate_path', | ||
private_key_path: 'path/to/private_key_path' | ||
} | ||
} | ||
} | ||
websocket_port: '10000' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not also mention that the user can add configuration for certificates for secure websockets here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal was to allow to user to run the examples immediately, without making any changes. The example with certificates is in "config.json5" file, I'll add reference to it to readme.
There is no way to comment out part of json config :-(