-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into eladb/service-state
- Loading branch information
Showing
11 changed files
with
212 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
bring cloud; | ||
bring util; | ||
|
||
let var timeout = 100ms; | ||
let var retentionPeriod = 1s; | ||
|
||
let q = new cloud.Queue(timeout: timeout, retentionPeriod: retentionPeriod); | ||
|
||
test "retentionPeriod" { | ||
q.push("hello", "world"); | ||
|
||
assert(util.waitUntil(() => { | ||
return q.approxSize() == 0; | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
...apshots__/test_corpus/sdk_tests/queue/retention_period.main.w_compile_tf-aws.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# [retention_period.main.w](../../../../../../examples/tests/sdk_tests/queue/retention_period.main.w) | compile | tf-aws | ||
|
||
## inflight.$Closure1-1.js | ||
```js | ||
module.exports = function({ $q, $util_Util }) { | ||
class $Closure1 { | ||
constructor({ }) { | ||
const $obj = (...args) => this.handle(...args); | ||
Object.setPrototypeOf($obj, this); | ||
return $obj; | ||
} | ||
async handle() { | ||
(await $q.push("hello","world")); | ||
{((cond) => {if (!cond) throw new Error("assertion failed: util.waitUntil(() => {\n return q.approxSize() == 0;\n })")})((await $util_Util.waitUntil(async () => { | ||
return (((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await $q.approxSize()),0)); | ||
} | ||
)))}; | ||
} | ||
} | ||
return $Closure1; | ||
} | ||
|
||
``` | ||
|
||
## main.tf.json | ||
```json | ||
{ | ||
"//": { | ||
"metadata": { | ||
"backend": "local", | ||
"stackName": "root", | ||
"version": "0.17.0" | ||
}, | ||
"outputs": { | ||
"root": { | ||
"Default": { | ||
"cloud.TestRunner": { | ||
"TestFunctionArns": "WING_TEST_RUNNER_FUNCTION_ARNS" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"output": { | ||
"WING_TEST_RUNNER_FUNCTION_ARNS": { | ||
"value": "[]" | ||
} | ||
}, | ||
"provider": { | ||
"aws": [ | ||
{} | ||
] | ||
}, | ||
"resource": { | ||
"aws_sqs_queue": { | ||
"cloudQueue": { | ||
"//": { | ||
"metadata": { | ||
"path": "root/Default/Default/cloud.Queue/Default", | ||
"uniqueId": "cloudQueue" | ||
} | ||
}, | ||
"message_retention_seconds": 1, | ||
"name": "cloud-Queue-c86e03d8", | ||
"visibility_timeout_seconds": 0.1 | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## preflight.js | ||
```js | ||
const $stdlib = require('@winglang/sdk'); | ||
const $plugins = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLUGIN_PATHS); | ||
const $outdir = process.env.WING_SYNTH_DIR ?? "."; | ||
const $wing_is_test = process.env.WING_IS_TEST === "true"; | ||
const std = $stdlib.std; | ||
const cloud = $stdlib.cloud; | ||
const util = $stdlib.util; | ||
class $Root extends $stdlib.std.Resource { | ||
constructor(scope, id) { | ||
super(scope, id); | ||
class $Closure1 extends $stdlib.std.Resource { | ||
constructor(scope, id, ) { | ||
super(scope, id); | ||
(std.Node.of(this)).hidden = true; | ||
} | ||
static _toInflightType(context) { | ||
return ` | ||
require("./inflight.$Closure1-1.js")({ | ||
$q: ${context._lift(q)}, | ||
$util_Util: ${context._lift($stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"))}, | ||
}) | ||
`; | ||
} | ||
_toInflight() { | ||
return ` | ||
(await (async () => { | ||
const $Closure1Client = ${$Closure1._toInflightType(this)}; | ||
const client = new $Closure1Client({ | ||
}); | ||
if (client.$inflight_init) { await client.$inflight_init(); } | ||
return client; | ||
})()) | ||
`; | ||
} | ||
_getInflightOps() { | ||
return ["handle", "$inflight_init"]; | ||
} | ||
_registerBind(host, ops) { | ||
if (ops.includes("handle")) { | ||
$Closure1._registerBindObject(q, host, ["approxSize", "push"]); | ||
} | ||
super._registerBind(host, ops); | ||
} | ||
} | ||
let timeout = (std.Duration.fromSeconds(0.1)); | ||
let retentionPeriod = (std.Duration.fromSeconds(1)); | ||
const q = this.node.root.newAbstract("@winglang/sdk.cloud.Queue",this,"cloud.Queue",{ timeout: timeout, retentionPeriod: retentionPeriod }); | ||
this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:retentionPeriod",new $Closure1(this,"$Closure1")); | ||
} | ||
} | ||
const $App = $stdlib.core.App.for(process.env.WING_TARGET); | ||
new $App({ outdir: $outdir, name: "retention_period.main", rootConstruct: $Root, plugins: $plugins, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }).synth(); | ||
|
||
``` | ||
12 changes: 12 additions & 0 deletions
12
...r/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_test_sim.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# [retention_period.main.w](../../../../../../examples/tests/sdk_tests/queue/retention_period.main.w) | test | sim | ||
|
||
## stdout.log | ||
```log | ||
pass ─ retention_period.main.wsim » root/env0/test:retentionPeriod | ||
Tests 1 passed (1) | ||
Test Files 1 passed (1) | ||
Duration <DURATION> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters