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

Custom serializer register #1296

Merged
merged 12 commits into from
Apr 12, 2023
Merged

Conversation

Lo1nt
Copy link
Collaborator

@Lo1nt Lo1nt commented Feb 9, 2023

Motivation:

Currently, the custom serializer is registered by static code block. And once it registered, it could not be modified.

When there are several classes that register custom serializer, the sequence, dependents on sequence of class loading, is unpredictable, and unmodifiable.

Thus, there's no way we define our own serializer (say, for SofaRequest.Class).

The pr here is aiming at making custom serializer registration sequentially.

P.S. And we here still don't want to change the unmodifiable feature (Once a serializer registered, it can never be changed).

Modification:

Apply extension-loader mechanism to let the register work in sequence.

Still, there is an override feature for extension loader, which enables us to substitute the origin register provided by sofa rpc.

Result:

  1. Let all register become instance managed by ExtensionLoader.
  2. Change call to static register method to get Extension instance and then call instances' register method.

@Lo1nt Lo1nt changed the title Dev serializer register Custom serializer register Feb 9, 2023
@sofastack-bot sofastack-bot bot added cla:yes CLA is ok size/L and removed size/L labels Feb 9, 2023
@codecov
Copy link

codecov bot commented Feb 9, 2023

Codecov Report

Merging #1296 (66cae3f) into master (a9af9cd) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #1296      +/-   ##
============================================
- Coverage     71.95%   71.95%   -0.01%     
+ Complexity      784      783       -1     
============================================
  Files           415      416       +1     
  Lines         17654    17659       +5     
  Branches       2752     2752              
============================================
+ Hits          12703    12706       +3     
  Misses         3549     3549              
- Partials       1402     1404       +2     
Impacted Files Coverage Δ
...in/java/com/alipay/sofa/rpc/common/RpcOptions.java 100.00% <ø> (ø)
.../rpc/codec/bolt/AbstractSerializationRegister.java 100.00% <100.00%> (ø)
...a/rpc/codec/bolt/SofaRpcSerializationRegister.java 81.81% <100.00%> (+9.09%) ⬆️
...ipay/sofa/rpc/server/bolt/BoltServerProcessor.java 65.33% <100.00%> (+0.46%) ⬆️
...y/sofa/rpc/transport/bolt/BoltClientTransport.java 85.88% <100.00%> (+0.17%) ⬆️

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Lo1nt Lo1nt force-pushed the dev_serializer_register branch from 277eee9 to a093a33 Compare February 10, 2023 07:23
@Lo1nt Lo1nt added this to the 5.10.0 milestone Feb 22, 2023
@@ -69,7 +72,10 @@ public class BoltServerProcessor extends AsyncUserProcessor<SofaRequest> {
* 提前注册序列化器
*/
static {
SofaRpcSerializationRegister.registerCustomSerializer();
String extensionAlias = RpcConfigs.getOrDefaultValue(RpcOptions.BOLT_SERIALIZER_REGISTER_EXTENSION,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these static code can remove into constructor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is designed here as:

  1. To do the register at same time as before.
  2. Get config and load extension once.
  3. Clarify it as ACTION belong to the BoltServerProcessor class, not only to a single BoltServerProcessor instance.

@Lo1nt Lo1nt requested review from EvenLjj and OrezzerO April 11, 2023 09:13
Copy link
Collaborator

@EvenLjj EvenLjj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@chuailiwu chuailiwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Collaborator

@leslieSll leslieSll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EvenLjj EvenLjj merged commit 5a0c0f7 into sofastack:master Apr 12, 2023
Lo1nt added a commit that referenced this pull request Jun 20, 2023
* Modify the parsing header method to facilitate expansion (#1325)

Co-authored-by: liujianjun.ljj <liujianjun.ljj@antgroup.com>

* feat: let use of javassist compatible at jdk 17 (#1316)

Co-authored-by: junyuan <zhangminglun.zml@ant-group.com>

* upgrade rpc version to 5.10.0-SNAPSHOT (#1326)

* upgrade rpc version to 5.10.0-SNAPSHOT

* upgrade rpc version to 5.10.0-SNAPSHOT

---------

Co-authored-by: liujianjun.ljj <liujianjun.ljj@antgroup.com>

* Custom serializer register (#1296)

* feat: use extension on serializer register
---------

Co-authored-by: 均源 <zhangminglun.zml@antgroup.com>
Co-authored-by: junyuan <zhangminglun.zml@ant-group.com>

* chore: update version to release (#1328)

Co-authored-by: lo1nt <zhangminglun.zml@ant-group.com>

* upgrade rpc version to 5.10.1-SNAPSHOT (#1334)

Co-authored-by: liujianjun.ljj <liujianjun.ljj@antgroup.com>

* support change grpc maxInboundMessageSize (#1333)

Co-authored-by: liujianjun.ljj <liujianjun.ljj@antgroup.com>

* Fix the unit test message too large problem (#1339)

* support change grpc maxInboundMessageSize

* fix the debug body message too large problem

---------

Co-authored-by: liujianjun.ljj <liujianjun.ljj@antgroup.com>

* feat: bump hessian from 3.13.3 to 3.4.0 (#1338)

Co-authored-by: Lo1nt <zhangminglun.zml@antgroup.com>

* updapte 5.10.1 version to release (#1337)

Co-authored-by: Lo1nt <zhangminglun.zml@antgroup.com>

* update version

* bump hessian

* update version

* add ci

* set verison as 51100

* fix: destory

* fix: unit test

---------

Co-authored-by: evenliu <evenljj@163.com>
Co-authored-by: liujianjun.ljj <liujianjun.ljj@antgroup.com>
Co-authored-by: lo1nt <zhangminglun.zml@ant-group.com>
Co-authored-by: lo1nt <zhangminglun.zml@antgroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants