# @transomjs/transom-scheduler

> A Transom job scheduler that emits events rather than processes the jobs

Latest version **1.0.1** (published 2021-02-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @transomjs/transom-scheduler
pnpm add @transomjs/transom-scheduler
yarn add @transomjs/transom-scheduler
bun add @transomjs/transom-scheduler
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-02-23 |
| First published | 2021-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Wiebo Troost |
| Maintainers | binaryops.mark, binaryops.wiebo |
| Keywords | transom, TransomJS, job, scheduler, event |

## Links

- npm: https://www.npmjs.com/package/@transomjs/transom-scheduler
- Repository: https://github.com/transomjs/transom-scheduler
- Homepage: https://github.com/transomjs/transom-scheduler#readme
- Issues: https://github.com/transomjs/transom-scheduler/issues
- npm.io page: https://npm.io/package/@transomjs/transom-scheduler

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.3.1
- [simple-event-scheduler](https://npm.io/package/simple-event-scheduler.md) ^1.1.2

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-02-23
- 1.0.0 — 2021-02-22
- 0.5.3 — 2021-02-22
- 0.5.2 — 2021-02-22
- 0.5.1 — 2021-02-22

## README

# Transom Scheduler

A Transom Plugin wrapper around the Simple Event Scheduler. A convenient way to add the 
functionality of the [Simple Event Scheduler](https://www.npmjs.com/package/simple-event-scheduler) to the [TransomJS](https://transomjs.github.io/) Landscape.

## Gettings started
You can install the scheduler with npm: `npm install @transomjs/transom-scheduler`.

You'll need to have a database table available for the scheduler to persist the configured jobs.
Here is a sample table:
```
CREATE TABLE `job` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `channel` varchar(255) NOT NULL,
  `active` int NOT NULL,
  `cronexp` varchar(255) NULL,
  `nextRunAt` datetime NULL,
  `intervalSeconds` int NULL,
  `lastRunTime`bigint NOT NULL,
  `startDate` datetime NULL,
  `endDate` datetime NULL,
  PRIMARY KEY (id)
  );
```


# Usage

```
const {TransomScheduler} = require('@transomjs/transom-scheduler');
const Transom = require('@transomjs/transom-core');

const transom = new Transom();
const transomScheduler = new TransomScheduler();

transom.configure(transomSequelize, {
    preMiddleware: []    
});
transom.configure(transomScheduler, {
    jobsTableName:'job'
});

function setupListeners(server){
    const scheduler = server.registry.get('scheduler');

    scheduler.on("jobs", (event) => {
        console.log("Yay, I can handle the event right here!", {event});
    });


    //just a test job, 3 seconds out.
    const d = new Date(new Date().getTime() + 3000);
    scheduler.createOnetimeJob(`onetimer ${d.getTime()}`, d);

    scheduler.start();

}


 transom
    .initialize(apiDefinition)
    .then(function(server) {

        setupListeners(server);
       
        //remainder of the startup here
        ...

    })
    .catch(function(err) {
        console.log('Unable to start the server, exiting');
        console.error(err);
        process.exit(-1);
    });
```

# Need Support?
Transom Scheduler is developed and maintained by [BinaryOps Software Inc.](https://binaryops.ca) in Canada.

---
_Source: https://npm.io/package/@transomjs/transom-scheduler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
