basicInterceptor.js 803 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Basic Interceptor class
  3. */
  4. class BasicInterceptor {
  5. /**
  6. * getter for id
  7. */
  8. getId() {
  9. return this.constructor.name;
  10. }
  11. /**
  12. * return whether this interceptor works by specified contextName
  13. *
  14. * @param {string} contextName
  15. * @return {boolean}
  16. */
  17. isInterceptWhen(contextName) {
  18. // implement this
  19. return false;
  20. }
  21. /**
  22. * return whether this interceptor processes in parallel mode or sequencial mode
  23. * @return {boolean}
  24. */
  25. isProcessableParallel() {
  26. // implement this
  27. return true;
  28. }
  29. /**
  30. * process method
  31. *
  32. * @param {string} contextName
  33. * @param {any} args
  34. * @return {Promise}
  35. */
  36. process(contextName, ...args) {
  37. // override this
  38. return Promise.resolve(...args);
  39. }
  40. }
  41. module.exports = BasicInterceptor;