Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke request interface #291

Merged
merged 5 commits into from
Mar 22, 2024
Merged

Conversation

koriym
Copy link
Member

@koriym koriym commented Mar 19, 2024

ResourceObjects that are called to execute resources (calls to onGet methods, etc.), which were done by Invoker, will be passed Invoker to do so. This is the same as the current Transfer mechanism and enhances object autonomy in object-oriented programming.

The benefits gained are

The if statement that used to determine whether an object was an HTTP request object (HttpResourceObject) or a PHP ResourceObject on the Invoker side is eliminated, and resources other than HTTP and PHP method calls can be handled. You can open extensions and close changes for new resources like BEAR.Thrift.

Other extras.

  1. You can also write the processing before and after the execution of an object on the ResourceObject side, like AOP.
  2. You can also replace it with your own Invoker.

Invokerが行っていたリソースの実行(onGetメソッドなどの呼び出し)を呼ばれたResourceObjectがInvokerを渡してもらって、実行するようにします。現在のTransferの仕組みと同じでオブジェクト指向においてのオブジェクトの自律を強化します。

得られるメリットは

従来Invoker側でHTTPリクエストオブジェクト(HttpResourceObject)なのか、PHPのResourceObjectなのかを判断していたif文を取り除き、HTTPやPHPのメソッドコール以外のリソースも対応できます。BEAR.Thriftのような新しいリソースに対して拡張を開き、変更を閉じることができます。

他におまけで

  1. AOPのようにオブジェクトの実行の前後の処理をResourceObject側に記述することもできる。
  2. 自身のInvokerに差し替えることもできる

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (4249268) to head (9466722).

❗ Current head 9466722 differs from pull request most recent head 04a9614. Consider uploading reports for the commit 04a9614 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##                 1.x      #291   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       498       500    +2     
===========================================
  Files             82        83    +1     
  Lines           1327      1333    +6     
===========================================
+ Hits            1327      1333    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@koriym koriym requested a review from NaokiTsuchiya March 19, 2024 02:20
keep request() method as it was.
@koriym koriym requested a review from NaokiTsuchiya March 22, 2024 05:59
@koriym koriym merged commit d5e21c0 into bearsunday:1.x Mar 22, 2024
7 of 8 checks passed
@koriym koriym deleted the InvokeRequestInterface branch March 22, 2024 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants