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
add raw buffer mode #35
Conversation
646773c
to
49829e2
Compare
@@ -18,7 +18,7 @@ Notice | |||
------------------- | |||
We suggest using fc2,The main difference between fc and fc2 is: | |||
|
|||
The response returned by the user is the following dict, for invoke function, data is bytes, for other apis, data is dict. |
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.
bytes和dict都是Python里面的术语
README.md
Outdated
resp = await client.invokeFunction(serviceName, funcName, null); | ||
console.log('invoke function: %j', resp); | ||
|
||
// respBuf is returned as buffer if isRawBuf is true | ||
respBuf = await client.invokeFunction(serviceName, funcName, null, {}, 'LATEST', true); |
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.
这个叫respBuf不合适,invokeFunction的返回不是直接的一个Buffer,resp.data是Buffer
test/client.test.js
Outdated
expect(func.data).to.have.property('functionName', functionWithHandledErr); | ||
|
||
const response = await client.invokeFunction(serviceName, functionWithHandledErr, Buffer.from('world'), {}, 'LATEST', true); | ||
expect(response.data).an(Object) |
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.
Buffer也是Object吧?
@@ -734,7 +804,8 @@ describe('client test', function () { | |||
{ | |||
'additionalVersionWeight': { | |||
'2': 0.3 | |||
} | |||
}, | |||
'description': '' |
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.
这个改动是为啥?
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.
之前的 case 过不了,看了代码,create alias 的时候 description 为 'test alias',update 没有更新 description,expect description to be ' ' 是会 fail 的。
test/client.test.js
Outdated
expect(func.data).to.have.property('functionName', functionWithUnhandledErr); | ||
|
||
const response = await client.invokeFunction(serviceName, functionWithUnhandledErr, Buffer.from('world'), {}, 'LATEST', true); | ||
expect(response.data).an(Object) |
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.
Unhandled error也要assert error message
README.md
Outdated
resp = await client.invokeFunction(serviceName, funcName, null); | ||
console.log('invoke function: %j', resp); | ||
|
||
// respBuf is returned as buffer if isRawBuf is true | ||
respBuf = await client.invokeFunction(serviceName, funcName, null, {}, 'LATEST', true); |
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.
最后一个参数是bool不太好,光看一个false/true不太清楚是什么含义,可以变成一个opts = {},然后调用的时候变成:
respBuf = await client.invokeFunction(serviceName, funcName, null, {}, 'LATEST', {rawBuf: true});
49829e2
to
f84e7d4
Compare
README.md
Outdated
@@ -27,6 +27,10 @@ The response returned by the user is the following dict, for invoke function, da | |||
} | |||
|
|||
``` | |||
for invoke function, data is the results returned by your code. By default, data is decoded by utf8, if you would like to get raw buffer, just set {isRawBuf: true} in opts when you invoke function. |
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.
isRawBuf => rawBuf
f84e7d4
to
864ad68
Compare
add raw buffer mode for invokeFunction