Task input to the service looks like:
{
account_id : 1234,
queued : <date>, // date/time queued
status : 'pending', // pending, inflight, complete
// circuit breaker concept using async/await | |
let getFoo = yoda.do(async (foo) => { | |
return await request(`http://foo.example.com/api/foo/:${foo}`); | |
}).orDoNot(async (foo) => { | |
// fallback logic | |
}); | |
let foo = await getFoo(1234); |
// Idea for a pg lib wrapper that uses promises and converts | |
// queries into promise-returning functions. $1, $2 substitutions | |
// apply, and are extended with object (.keys, .values) handling | |
// to make working with objects simpler. | |
pgpr = new PGPR(pg_dbConnection) | |
let getCat = pgpr('SELECT * FROM cat WHERE id = $1') | |
let updateCat = pgpr('UPDATE cat SET $1.keys VALUES $1.values WHERE id = $2') |
'use strict'; | |
let mog = require('./mog'); | |
let express = require('express'); | |
let m = mog(); | |
// Define a cat object schema that we can use down the track.. | |
let cat = m` | |
cat @Object - Cat is a four legged creature, you need more of these | |
cat.name @String { min : 3, max : 35 } - All cats should have names, this is important |
-- BASE DB | |
CREATE TABLE IF NOT EXISTS "db_ver" ( | |
version integer unique not null, | |
updated timestamp WITH time zone DEFAULT now() | |
); | |
INSERT INTO db_ver (version) VALUES (1); -- init version 1 | |
-- Migrations are named 1.sql, 2.sql etc. |
DO $shards$ | |
BEGIN | |
FOR i IN 1..100 LOOP | |
DECLARE shardID TEXT := CONCAT('shard_', to_char(i, 'FM000')); | |
EXECUTE 'CREATE SCHEMA IF NOT EXISTS ' || shardID ';' | |
END LOOP; | |
END $shards$; | |
-- ERROR: syntax error at or near "EXECUTE" | |
-- LINE 5: EXECUTE 'CREATE SCHEMA IF NOT EXISTS ' || shardI... |
-- Create 100 schemas shard_001 - shard_100 | |
DO $shards$ | |
BEGIN | |
FOR i IN 1..100 LOOP | |
DECLARE shardID TEXT := CONCAT('shard_', to_char(i, 'FM000')); | |
EXECUTE 'CREATE SCHEMA IF NOT EXISTS $1 AUTHORIZATION iflix;' | |
INTO c USING shardID; | |
END LOOP; | |
END $shards$; |
{ '0': 92, | |
'1': 86, | |
'2': 114, | |
'3': 104, | |
'4': 94, | |
'5': 98, | |
'6': 91, | |
'7': 104, | |
'8': 106, | |
'9': 94, |
var path = require('path'); | |
var fs = require('fs'); | |
module.exports = function(context) { | |
this.cachable(true); | |
//this.addDependency(path); | |
} | |
module.exports.pitch = function(remainingRequest, precedingRequest, data) { | |
var self = this; |
<div> | |
<div class='list'> | |
<div class='item'>abc</div> | |
<div class='item'>abc</div> | |
<div class='item'>abc</div> | |
<div class='item'>abc</div> | |
</div> | |
<img src='http://google.com/logo.png'/> | |
</div> |