Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Oct 30, 2021
1 parent 651c45f commit 1a664d8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
8 changes: 8 additions & 0 deletions configs/config_integration_redis_etcd.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@
}
}
},
"pub_subs": {
"redis": {
"metadata": {
"redisHost": "localhost:6380",
"redisPassword": ""
}
}
},
"app": {
"app_id": "app1",
"grpc_callback_port": 9999
Expand Down
1 change: 1 addition & 0 deletions sdk/js-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"homepage": "https://github.com/mosn/layotto#readme",
"devDependencies": {
"@eggjs/tsconfig": "^1.0.0",
"@types/google-protobuf": "^3.15.5",
"@types/jest": "^27.0.2",
"egg-ci": "^1.19.0",
"grpc-tools": "^1.11.2",
Expand Down
22 changes: 16 additions & 6 deletions sdk/js-sdk/src/client/Invoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,24 @@ export default class Invoker extends API {
this.runtime.invokeService(req, this.createMetadata(request), (err, res: InvokeResponsePB) => {
if (err) return reject(err);
const contentType = res.getContentType().split(';', 1)[0].toLowerCase();
const content = res.getData() as Buffer;
const response: InvokeResponse = { contentType, content };
const rawData = res.getData();
let content;
if (contentType === 'application/json') {
response.content = JSON.parse(content.toString());
}
if (contentType === 'text/plain') {
response.content = content.toString();
if (rawData) {
content = JSON.parse(Buffer.from(rawData.getValue_asU8()).toString());
} else {
content = {};
}
} else if (contentType === 'text/plain') {
if (rawData) {
content = Buffer.from(rawData.getValue_asU8()).toString();
} else {
content = '';
}
} else {
content = rawData ? rawData.getValue_asU8() : [];
}
const response: InvokeResponse = { contentType, content };
resolve(response);
});
});
Expand Down

0 comments on commit 1a664d8

Please sign in to comment.