方法 asyncBlock 正在正确执行。
但是(其他两种方法)当它被分成 2 种方法时,它会重新调整承诺而不是实际值。
https://runkit.com/sedhuait/5af7bc4eebb12c00128f718e
const asyncRedis = require("async-redis");
const myCache = asyncRedis.createClient();
myCache.on("error", function(err) {
console.log("Error " + err);
});
const asyncBlock = async() => {
await myCache.set("k1", "val1");
const value = await myCache.get("k1");
console.log("val2",value);
};
var setValue = async(key, value) => {
await myCache.set(key, value);
};
var getValue = async(key) => {
let val = await myCache.get(key);
return val;
};
asyncBlock(); // working
setValue("aa", "bb"); // but this isn't
console.log("val", getValue("aa"));//but this isn't
Run Code Online (Sandbox Code Playgroud)
输出
val Promise …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Nestjs EventEmitter 模块的帮助下实现具有无服务器 lambda 函数的异步工作线程。
处理程序在发出事件时被调用,但该函数在 async/await 调用之前关闭。
我尝试过同时使用emitandemitAsync函数和不同的参数
@OnEvent(AccountEvents.NEW_ACCOUNT, {async:true, promisify:true})
制作人片段
public async execute(event: EventDetail): Promise<void> {
await this.eventEmitter.emitAsync(AccountEvents.NEW_ACCOUNT, event);
}
Run Code Online (Sandbox Code Playgroud)
听众片段
@OnEvent(AccountEvents.NEW_ACCOUNT)
public async handleAccountCreatedEvent(event: EventDetail): Promise<void> {
this.logger.log({ message: `Log1: ${AccountEvents.NEW_ACCOUNT} Handler`, event });
const message = await this.testAsync();
this.logger.log({ message });
this.logger.log({ message: 'Log 3: Event Processing Successfuly Completed' });
}
private testAsync(): Promise<string> {
return new Promise(res => {
setTimeout(() => {
res('Log 2: Promise resolved after one sec'); …Run Code Online (Sandbox Code Playgroud) 它的理论问题.我被告知铸造物体不是最好的.所以我们使用泛型来避免它.
但是内部会发生什么?为什么沮丧?
3.在Java中是否有内部实现.
请解释一个例子,并提及涉及该过程的方法/类.
我能否覆盖其默认实现?(只是好奇,希望它不傻)
Athena 表的分区方式与 s3 文件夹路径相同
parent=9ab4fcca-65d8-11ea-bc55-0242ac130003/year=2020/month=4/date=17
parent=9ab4fcca-65d8-11ea-bc55-0242ac130003/year=2020/month=4/date=9
parent=0fc966a0-bba7-4c0b-a648-cff7f0332059/year=2020/month=4/date=16
parent=9ab4fcca-65d8-11ea-bc55-0242ac130003/year=2020/month=4/date=14
Run Code Online (Sandbox Code Playgroud)
PARTITIONED BY (
`parent` string,
`year` int,
`month` tinyint,
`date` tinyint)
Run Code Online (Sandbox Code Playgroud)
现在,我应该如何形成选择查询的 where 条件以获取 2019-06-01 到 2020-04-31 的 Parent = "9ab4fcca-65d8-11ea-bc55-0242ac130003" 的数据?
SELECT *
FROM table
WHERE parent = '9ab4fcca-65d8-11ea-bc55-0242ac130003' AND year >= 2019 AND year <= 2020 AND month >= 04 AND month <= 06 AND date >= 01 AND date <= 31 ;
Run Code Online (Sandbox Code Playgroud)
但这是不正确的。请帮忙
我正在尝试将记录插入到我的 aws 时间流表中。它的获取导致了访问被拒绝错误。
这是serverless.yml上的权限
- Effect: Allow
Action:
- timestream:*
Resource:
- arn:aws:timestream:${self:provider.region}:*:database/*
- arn:aws:timestream:${self:provider.region}:*:database/*/*/*
Run Code Online (Sandbox Code Playgroud)
我是 lambda 的角色详细信息。
{
"Action": [
"timestream:*"
],
"Resource": [
"arn:aws:timestream:us-east-1:*:database/*",
"arn:aws:timestream:us-east-1:*:database/*/*/*"
],
"Effect": "Allow"
},
Run Code Online (Sandbox Code Playgroud)
记录样本
{
"DatabaseName": "developmentreportsdb",
"TableName": "developmenteventstable",
"Records": [
{
"Dimensions": [
{
"Name": "accountId",
"Value": "6921e43e-266c-4adf-8a69-d90bd8743d1b"
},
{
"Name": "userId",
"Value": "6921e43e-266c-4adf-8a69-d90bd8743d1b"
}
],
"MeasureName": "ACCOUNT.NEW",
"MeasureValue": "6921e43e-266c-4adf-8a69-d90bd8743d1b",
"MeasureValueType": "VARCHAR",
"Time": "1644234263813",
"TimeUnit": "MILLISECONDS",
"Version": 1
}
]
}
Run Code Online (Sandbox Code Playgroud)
错误详情:
Error writing records: AccessDeniedException: User: arn:aws:sts::344128203239:assumed-role/development-us-east-1-lambdaRole/development-worker is not authorized …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-cloudformation serverless amazon-timestream
async-await ×1
casting ×1
eventemitter ×1
java ×1
javascript ×1
nestjs ×1
node.js ×1
presto ×1
redis ×1
serverless ×1