How to use the egg-core.utils.getCalleeFromStack function in egg-core

To help you get started, we’ve selected a few egg-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eggjs / egg / app / extend / context.js View on Github external
_runInBackground(scope) {
    const ctx = this;
    const start = Date.now();
    /* istanbul ignore next */
    const taskName = scope._name || scope.name || eggUtils.getCalleeFromStack(true);
    // use app.toAsyncFunction to support both generator function and async function
    return ctx.app.toAsyncFunction(scope)(ctx)
      .then(() => {
        ctx.coreLogger.info('[egg:background] task:%s success (%dms)', taskName, Date.now() - start);
      })
      .catch(err => {
        // background task process log
        ctx.coreLogger.info('[egg:background] task:%s fail (%dms)', taskName, Date.now() - start);

        // emit error when promise catch, and set err.runInBackground flag
        err.runInBackground = true;
        ctx.app.emit('error', err, ctx);
      });
  },
};
github eggjs / egg / app / extend / context.js View on Github external
_runInBackground(scope) {
    const ctx = this;
    const start = Date.now();
    /* istanbul ignore next */
    const taskName = scope._name || scope.name || eggUtils.getCalleeFromStack(true);
    // use app.toAsyncFunction to support both generator function and async function
    return ctx.app.toAsyncFunction(scope)(ctx)
      .then(() => {
        ctx.coreLogger.info('[egg:background] task:%s success (%dms)', taskName, Date.now() - start);
      })
      .catch(err => {
        // background task process log
        ctx.coreLogger.info('[egg:background] task:%s fail (%dms)', taskName, Date.now() - start);

        // emit error when promise catch, and set err.runInBackground flag
        err.runInBackground = true;
        ctx.app.emit('error', err, ctx);
      });
  },
};
github eggjs / egg / app / extend / context.js View on Github external
runInBackground(scope) {
    // try to use custom function name first
    /* istanbul ignore next */
    const taskName = scope._name || scope.name || eggUtils.getCalleeFromStack(true);
    scope._name = taskName;
    this._runInBackground(scope);
  },
github eggjs / egg / app / extend / context.js View on Github external
runInBackground(scope) {
    // try to use custom function name first
    /* istanbul ignore next */
    const taskName = scope._name || scope.name || eggUtils.getCalleeFromStack(true);
    scope._name = taskName;
    this._runInBackground(scope);
  },
github eggjs / egg / lib / application.js View on Github external
runInBackground(scope) {
    const ctx = this.createAnonymousContext();
    if (!scope.name) scope._name = eggUtils.getCalleeFromStack(true);
    ctx.runInBackground(scope);
  }

egg-core

A core Pluggable framework based on koa

MIT
Latest version published 4 months ago

Package Health Score

75 / 100
Full package analysis