# short-interval-control-infrastructure-sequelize-rabbit

> A library providing connectivity to sql state and rabbit mq messaging infrastructure

Latest version **0.4.5** (published 2019-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install short-interval-control-infrastructure-sequelize-rabbit
pnpm add short-interval-control-infrastructure-sequelize-rabbit
yarn add short-interval-control-infrastructure-sequelize-rabbit
bun add short-interval-control-infrastructure-sequelize-rabbit
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.5 |
| Published | 2019-09-13 |
| First published | 2019-07-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 257.8 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | Quartile One |
| Maintainers | philxceptionale |

## Links

- npm: https://www.npmjs.com/package/short-interval-control-infrastructure-sequelize-rabbit
- Repository: https://gitlab.com/
- npm.io page: https://npm.io/package/short-interval-control-infrastructure-sequelize-rabbit

## Dependencies (5)

- [amqp](https://npm.io/package/amqp.md) ^0.2.6
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [mssql](https://npm.io/package/mssql.md) ^4.1.0
- [sequelize](https://npm.io/package/sequelize.md) ^4.37.6
- [short-interval-control-archetype-lib-component](https://npm.io/package/short-interval-control-archetype-lib-component.md) ^1.0.5

## Recent versions

- 0.4.5 (latest) — 2019-09-13
- 0.4.4 — 2019-09-13
- 0.4.3 — 2019-09-13
- 0.4.1 — 2019-08-29
- 0.4.0 — 2019-08-29
- 0.3.5 — 2019-08-15
- 0.3.4 — 2019-08-13
- 0.3.3 — 2019-08-12
- 0.3.2 — 2019-08-12
- 0.3.1 — 2019-08-07
- 0.3.0 — 2019-08-07
- 0.2.2 — 2019-08-06
- 0.2.1 — 2019-08-06
- 0.2.0 — 2019-08-05
- 0.1.1 — 2019-07-28
- … 1 more at https://npm.io/package/short-interval-control-infrastructure-sequelize-rabbit/versions

## README

# 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.
![](./images/overview.PNG)

## 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
}
```

---
_Source: https://npm.io/package/short-interval-control-infrastructure-sequelize-rabbit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
