Hprose 中间件 - 执行顺序

优质
小牛编辑
134浏览
2023-12-01

Hprose 中间件的顺序执行是按照添加的前后顺序执行的,假设添加的中间件处理器分别为:handler1, handler2handlerN,那幺执行顺序就是 handler1, handler2handlerN

不同类型的 Hprose 中间件和 Hprose 其它过程的执行流程如下图所示:

  1. +------------------------------------------------------------------+
  2. | +-----------------batch invoke----------------+ |
  3. | +------+ | +-----+ +------+ +------+ +-----+ | |
  4. | |invoke| | |begin| |invoke| ... |invoke| | end | | |
  5. | +------+ | +-----+ +------+ +------+ +-----+ | |
  6. | ^ +---------------------------------------------+ |
  7. | | ^ |
  8. | | | |
  9. | v v |
  10. | +-------------------+ +------------------+ |
  11. | | invoke middleware | | batch middleware | |
  12. | +-------------------+ +------------------+ |
  13. | ^ ^ |
  14. | | +---------------+ | |
  15. | +---->| encode/decode |<-----+ |
  16. | +---------------+ |
  17. | ^ |
  18. | | |
  19. | v |
  20. | +--------------------------+ |
  21. | | before filter middleware | |
  22. | +--------------------------+ |
  23. | ^ |
  24. | | _ _ ___ ____ ____ ____ ____ |
  25. | v |__| |__] |__/ | | [__ |___ |
  26. | +--------+ | | | | \ |__| ___] |___ |
  27. | | filter | |
  28. | +--------+ ____ _ _ ____ _ _ ___ |
  29. | ^ | | | |___ |\ | | |
  30. | | |___ |___ | |___ | \| | |
  31. | v |
  32. | +-------------------------+ |
  33. | | after filter middleware | |
  34. | +-------------------------+ |
  35. +------------------------------------------------------------------+
  36. ^
  37. |
  38. |
  39. v
  40. +------------------------------------------------------------------+
  41. | +--------------------------+ |
  42. | | before filter middleware | |
  43. | +--------------------------+ |
  44. | ^ |
  45. | | _ _ ___ ____ ____ ____ ____ |
  46. | v |__| |__] |__/ | | [__ |___ |
  47. | +--------+ | | | | \ |__| ___] |___ |
  48. | | filter | |
  49. | +--------+ ____ ____ ____ _ _ ____ ____ |
  50. | ^ [__ |___ |__/ | | |___ |__/ |
  51. | | ___] |___ | \ \/ |___ | \ |
  52. | v |
  53. | +-------------------------+ |
  54. | | after filter middleware | |
  55. | +-------------------------+ |
  56. | ^ |
  57. | | |
  58. | v |
  59. | +---------------+ |
  60. | +----------->| encode/decode |<---------------------+ |
  61. | | +---------------+ | |
  62. | | | | |
  63. | | | | |
  64. | | v | |
  65. | | +---------------+ | |
  66. | | | before invoke |-------------+ | |
  67. | | +---------------+ | | |
  68. | | | | | |
  69. | | | | | |
  70. | | v v | |
  71. | | +-------------------+ +------------+ | |
  72. | | | invoke middleware |--->| send error |--+ |
  73. | | +-------------------+ +------------+ |
  74. | | | ^ |
  75. | | | | |
  76. | | v | |
  77. | | +--------------+ | |
  78. | | | after invoke |--------------+ |
  79. | | +--------------+ |
  80. | | | |
  81. | | | |
  82. | +--------------------+ |
  83. +------------------------------------------------------------------+