Skip to content

Commit 8cfad4f

Browse files
author
Guy Bedford
authored
fix: ready-based immediate task indexing (#1129)
1 parent cf6b5a0 commit 8cfad4f

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

integration-tests/js-compute/setup.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import { getEnv } from './env.js';
77
const serviceId = argv[2];
88
const serviceName = argv[3];
99

10+
const env = getEnv(serviceName);
11+
Object.assign(process.env, env);
12+
1013
const {
1114
DICTIONARY_NAME,
1215
CONFIG_STORE_NAME,
1316
KV_STORE_NAME,
1417
SECRET_STORE_NAME,
1518
ACL_NAME,
16-
} = getEnv(serviceName);
19+
} = env;
1720

1821
function existingListId(stores, existingName) {
1922
const existing = stores.find(
@@ -49,11 +52,10 @@ async function setupConfigStores() {
4952
if (!STORE_ID) {
5053
console.log(`Creating new config store ${DICTIONARY_NAME}`);
5154
STORE_ID = JSON.parse(
52-
await zx`fastly config-store create --quiet --name=${DICTIONARY_NAME} --json --token $FASTLY_API_TOKEN`,
55+
await zx`fastly config-store create --quiet --name="$DICTIONARY_NAME" --json --token $FASTLY_API_TOKEN`,
5356
).id;
5457
} else {
5558
console.log(`Using existing config store ${DICTIONARY_NAME}`);
56-
STORE_ID = STORE_ID;
5759
}
5860
await zx`echo -n 'https://twitter.com/fastly' | fastly config-store-entry update --upsert --key twitter --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
5961
try {
@@ -66,11 +68,10 @@ async function setupConfigStores() {
6668
if (!STORE_ID) {
6769
console.log(`Creating new config store ${CONFIG_STORE_NAME}`);
6870
STORE_ID = JSON.parse(
69-
await zx`fastly config-store create --quiet --name=${CONFIG_STORE_NAME} --json --token $FASTLY_API_TOKEN`,
71+
await zx`fastly config-store create --quiet --name="$CONFIG_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
7072
).id;
7173
} else {
7274
console.log(`Using existing config store ${CONFIG_STORE_NAME}`);
73-
STORE_ID = STORE_ID;
7475
}
7576
await zx`echo -n 'https://twitter.com/fastly' | fastly config-store-entry update --upsert --key twitter --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
7677
try {
@@ -89,11 +90,10 @@ async function setupKVStore() {
8990
if (!STORE_ID) {
9091
console.log(`Creating new KV store ${KV_STORE_NAME}`);
9192
STORE_ID = JSON.parse(
92-
await zx`fastly kv-store create --quiet --name=${KV_STORE_NAME} --json --token $FASTLY_API_TOKEN`,
93+
await zx`fastly kv-store create --quiet --name="$KV_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
9394
).StoreID;
9495
} else {
9596
console.log(`Using existing KV store ${KV_STORE_NAME}`);
96-
STORE_ID = STORE_ID;
9797
}
9898
try {
9999
await zx`fastly resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
@@ -110,7 +110,7 @@ async function setupSecretStore() {
110110
if (!STORE_ID) {
111111
console.log(`Creating new secret store ${SECRET_STORE_NAME}`);
112112
STORE_ID = JSON.parse(
113-
await zx`fastly secret-store create --quiet --name=${SECRET_STORE_NAME} --json --token $FASTLY_API_TOKEN`,
113+
await zx`fastly secret-store create --quiet --name="$SECRET_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
114114
).id;
115115
} else {
116116
console.log(`Using existing secret store ${SECRET_STORE_NAME}`);
@@ -136,7 +136,7 @@ async function setupAcl() {
136136
if (!ACL_ID) {
137137
console.log(`Creating ACL ${ACL_NAME}`);
138138
ACL_ID = JSON.parse(
139-
await zx`fastly compute acl create --name=${ACL_NAME} --token $FASTLY_API_TOKEN --json`,
139+
await zx`fastly compute acl create --name="$ACL_NAME" --token $FASTLY_API_TOKEN --json`,
140140
).id;
141141
await zx`fastly compute acl update --acl-id=${ACL_ID} --operation=create --prefix=100.100.0.0/16 --action=BLOCK --token $FASTLY_API_TOKEN`;
142142
await zx`fastly compute acl update --acl-id=${ACL_ID} --operation=create --prefix=2a03:4b80::/32 --action=ALLOW --token $FASTLY_API_TOKEN`;
@@ -150,9 +150,11 @@ async function setupAcl() {
150150
}
151151
}
152152

153+
zx.verbose = true;
153154
await setupConfigStores();
154155
await setupKVStore();
155156
await setupSecretStore();
156157
await setupAcl();
158+
zx.verbose = false;
157159

158160
await zx`fastly service-version activate --service-id ${serviceId} --version latest --token $FASTLY_API_TOKEN`;

runtime/fastly/host-api/host_api.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ size_t api::AsyncTask::select(std::vector<api::AsyncTask *> &tasks) {
183183
// only immediate timers in the task list -> do a ready check against all handles instead of a
184184
// select
185185
if (now != 0 && soonest_deadline == now) {
186-
for (auto handle : handles) {
186+
for (ret = 0; ret < handles.size(); ++ret) {
187+
auto handle = handles.at(ret);
187188
uint32_t is_ready_out;
188189
if (!convert_result(fastly::async_is_ready(handle, &is_ready_out), &err)) {
189190
if (host_api::error_is_bad_handle(err)) {

0 commit comments

Comments
 (0)