Skip to content

Conversation

CiCi503
Copy link
Collaborator

@CiCi503 CiCi503 commented Nov 9, 2018

add raw buffer mode for invokeFunction

@CiCi503 CiCi503 requested a review from rockuw November 9, 2018 06:45
@CiCi503 CiCi503 force-pushed the add_raw_buffer_mode branch from 646773c to 49829e2 Compare November 9, 2018 10:06
@coveralls
Copy link

coveralls commented Nov 9, 2018

Coverage Status

Coverage increased (+0.09%) to 96.667% when pulling 864ad68 on add_raw_buffer_mode into 12e6702 on master.

@@ -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.
Copy link
Collaborator

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);
Copy link
Collaborator

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

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)
Copy link
Collaborator

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': ''
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改动是为啥?

Copy link
Collaborator Author

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 的。

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)
Copy link
Collaborator

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);
Copy link
Collaborator

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});

@CiCi503 CiCi503 force-pushed the add_raw_buffer_mode branch from 49829e2 to f84e7d4 Compare November 13, 2018 08:50
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isRawBuf => rawBuf

@CiCi503 CiCi503 force-pushed the add_raw_buffer_mode branch from f84e7d4 to 864ad68 Compare November 13, 2018 09:38
@rockuw rockuw merged commit 74ef70f into master Nov 13, 2018
@rockuw rockuw deleted the add_raw_buffer_mode branch November 13, 2018 12:31
CiCi503 pushed a commit that referenced this pull request Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants