Skip to content

Instantly share code, notes, and snippets.

Avatar
🦝
☕️

Antti Pitkänen anttispitkanen

🦝
☕️
View GitHub Profile
View handleDataRequestWithCanaryTraffic.ts
const CANARY_THRESHOLD_PERCENT = parseInt(
process.env.CANARY_THRESHOLD_PERCENT || '0',
);
/**
* This function divides the traffic between Old Data API and New Data API
* based on the runtime configuration of CANARY_THRESHOLD_PERCENT.
*/
export const handleDataRequestWithCanaryTraffic = (
requestId: string,
View handleDataRequestWithShadowTraffic.ts
const SHADOW_TRAFFIC_ENABLED = process.env.SHADOW_TRAFFIC_ENABLED === 'true';
/**
* This function includes the shadow traffic "side channel" in addition to
* the "main channel".
*/
export const handleDataRequestWithShadowTraffic = (
requestId: string,
animal: TAnimal,
): Promise<TDataApiData> => {
View model.basic.ts
export const handleDataRequest = (requestId: string, animal: TAnimal): Promise<TDataApiData> =>
dataApiClient.getData(requestId, animal);
@anttispitkanen
anttispitkanen / test.js
Last active May 25, 2021
What happens to the first async function (waitAndReturn) invocation?
View test.js
const waitAndReturn = (ms, msg) =>
new Promise(resolve => {
setTimeout(() => {
resolve(msg);
}, ms);
});
const foo = () => {
waitAndReturn(5000, 'First').then(msg => console.log(msg));
@anttispitkanen
anttispitkanen / App.js
Created Feb 25, 2019
Awesome react application, wanna invest?
View App.js
import React, { Component } from "react";
import "./App.css";
const names = [
"Repe",
"Pera",
"Kartsa",
"Raipe",
"Simo",
"Jussi",