-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shichaoyang
committed
Sep 26, 2024
1 parent
805eefc
commit abc0738
Showing
4 changed files
with
70 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 66 additions & 66 deletions
132
...grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/ClusterDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
/* | ||
* Copyright © ${year} ${owner} (${email}) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.jd.live.agent.plugin.router.gprc.definition; | ||
|
||
import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; | ||
//import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; | ||
//import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; | ||
import com.jd.live.agent.core.extension.annotation.Extension; | ||
import com.jd.live.agent.core.inject.annotation.Inject; | ||
import com.jd.live.agent.core.inject.annotation.Injectable; | ||
import com.jd.live.agent.core.parser.ObjectParser; | ||
import com.jd.live.agent.core.plugin.definition.InterceptorDefinition; | ||
import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; | ||
import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; | ||
//import com.jd.live.agent.governance.config.GovernanceConfig; | ||
import com.jd.live.agent.governance.invoke.InvocationContext; | ||
import com.jd.live.agent.plugin.router.gprc.interceptor.ClusterInterceptor; | ||
|
||
@Injectable | ||
@Extension(value = "GrpcClusterDefinition") | ||
//@ConditionalOnProperty(name = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) | ||
//@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SOFARPC_ENABLED, matchIfMissing = true) | ||
//@ConditionalOnClass(ClusterDefinition.TYPE_ABSTRACT_CLUSTER) | ||
public class ClusterDefinition extends PluginDefinitionAdapter { | ||
|
||
protected static final String TYPE_ABSTRACT_CLUSTER = "com.alipay.sofa.rpc.client.AbstractCluster"; | ||
|
||
private static final String METHOD_DO_INVOKE = "doInvoke"; | ||
|
||
private static final String[] ARGUMENT_DO_INVOKE = new String[]{ | ||
"com.alipay.sofa.rpc.core.request.SofaRequest" | ||
}; | ||
|
||
@Inject(InvocationContext.COMPONENT_INVOCATION_CONTEXT) | ||
private InvocationContext context; | ||
|
||
@Inject(ObjectParser.JSON) | ||
private ObjectParser parser; | ||
|
||
public ClusterDefinition() { | ||
System.out.println("----> ClusterDefinition"); | ||
this.matcher = () -> MatcherBuilder.isSubTypeOf(TYPE_ABSTRACT_CLUSTER) | ||
.and(MatcherBuilder.not(MatcherBuilder.isAbstract())); | ||
this.interceptors = new InterceptorDefinition[]{ | ||
new InterceptorDefinitionAdapter( | ||
MatcherBuilder.named(METHOD_DO_INVOKE) | ||
.and(MatcherBuilder.arguments(ARGUMENT_DO_INVOKE)), | ||
() -> new ClusterInterceptor(context, parser) | ||
) | ||
}; | ||
} | ||
|
||
} | ||
///* | ||
// * Copyright © ${year} ${owner} (${email}) | ||
// * | ||
// * Licensed under the Apache License, Version 2.0 (the "License"); | ||
// * you may not use this file except in compliance with the License. | ||
// * You may obtain a copy of the License at | ||
// * | ||
// * http://www.apache.org/licenses/LICENSE-2.0 | ||
// * | ||
// * Unless required by applicable law or agreed to in writing, software | ||
// * distributed under the License is distributed on an "AS IS" BASIS, | ||
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// * See the License for the specific language governing permissions and | ||
// * limitations under the License. | ||
// */ | ||
//package com.jd.live.agent.plugin.router.gprc.definition; | ||
// | ||
//import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; | ||
////import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; | ||
////import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; | ||
//import com.jd.live.agent.core.extension.annotation.Extension; | ||
//import com.jd.live.agent.core.inject.annotation.Inject; | ||
//import com.jd.live.agent.core.inject.annotation.Injectable; | ||
//import com.jd.live.agent.core.parser.ObjectParser; | ||
//import com.jd.live.agent.core.plugin.definition.InterceptorDefinition; | ||
//import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; | ||
//import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; | ||
////import com.jd.live.agent.governance.config.GovernanceConfig; | ||
//import com.jd.live.agent.governance.invoke.InvocationContext; | ||
//import com.jd.live.agent.plugin.router.gprc.interceptor.ClusterInterceptor; | ||
// | ||
//@Injectable | ||
//@Extension(value = "GrpcClusterDefinition") | ||
////@ConditionalOnProperty(name = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) | ||
////@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SOFARPC_ENABLED, matchIfMissing = true) | ||
////@ConditionalOnClass(ClusterDefinition.TYPE_ABSTRACT_CLUSTER) | ||
//public class ClusterDefinition extends PluginDefinitionAdapter { | ||
// | ||
// protected static final String TYPE_ABSTRACT_CLUSTER = "com.alipay.sofa.rpc.client.AbstractCluster"; | ||
// | ||
// private static final String METHOD_DO_INVOKE = "doInvoke"; | ||
// | ||
// private static final String[] ARGUMENT_DO_INVOKE = new String[]{ | ||
// "com.alipay.sofa.rpc.core.request.SofaRequest" | ||
// }; | ||
// | ||
// @Inject(InvocationContext.COMPONENT_INVOCATION_CONTEXT) | ||
// private InvocationContext context; | ||
// | ||
// @Inject(ObjectParser.JSON) | ||
// private ObjectParser parser; | ||
// | ||
// public ClusterDefinition() { | ||
// System.out.println("----> ClusterDefinition"); | ||
// this.matcher = () -> MatcherBuilder.isSubTypeOf(TYPE_ABSTRACT_CLUSTER) | ||
// .and(MatcherBuilder.not(MatcherBuilder.isAbstract())); | ||
// this.interceptors = new InterceptorDefinition[]{ | ||
// new InterceptorDefinitionAdapter( | ||
// MatcherBuilder.named(METHOD_DO_INVOKE) | ||
// .and(MatcherBuilder.arguments(ARGUMENT_DO_INVOKE)), | ||
// () -> new ClusterInterceptor(context, parser) | ||
// ) | ||
// }; | ||
// } | ||
// | ||
//} |
2 changes: 1 addition & 1 deletion
2
...ain/resources/META-INF/services/com.jd.live.agent.core.plugin.definition.PluginDefinition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
com.jd.live.agent.plugin.router.gprc.definition.ClusterDefinition | ||
#com.jd.live.agent.plugin.router.gprc.definition.ClusterDefinition | ||
com.jd.live.agent.plugin.router.gprc.definition.GrpcClientCallDefinition |