Skip to content

Commit

Permalink
add preferred protocol support
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj committed May 11, 2024
1 parent e68b4b8 commit 5c97bdd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public interface CommonConstants {

String EXT_PROTOCOL = "ext.protocol";

String PRIORITIZED_PROTOCOL = "prioritized.protocol";
String PREFERRED_PROTOCOL = "preferred.protocol";

String IS_EXTRA = "isExtra";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public class ProtocolConfig extends AbstractConfig {
*/
private String extProtocol;

private String preferredProtocol;

/**
* JSON check level for serialization.
*/
Expand Down Expand Up @@ -621,6 +623,14 @@ public void setExtProtocol(String extProtocol) {
this.extProtocol = extProtocol;
}

public String getPreferredProtocol() {
return preferredProtocol;
}

public void setPreferredProtocol(String preferredProtocol) {
this.preferredProtocol = preferredProtocol;
}

public void mergeProtocol(ProtocolConfig sourceConfig) {
if (sourceConfig == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ public <T extends AbstractConfig> List<T> loadConfigsOfTypeFromProps(Class<T> cl
config.refresh();
} catch (Exception e) {
throw new IllegalStateException(
"create default config instance failed, type:" + cls.getSimpleName());
"create default config instance failed, type:" + cls.getSimpleName(), e);
}

this.addConfig(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,11 @@
<xsd:documentation><![CDATA[ Is SSL enabled. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="preferred-protocol" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ Tell consumer the preferred protocol to consume. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:complexType>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,11 @@
<xsd:documentation><![CDATA[ Is SSL enabled. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="preferred-protocol" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ Tell consumer the preferred protocol to consume. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:complexType>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.EXT_PROTOCOL;
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_REGISTER_MODE;
import static org.apache.dubbo.common.constants.CommonConstants.PRIORITIZED_PROTOCOL;
import static org.apache.dubbo.common.constants.CommonConstants.PREFERRED_PROTOCOL;
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_INIT_SERIALIZATION_OPTIMIZER;
Expand Down Expand Up @@ -516,7 +516,7 @@ private Map<URL, Invoker<T>> toInvokers(Map<URL, Invoker<T>> oldUrlInvokerMap, L
*/
private String getEffectiveProtocol(String queryProtocols, URL url) {
String protocol = url.getProtocol();
String prioritizedProtocol = url.getParameter(PRIORITIZED_PROTOCOL, protocol);
String prioritizedProtocol = url.getParameter(PREFERRED_PROTOCOL, protocol);

String effectiveProtocol = prioritizedProtocol;

Expand Down

0 comments on commit 5c97bdd

Please sign in to comment.