Compare commits
5 Commits
fix-statef
...
master
Author | SHA1 | Date |
---|---|---|
wss-git | fb64cc31c9 | |
heimanba | 16fef7da63 | |
wss-git | 53524ca5a0 | |
千风 | 545b575b2e | |
wss-git | 853611b69f |
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "fc-remote-invoke",
|
"name": "fc-remote-invoke",
|
||||||
"version": "0.0.20",
|
"version": "0.0.23",
|
||||||
"description": "This is a component demo for Serverless Devs Tool ",
|
"description": "This is a component demo for Serverless Devs Tool ",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Serverless",
|
"Serverless",
|
||||||
|
|
|
@ -2,7 +2,7 @@ Type: Component
|
||||||
Name: fc-remote-invoke
|
Name: fc-remote-invoke
|
||||||
Provider:
|
Provider:
|
||||||
- 其它
|
- 其它
|
||||||
Version: 0.0.21
|
Version: 0.0.23
|
||||||
Description: 初始化component模板
|
Description: 初始化component模板
|
||||||
HomePage: https://www.serverless-devs.com
|
HomePage: https://www.serverless-devs.com
|
||||||
Tags: #标签详情
|
Tags: #标签详情
|
||||||
|
|
16
src/index.ts
16
src/index.ts
|
@ -15,6 +15,7 @@ export default class FcRemoteInvoke {
|
||||||
async invoke(inputs: InputProps): Promise<any> {
|
async invoke(inputs: InputProps): Promise<any> {
|
||||||
const {
|
const {
|
||||||
props,
|
props,
|
||||||
|
timeout,
|
||||||
eventPayload,
|
eventPayload,
|
||||||
credentials,
|
credentials,
|
||||||
isHelp,
|
isHelp,
|
||||||
|
@ -31,7 +32,7 @@ export default class FcRemoteInvoke {
|
||||||
let fcClient;
|
let fcClient;
|
||||||
if (!props.domainName) {
|
if (!props.domainName) {
|
||||||
const fcCommon = await core.loadComponent('devsapp/fc-common');
|
const fcCommon = await core.loadComponent('devsapp/fc-common');
|
||||||
fcClient = await fcCommon.makeFcClient({ ...inputs, props: { region: props.region }});
|
fcClient = await fcCommon.makeFcClient({ ...inputs, props: { region: props.region, timeout }});
|
||||||
}
|
}
|
||||||
const remoteInvoke = new RemoteInvoke(fcClient, credentials.AccountID);
|
const remoteInvoke = new RemoteInvoke(fcClient, credentials.AccountID);
|
||||||
await remoteInvoke.invoke(props, eventPayload, { invocationType, statefulAsyncInvocationId });
|
await remoteInvoke.invoke(props, eventPayload, { invocationType, statefulAsyncInvocationId });
|
||||||
|
@ -51,6 +52,7 @@ export default class FcRemoteInvoke {
|
||||||
|
|
||||||
const parsedArgs: {[key: string]: any} = core.commandParse({ ...inputs, args }, {
|
const parsedArgs: {[key: string]: any} = core.commandParse({ ...inputs, args }, {
|
||||||
boolean: ['help', 'event-stdin'],
|
boolean: ['help', 'event-stdin'],
|
||||||
|
number: ['timeout'],
|
||||||
string: ['invocation-type', 'event', 'event-file', 'region', 'domain-name','service-name', 'function-name', 'qualifier', 'stateful-async-invocation-id'],
|
string: ['invocation-type', 'event', 'event-file', 'region', 'domain-name','service-name', 'function-name', 'qualifier', 'stateful-async-invocation-id'],
|
||||||
alias: {
|
alias: {
|
||||||
'help': 'h',
|
'help': 'h',
|
||||||
|
@ -108,8 +110,20 @@ export default class FcRemoteInvoke {
|
||||||
throw new Error('region/serviceName(service-name)/functionName(function-name) can not be empty.');
|
throw new Error('region/serviceName(service-name)/functionName(function-name) can not be empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 超时时间获取的原理:https://github.com/devsapp/fc/issues/480
|
||||||
|
const propsTimeout = argsData.timeout || inputs.props?.timeout;
|
||||||
|
let timeout = 600;
|
||||||
|
if (_.isNumber(propsTimeout)) {
|
||||||
|
if (_.isEmpty(inputs.props?.runtime) || inputs.props?.runtime === 'custom-container') {
|
||||||
|
timeout = propsTimeout + 7 * 60;
|
||||||
|
} else {
|
||||||
|
timeout = propsTimeout + 2 * 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props,
|
props,
|
||||||
|
timeout,
|
||||||
credentials: inputs.credentials,
|
credentials: inputs.credentials,
|
||||||
eventPayload,
|
eventPayload,
|
||||||
isHelp: false,
|
isHelp: false,
|
||||||
|
|
|
@ -25,8 +25,10 @@ export interface IProperties {
|
||||||
region: string;
|
region: string;
|
||||||
serviceName: string;
|
serviceName: string;
|
||||||
functionName: string;
|
functionName: string;
|
||||||
|
runtime?: string;
|
||||||
qualifier?: string;
|
qualifier?: string;
|
||||||
domainName?: string;
|
domainName?: string;
|
||||||
|
timeout?: string;
|
||||||
}
|
}
|
||||||
export function isProperties(args: any): args is IProperties {
|
export function isProperties(args: any): args is IProperties {
|
||||||
if (!args) {
|
if (!args) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ export default class RemoteInvoke {
|
||||||
const { headers } = await this.fcClient.invokeFunction(serviceName, functionName, event, {
|
const { headers } = await this.fcClient.invokeFunction(serviceName, functionName, event, {
|
||||||
'X-Fc-Invocation-Code-Version': 'Latest',
|
'X-Fc-Invocation-Code-Version': 'Latest',
|
||||||
'X-Fc-Invocation-Type': invocationType,
|
'X-Fc-Invocation-Type': invocationType,
|
||||||
'X-Fc-Stateful-Async-Invocation-Id': statefulAsyncInvocationId,
|
'X-Fc-Stateful-Async-Invocation-Id': statefulAsyncInvocationId || "",
|
||||||
}, qualifier);
|
}, qualifier);
|
||||||
const rId = headers['x-fc-request-id'];
|
const rId = headers['x-fc-request-id'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue