0.4.5 • Published 5 years ago

short-interval-control-infrastructure-sequelize-rabbit v0.4.5

Weekly downloads
3
License
MIT
Repository
gitlab
Last release
5 years ago

Short-Interval-Control-Infrastructure Library Sequelize and Rabbit MQ

About

This library provides an API contract between a short interval control data processing pipeline and infrastructure which provides state and messaging functionality to the processing pipeline. npm.io

Install

npm install short-interval-control-infrastructure-sql-rabbit
yarn install short-interval-control-infrastructure-sql-rabbit

How to use

Describe the configuration required

// Sequelize Sql Server Dialect configuration
let sqlOptions = {
    health: "SELECT DB_NAME() AS DatabaseName, DATABASEPROPERTYEX('master', 'Status') AS DBStatus",
    host: "localhost",
    dialect: 'mssql',
    operatorsAliases: false,
    define: { freezeTableName: true },
    pool: { max: 5, min: 0, acquire: 30000, idle: 10000 },
    logging: true
  }


let config = {
  storage: {
      sync: false,
      host: 'localhost',
      database: 'powerview',
      username: 'sa',
      password: 'password',
      // logging: x=>x,
      logging: true,
      schema: 'dbo',
      options: sqlOptions
  },
  broker: {
      host: '192.168.56.20',
      port: 5672,
      username: 'guest',
      password: 'guest'
  },
  in: {
    exchange: { name: 'Test.In.Exchange' },
    queue: { name: 'queue'},
    routingKey: {name: 'Key'}
  },
  out: {
    exchange: { name: 'Test.Out.Exchange' }
  }
}

Define your sequelize db model

let model = {
    Model: (connector)=>{
        getSomething () {
            return connector.something.findAll({})
        }
    },
    Connector: (config,connectionPool)=>{
        const someTable = db.define(
        'some_table', {
          index: { type: Sequelize.INTEGER, primaryKey: true },
          description: { type: Sequelize.STRING }
        },
        { createdAt: false, updatedAt: false, schema: config.schema })
    }
}

Build the infrastructure

const infrastructureFactory = await infrastructureGenerator(config,model)
const infrastructure = await infrastructureFactory()

The infrastructure provides the following api.

{
    checkHealth, //used to check the sql and message broker are operating successfully
    state: {
        dbModel // entity which provides the db model functions you have provided
    },
    messaging: {
        publisher, // used to publish messages
        createConsumer, // used to create message consumer
    },
    close // used to shut down the infrastructure
}
0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago