The Layotto Node.js SDK to build your application.
git clone --recurse-submodules git@github.com:layotto/js-sdk.git
If forgot to add --recurse-submodules
, you can run git submodule update --init --recursive
to clone the submodules.
More git submodule commands, please refer to Git submodule.
demo/state.ts
import { Client } from 'layotto';
const storeName = 'redis';
const key = 'foo-js-sdk';
const value = `bar, from js-sdk, ${Date()}`;
await client.state.save({
storeName,
states: { key, value },
});
console.log('saveState success, key: %j, value: %j', key, value);
const resValue = await client.state.get({ storeName, key });
console.log('getState success, key: %j, value: %j, toString: %j',
key, resValue, Buffer.from(resValue).toString('utf8'));
npm install
Should install grpc-tools first. MacOS M1 follow this issue.
npm run build:grpc
- Running redis and etcd under Docker
docker-compose up -d
- Start a echoserver for testing the rpc api
node demo/rpc/http/server.js
If you want to know more about this, check https://mosn.io/layotto/#/zh/start/rpc/helloworld
- Start Layotto, see How to run layotto
cd layotto/cmd/layotto
go build
./layotto start -c ../../../demo/config.json
- Then, run the test script by npm
npm run test:unit
Enable trace debug log for grpc-js:
GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/unit/client/Invoker.test.ts
- Core concepts, architecture and lifecycle
- Get Start with gRPC on Node.js
- Node.js gRPC Library
- Understanding Streams in Node.js
- Go Proxy in China
- How to build a bi-directional streaming gRPC service with Node.js and Java
fengmk2 |
seeflood |
LZHK1ng |
killagu |
---|
This project follows the git-contributor spec, auto updated at Thu Oct 13 2022 15:14:41 GMT+0800
.