author SunMyeong Lee <actumn814@gmail.com>
  import { CeleryConf , defaultConf } from "./conf" ; import { newCeleryBroker , CeleryBroker } from "../kombu/brokers" ; import { newCeleryBackend , CeleryBackend } from "../backends" ; export default class Base { private _backend : CeleryBackend ; private _broker : CeleryBroker ; conf : CeleryConf ; constructor constructor ( broker , backend , queue = "celery" ) { this . conf = defaultConf ( ) ; this . conf . CELERY_BROKER = broker ; this . conf . CELERY_BACKEND = backend ; this . conf . CELERY_QUEUE = queue ; } get broker ( ) : CeleryBroker { if ( ! this . _broker ) { this . _broker = newCeleryBroker ( this . conf . CELERY_BROKER , this . conf . CELERY_BROKER_OPTIONS , this . conf . CELERY_QUEUE ) ; } return this . _broker ; } get backend ( ) : CeleryBackend { if ( ! this . _backend ) { this . _backend = newCeleryBackend ( this . conf . CELERY_BACKEND , this . conf . CELERY_BACKEND_OPTIONS ) ; } return this . _backend ; } method returns { Promise } public isReady ( ) { return Promise . all ( [ this . backend . isReady ( ) , this . broker . isReady ( ) ] ) ; } method returns { Promise } public disconnect ( ) { return this . broker . disconnect ( ) . then ( ( ) => this . backend . disconnect ( ) ) ; } }