Socket
Socket
Sign inDemoInstall

@eggjs/tegg-schedule-decorator

Package Overview
Dependencies
4
Maintainers
11
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eggjs/tegg-schedule-decorator


Version published
Maintainers
11
Created

Readme

Source

@eggjs/tegg-schedule-decorator

Install

npm i --save @eggjs/tegg-schedule-decorator

Define schedule subscriber

import { Schedule } from '@eggjs/tegg';

// use number to define schedule interval
@Schedule<IntervalParams>({
  type: ScheduleType.WORKER,
  scheduleData: {
    // run every 100ms
    interval: 100,
  },
})
export class FooSubscriber {
  @Inject()
  private readonly logger: EggLogger;

  async subscribe() {
    this.logger.info('schedule called');
  }
}

// use cron to define schedule interval
@Schedule<CronParams>({
  type: ScheduleType.WORKER,
  scheduleData: {
    cron: '0 0 3 * * *',
  },
})
export class FooSubscriber {
  @Inject()
  private readonly logger: EggLogger;

  async subscribe() {
    this.logger.info('schedule called');
  }
}

Keywords

FAQs

Last updated on 24 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc