-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2679 from threefoldtech/development_rmb_docs
Update installation instructions in RMB `Peer`, `Direct` README.md
- Loading branch information
Showing
5 changed files
with
98 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Types Update Guide for Developers | ||
|
||
## Introduction | ||
|
||
This guide outlines the steps to update the types used in the `RMB Direct Client` to reflect changes in messages sent over the RMB. | ||
|
||
### Prerequisites | ||
|
||
- **Install Protobuf**: Install [Protobuf](https://grpc.io/docs/protoc-installation/) on your system. | ||
|
||
## Usage | ||
|
||
1. **Update types.proto File**: Update the [types.proto](lib/types.proto) file with any changes to the message structure. | ||
2. **Run build.sh Script**: Execute the [build.sh](build.sh) script to generate the necessary TypeScript files. | ||
|
||
After updating the types, run the `build.sh` script, and ensure that the client is updated accordingly to utilize the auto-generated [types.ts](lib/types/lib/types.ts) file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,78 @@ | ||
# rmb_peer_client | ||
# RMB Peer Client | ||
|
||
[![Version](https://img.shields.io/npm/v/@threefold/rmb_peer_client?color=blue)](https://www.npmjs.com/package/@threefold/rmb_peer_client) | ||
[![Lint](https://github.com/threefoldtech/tfgrid-sdk-ts/actions/workflows/lint.yml/badge.svg)](https://github.com/threefoldtech/tfgrid-sdk-ts/actions/workflows/lint.yml) | ||
[![Build](https://github.com/threefoldtech/tfgrid-sdk-ts/actions/workflows/build.yml/badge.svg)](https://github.com/threefoldtech/tfgrid-sdk-ts/actions/workflows/build.yml) | ||
|
||
The RMB Peer Client is a TypeScript library that enables communication with the ThreeFold Messaging Bus (RMB). It provides functionalities similar to the [Rust client](https://github.com/threefoldtech/rmb-rs). | ||
|
||
## Usage | ||
|
||
To use the RMB Peer Client, instantiate the `MessageBusClient` class: | ||
|
||
```ts | ||
import { MessageBusClient } from "@threefold/rmb_peer_client"; | ||
|
||
const messageBus = new MessageBusClient(); | ||
``` | ||
|
||
You can send messages over the RMB using the `send` method, which takes the following parameters: | ||
|
||
1. `requestCommand` The command to be executed in the Zero-OS node. | ||
2. `requestData` The message content. | ||
3. `destinationTwinId` The ID of the destination twin to receive the message. | ||
4. `expirationMinutes` Expiration time for the message in minutes. | ||
|
||
```ts | ||
const requestId = await messageBus.send("zos.nodes.list", "", 143, 5); | ||
``` | ||
|
||
After sending a message, you can read the response using the `read` method: | ||
|
||
```ts | ||
const response = await messageBus.read(requestId); | ||
``` | ||
|
||
## Installation | ||
|
||
Install the package via npm: | ||
|
||
```bash | ||
npm install @threefold/rmb_peer_client | ||
``` | ||
|
||
## Example | ||
|
||
```ts | ||
import { MessageBusClient } from "@threefold/rmb_peer_client"; | ||
|
||
const messageBus = new MessageBusClient(); | ||
|
||
// Send a message | ||
const requestId = await messageBus.send("zos.nodes.list", "", 143, 5); | ||
|
||
// Read the response | ||
const response = await messageBus.read(requestId); | ||
``` | ||
|
||
## API | ||
|
||
### `MessageBusClient()` | ||
|
||
- Constructor function to create a new instance of the RMB Peer Client. | ||
- Accepts an optional `port` parameter to specify the Redis server port. Defaults to `6379`. | ||
|
||
### `send(requestCommand: string, requestData: string, destinationTwinId: number, expirationMinutes: number): Promise<string>` | ||
|
||
- Method to send a message over the RMB. | ||
- Returns a promise that resolves to the request ID. | ||
|
||
### `read(requestId: string, timeoutMinutes = 1): Promise<unknown>` | ||
|
||
- Method to read the response for a specific request ID. | ||
- Accepts an optional `timeoutMinutes` parameter to specify the timeout duration for waiting for the response. | ||
- Returns a promise that resolves to the response data. | ||
|
||
## Requirements | ||
|
||
- Redis server running locally or on a specified host/port. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters