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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more