GithubHelp home page GithubHelp logo

pg-shards-demo's Introduction

Description

Start the containers:

docker-compose up --force-recreate --build -d

Migrations not working yet, the following command is only for reference:

npm run migration:run ./data-source-shard1.ts 

Generate schema manually on each DB instance:

CREATE TABLE "public"."consumption" ( 
	"id" BigSerial NOT NULL,
	"timestamp" Timestamp With Time Zone NOT NULL,
	"source_id" Character Varying NOT NULL,
	"value" Character Varying NOT NULL,
	"description" Character Varying NOT NULL
);

And then populate each DB with some random data:

--INSTANCE 1
insert into consumption (timestamp, source_id, value, description) values (now(), 1, 1.07, 'Taken from instance 1');
insert into consumption (timestamp, source_id, value, description) values (now(), 1, 1.11, 'Taken from instance 1');
insert into consumption (timestamp, source_id, value, description) values (now(), 1, 1.13, 'Taken from instance 1');

--INSTANCE 2
insert into consumption (timestamp, source_id, value, description) values (now(), 2, 1.77, 'Taken from instance 2');
insert into consumption (timestamp, source_id, value, description) values (now(), 2, 1.39, 'Taken from instance 2');
insert into consumption (timestamp, source_id, value, description) values (now(), 2, 1.44, 'Taken from instance 2');

--INSTANCE 3
insert into consumption (timestamp, source_id, value, description) values (now(), 3, 0.15, 'Taken from instance 3');
insert into consumption (timestamp, source_id, value, description) values (now(), 3, 0.16, 'Taken from instance 3');
insert into consumption (timestamp, source_id, value, description) values (now(), 3, 0.18, 'Taken from instance 3');

Endpoint for all agreggated data:

http://localhost:3000/consumption

Endpoint for partitioned data:

http://localhost:3000/consumption/1
http://localhost:3000/consumption/2
http://localhost:3000/consumption/3

pg-shards-demo's People

Contributors

fdbatista avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.