Using Visitor pattern to decouple the Selector and Rule from doExecute() method.
Feature Request
Due to the basic data structure in Soul(Selector, Rule) are stable and immune to change, visitor design pattern is very suitable for this scenario, and different Plugins play roles as Visitor, providing different visit method implementation. I plan to use this pattern to decouple the Selector and Rule from doExecute() method, and Improve the expansibility of program。
Example in divide plugin
public Mono
// rewriting example
selectorData.accept(this);
rule.accept(this);
return doExecute(exchange,chain);
.....
}
good
@lmhmhl Is this mission in progress? you can join us in weixin group
@lmhmhl Is this mission in progress? you can join us in weixin group
how join,i want join
@lmhmhl Is this mission in progress? you can join us in weixin group
Hello, I have tried to refractor the code, but some new questions occurred, when I decouple the rule and selector in doExecute method, and invoke visit() method in every single plugin to visit selector and rule, I suddenly aware that some thread-safe problem may happen, because visit() and doExecute() are different method, and visit method return void, when some visit operation happpens in visit, It should keep a global variable to pass the selector and rule in doExecute method doing message passing, I come up with a solution that we can use ThreadLocal variable to store selector and rule and can be passed to deExecute() method, but It is not so elegant, so I stuck there for a long time, I will be very happy if you can offer me some advices. Thx. @yu199195 @yangzhiw
If it's hard to change or if you don't understand how it works, don't do it
This senerio is suitable for visitor, may be u can add a discuss to gather more solutions.
@yangzhiw Can you leave your wechat here? I can invite you to join. : )
@yangzhiw Can you leave your wechat here? I can invite you to join. : )
lmh8899000 thx.
@yangzhiw Can you leave your wechat here? I can invite you to join. : ) wechat: juzi222666
thx!
No progress. Closing it and please feel free to reopen it if you have any question.