basic-interceptor.js 779 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Basic Interceptor class
  3. */
  4. export 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<any>}
  35. */
  36. process(contextName, ...args) {
  37. // override this
  38. return Promise.resolve(...args);
  39. }
  40. }