I kind of like the idea of using context for this. The context might contain the domain and/or region of the least carbon intense available service available.
{
"servicename": {
"domain": "https://eu-west-1.climatewarrior.store" // least carbon intense domain at the time for service
}
}
More generic approach - probably better suited as independent framework agnostic NPM lib.
// Run bounced request
const { res } = await hedge("emissionless").bounce("/rollthecloudinc/hedge-objects/shapeshifter/services/emissionless.json", {});
// Get optimal available region wrapper
const { region } = await hedge("emissionless").region()
// Get the raw region document object literal
const { regionDocument } = await region.document()
// Get CURRENT carbon savings between optimal region and specified region.
const = { savings } = await region.compare("us-east-1").savings()
// Full service config hedge wrapper
const { service } = await hedge("emissionless").service()
// Get the raw service document object literal
const { serviceDocument } = await service.document()
// Full service config
const { res } = await hedge("rtcopensearch").bounce("/...", { body: {}, method: "POST" })
// records carbon savings as well
export const hedge (service, options) => new Promise();
export const service = ({ service, adaptor }) => adaptor({ name: adaptor ? adaptor : "fetch" }).then(adaptor => adaptor(`https://store.hedge.earth/services/${service}`)).then(service => ({ service }))
export const region = ({ service, region }) => service({ service }).then(({ service }) => ({ region: service.regions.find(r => r.region === region) }));
export const adaptor = ({ name }) => new Promise(res => res(fetch));
I kind of like the idea of using context for this. The context might contain the domain and/or region of the least carbon intense available service available.
hedge context:
More generic approach - probably better suited as independent framework agnostic NPM lib.