我正在尝试使用AWS lambda建立一个hello world示例并通过api网关提供它.我点击了"创建一个Lambda函数",它设置了api gatway并选择了Blank Function选项.我添加了AWS网关入门指南中的lambda函数:
exports.handler = function(event, context, callback) {
callback(null, {"Hello":"World"}); // SUCCESS with message
};
Run Code Online (Sandbox Code Playgroud)
问题是,当我向它发出GET请求时,它返回502响应{ "message": "Internal server error" }.并且日志显示"由于配置错误导致执行失败:格式错误的Lambda代理响应".
我有一个简单的lambda函数,它异步地进行API调用,然后返回数据.99%的时间这个效果很好.当API需要更长时间然后lambda配置超时时,它会按预期给出错误.现在的问题是,当我对lambda函数进行任何后续调用时,它会永久地给出超时错误.
"errorMessage": "2016-05-14T22:52:07.247Z {session} Task timed out after 3.00 seconds"
Run Code Online (Sandbox Code Playgroud)
为了测试这种情况,我将lambda超时设置为3秒,并有办法在lambda中触发这两个函数.
使用Javascript
function now() {
return response.tell('success');
}
function wait() {
setTimeout(function() { return response.tell('success'); }, 4000);
}
Run Code Online (Sandbox Code Playgroud)
当我调用该now函数时没有问题.当我调用该wait函数时,我得到超时错误,然后任何后续调用now给我相同的错误.
这是预期的行为吗?我认为对lambda函数的任何后续调用都应该有效.我知道我总是可以增加配置超时,但不愿意.
action使用typescript在redux reducer中强制转换参数的最佳方法是什么?将会出现多个动作接口,这些接口都扩展了具有属性类型的基接口.扩展操作接口可以具有更多属性,这些属性在操作接口之间都是不同的.以下是一个示例:
interface IAction {
type: string
}
interface IActionA extends IAction {
a: string
}
interface IActionB extends IAction {
b: string
}
const reducer = (action: IAction) {
switch (action.type) {
case 'a':
return console.info('action a: ', action.a) // property 'a' does not exists on type IAction
case 'b':
return console.info('action b: ', action.b) // property 'b' does not exists on type IAction
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,action需要定投作为同时访问一个类型IActionA,并IActionB因此减速机可以同时使用action.a,并action.a不会引发错误. …
使用Docker容器创建干净的平板的最佳方法是什么?很多次我觉得从头开始更容易,但我有一堆容器,我不知道他们的状态是什么,然后当我运行docker rm它不会让我,因为docker容器仍然可以使用.
当使用带有样式组件的 html 输入并保存值以使用 onChange 响应状态时,组件似乎在每次状态更改时重新呈现并导致输入失去焦点。有什么办法可以防止输入失去焦点?为什么会出现这种情况?这是一个例子。
class MyComponent extends React.Component {
state = { val: "" };
render() {
const Input = styled.input`
border-radius: 6px;
`;
return (
<Input
value={this.state.val}
onChange={e => this.setState({ val: e.target.value })}
/>
);
}
}
Run Code Online (Sandbox Code Playgroud) 当将spyOn与 jest 和typescript一起使用时,我收到此类型错误:
类型“Spy”不可分配给类型“SpyInstance<{}>”。'Spy' 类型中缺少属性 'mockRestore'。
这是导致它的代码示例:
class A {
foo = () => this.bar() + 1;
bar = () => 1;
}
test('should pass', () => {
const a = new A();
let barSpy: jest.SpyInstance;
barSpy = spyOn(a, 'bar');
a.foo();
expect(barSpy).toHaveBeenCalled();
});
Run Code Online (Sandbox Code Playgroud)
当我运行此示例时,测试通过,但打字稿编译器失败。
我正在尝试为我的部署部署PodDisruptionBudget,但是当我部署此示例时
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: example-pdb
spec:
minAvailable: 1
selector:
matchLabels:
app: example-deployment
Run Code Online (Sandbox Code Playgroud)
通过此部署
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 1
selector:
matchLabels:
app: example-deployment-app
template:
metadata:
labels:
app: example-deployment-app
spec:
...
Run Code Online (Sandbox Code Playgroud)
我得到回应
$ kubectl get pdb
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE
example-pdb 1 N/A 0 7s
Run Code Online (Sandbox Code Playgroud)
“允许中断”为 0 意味着什么?
根据样式组件doc,我可以引用另一个组件来触发,例如,悬停效果.
const Link = styled.a`
display: flex;
align-items: center;
padding: 5px 10px;
background: papayawhip;
color: palevioletred;
`;
const Link2 = styled.a`
display: flex;
align-items: center;
padding: 5px 10px;
background: steelblue;
color: white;
${Link}:hover & {
background-color: greenyellow;
color: black;
}
`;
class Hello extends React.Component{
render() {
return(
<div>
<Link>Hello World</Link>
<Link2>Hello Again</Link2>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
基本上,我的鼠标悬停<Link>应触发改变background-color的<Link2>.
这不会发生.有什么想法吗?
我在这里准备了一个代码片段:https://codesandbox.io/s/qv34lox494
我正在查看他们文档中的 helm range 示例。
yaml
favorite:
drink: coffee
food: pizza
pizzaToppings:
- mushrooms
- cheese
- peppers
- onions
Run Code Online (Sandbox Code Playgroud)
舵
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
myvalue: "Hello World"
{{- with .Values.favorite }}
drink: {{ .drink | default "tea" | quote }}
food: {{ .food | upper | quote }}
{{- end }}
toppings: |-
{{- range .Values.pizzaToppings }}
- {{ . | title | quote }}
- {{ .Values.favorite.drink }}
{{- end }} …Run Code Online (Sandbox Code Playgroud) 当使用styled-components到样式自定义功能反应成分,都没有被应用的样式。这是一个简单的示例,其中样式未应用于StyledDiv:
const Div = () => (<div>test</div>)
const StyledDiv = styled(Div)`
color: red;
`;
Run Code Online (Sandbox Code Playgroud)
确保正确应用样式的最佳方法是什么?
如果我有一个基本的 kubernetes helm 模板,如下所示:
port: {{ .Values.Port }}
Run Code Online (Sandbox Code Playgroud)
如果没有传入,有没有办法指定默认端口?
kubernetes ×3
reactjs ×3
aws-lambda ×2
javascript ×2
node.js ×2
typescript ×2
docker ×1
jestjs ×1
redux ×1