Published
Edited
Aug 24, 2022
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
samples = {
const samples = samplesRaw.map((d) => ({
...d,
time: d.time.replace("_", ".")
}));
samples.reverse();
return samples;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
async function timedRequest(destination) {
const start = window.performance.now();
const response = await fetch(targetURL(destination), {
method: "POST",
body: `${window.performance.now()}`
});
response.text(); // ensure request closed
const delta = window.performance.now() - start;
return {
status: response.status,
ms: delta
};
}
Insert cell
Insert cell
Insert cell
Insert cell
ping = deploy(
`ping`,
async (req, res, ctx) => {
async function ping(region) {
const coldTime = readableTimestamp();
const datapointCold = await timedRequest(region);
await baseRef.child(coldTime + region).set({
tag: "cold",
region,
time: coldTime,
...datapointCold
});
const warmTime = readableTimestamp();
const datapointWarm = await timedRequest(region);
await baseRef.child(warmTime + region).set({
tag: "warm",
region,
time: warmTime,
...datapointWarm
});
}

try {
const token = await getAccessTokenFromServiceAccount(
ctx.secrets["tomlarkworthy_webadmin_service_account_key"]
);
await signinWithAccessToken(firebase, token);
await Promise.all(regions.map(ping));
res.json("OK");
} catch (err) {
return res.json(err.message);
}
},
{
region: "europe-west1", // Run pinger in an unrelated 4th test region
secrets: ["tomlarkworthy_webadmin_service_account_key"]
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
firebaseConfig = ({
apiKey: "AIzaSyBN4bxw6d0cM0CGPNzRrkRlBqwFQnPLdN4",
authDomain: "larkworthy-dfb11.firebaseapp.com",
databaseURL: "https://larkworthy-dfb11-default-rtdb.europe-west1.firebasedatabase.app",
projectId: "larkworthy-dfb11",
appId: "1:786910701676:web:8d7dd002acf3b78c74d049"
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more