Skip to content
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

Merged
merged 1 commit into from Nov 13, 2018
Merged

add raw buffer mode #35

merged 1 commit into from Nov 13, 2018

Conversation

CiCi503
Copy link
Collaborator

@CiCi503 CiCi503 commented Nov 9, 2018

add raw buffer mode for invokeFunction

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

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

@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.

None yet

3 participants