npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

br2k-was

v0.2.2

Published

Replicaiton framework for blockchain application service

Downloads

4

Readme

logo[replace]

[] https://github.com/pinpoint-apm/pinpoint

Replicaiton framework for blockchain application service

About br2k-was

-desc

-goal

  • visiaulizaition png

quick-start

cd YOUR_SERVER_PROJECT
npm install br2k-was

server.js

const app = require('br2k-was')(RUNTIME_CONFIG);

/*--default mode--*/
app.replicate('POST','/user', (req,res)=>{
  //request process
  //return -1 (IF.failed)
});

app.onlyOnce('GET','/user',(req,res)=>{
  //process request
});

/*--[special case] rollback mode--*/
app.replicate('POST', '/user', (req,res)=>{
  //process request
  //return -1 (IF.failed) 
}).backupState(req=>{
  //define state(object)
  return state
}).rollback(state=>{
  //define rollback process with state(object)
});

app.onlyOnce('GET','/user',(req,res)=>{
  //process request
  //return -1 (IF.failed) 
});

/*--multi request mode--*/
// ex) replication reqeust + onlyOnce request
app.replicate('POST','/user', (req,res)=>{
  if(app.isLeader(req){
    //here!!: replicate request area
  }else{
    //here!!: onlyOnce request area
  }
  //process request
  //return -1 (IF.failed)
});

Overview

-express github

Supported Modules

runtime-configuration

{
  service-registry (obj),
  webpack-config (obj),
  state-config (obj)
}

service-registry

{
  type: 'ethereum' or 'klaytn' or 'test'
  id: 'service-id',
  access-perm: object
}

//IF type: 'test', access-perm: {}
//IF type: 'klaytn', access-perm
{
  endpoint: 'klaytn test net access point'
  account: '0xaB3ffd...xdf',
  private-key: '???',
  password: '???',
  contract: {
    json-interface-path: , //json file-> content abi --> []
    addresss: 
  }
}

//IF type: 'ethereum', access-perm
{
  endpoint: 'etheruem access-point'
  account: '0xaB3ffd...xdf',
  private-key: '???',
  password: '???',
  contract: {
    json-interface-path: , //json file-> content abi --> []
    addresss: 
  }
}

state-config

{
  'version-up-size': (option, default=50000)
  'state-path': PROJECT_PATH/state, (option, default)
  'max-state-version': 10, (option, default)
  'state-mode': 'default' or 'rollback' (option),
  'backup-storage-type': 'mysql',
  'backup-storage-auth': {
    host: '',
    user: '',
    password: ''
    database: ''
  }
}

backup storage: mysql

backup-log format in service registry

{
    "start": "",
    "end": "",
    "version": 5, //state-version
    "members": [],
    "alive-members": [],
    "etcd-snapshot-size": "",  //byte
    "service-state-size": "",  //byte
    "storage":{
        "host": "",
        "database": "",
        "user": "",
        "password": "",
        "backup-access-key": " "
    },
    "subject": "scv-id"
}

//example
{
  start: '2021-5-22 2:49:57:804',
  end: '2021-5-22 2:49:59:843',
  version: 3,
  services: '2',
  'alive-services': '2',
  'etcd-snapshot-size': 25890912,
  'service-state-size': 305,
  storage: {
    host: '203.250.77.152',
    user: 'minho',
    password: 'pslab',
    database: 'backup',
    'backup-access-key': '680f3bcce5444adb1b5c67297a031746'
  },
  subject: '13803658152347727308'
}

Setting

1. Run mysql db in docker

/*-- simple example --*/
docker run --name mysql-db -v /tmp/myown/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=backup -e MYSQL_USER=minho -e MYSQL_PASSWORD=pslab --restart=always -p 3306:3306 -p 8080:8080 -d mysql

2. create tables

mysql ---password=ROOT_PASSWORD
mysql> use backup;

mysql>
-- router Table Create SQL
CREATE TABLE router
(
    `index`        INT            NOT NULL AUTO_INCREMENT COMMENT '인덱스',
    `id`           VARCHAR(45)    NOT NULL COMMENT '액세스 키',
    `state_id`     VARCHAR(45)    NOT NULL,
    `snapshot_id`  VARCHAR(45)    NOT NULL,
    PRIMARY KEY (`index`,`id`)
);

ALTER TABLE router COMMENT 'router';


-- router Table Create SQL
CREATE TABLE states
(
    `id`        VARCHAR(45)    NOT NULL    COMMENT 'id',
    `chunk_id`  INT            NOT NULL    COMMENT '청크 아이디',
    `data`      LONGBLOB       NOT NULL    COMMENT '청크 데이터'
);

ALTER TABLE states COMMENT 'states';

ALTER TABLE states
    ADD CONSTRAINT FK_states_id_router_state_id FOREIGN KEY (id)
        REFERENCES router (state_id) ON DELETE RESTRICT ON UPDATE RESTRICT;


-- router Table Create SQL
CREATE TABLE snapshot
(
    `id`        VARCHAR(45)    NOT NULL    COMMENT 'id',
    `chunk_id`  INT            NULL        COMMENT '청크 아이디',
    `data`      LONGBLOB       NULL        COMMENT '청크 데이터'
);

ALTER TABLE snapshot
    ADD CONSTRAINT FK_snapshot_id_router_snapshot_id FOREIGN KEY (id)
        REFERENCES router (snapshot_id) ON DELETE RESTRICT ON UPDATE RESTRICT;

Error: ER_NOT_SUPPORTED_AUTH_MODE

Node.js의 Express에서 mysql미들웨어를 이용해서 원격연결

mysql> use mysql;

mysql> alter user 'userName'@'%' identified with mysql_native_password by 'userPassword';

mysql> FLUSH PRIVILEGES;

br2k request info

br2k request object

  • entryIndex:
  • subject: { id, index }
app.replicate('POST','/user', (req,res)=>{
  const subjectID = req.br2k.subject.id
  const subjectIndex = req.br2k.subject.index;
  const entryIndex = req.br2k.entryIndex;
});

check list

1. State folder permission

chmod -R 766 PROJECT_ROOT_PATH/state

related paper

br2k link

dev-env

nodejs: v14.15.3

npm: 7.10.0

etcd: v3.2

core npm modules:

  • express: 4.17.1
  • web3: 1.3.6 //ethereum client
  • etcd3: 1.0.1