-
Notifications
You must be signed in to change notification settings - Fork 435
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
[SCB-1128] Omega discovers alpha service from eureka #394
Conversation
@@ -0,0 +1,9 @@ | |||
info: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need the license header, please take the application.yaml as an example.
* to pass the transactions id across the application. | ||
* @see OmegaContext | ||
*/ | ||
public @interface EnableOmegaSpringCloud { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already has the EnableOmega, so I don't think we need to add this annotation here.
We may need to find a way to enable the service discovery by looking up the configuration atomatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can use spring.factories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can let SpringFactoriesLoader automatically configure OmegaSpringConfig through spring.factories, so @EnableOmega is not needed
|
||
@Bean(name = {"alphaClusterEurekaConfig"}) | ||
@ConditionalOnProperty(name = "alpha.cluster.register.type", havingValue = "spring-cloud") | ||
AlphaClusterConfig alphaClusterEurekaConfig( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to find a way to reuse the old configuration, it could be in our todo list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe define an object AlphaClusterAddress, Attribute contains Alpha's address, registry center information...
Add AlphaClusterAddress to the parameters of AlphaClusterConfig
AlphaClusterConfig alphaClusterConfig(
@Value("${alpha.cluster.address:localhost:8080}") String[] addresses,
@Value("${alpha.cluster.ssl.enable:false}") boolean enableSSL,
@Value("${alpha.cluster.ssl.mutualAuth:false}") boolean mutualAuth,
@Value("${alpha.cluster.ssl.cert:client.crt}") String cert,
@Value("${alpha.cluster.ssl.key:client.pem}") String key,
@Value("${alpha.cluster.ssl.certChain:ca.crt}") String certChain,
@Lazy AlphaClusterAddress alphaClusterAddress,
@Lazy MessageHandler handler,
@Lazy TccMessageHandler tccMessageHandler) {
...
}
Define an default AlphaClusterAddress Bean in OmegaSpringConfig,it's Null
Define an default AlphaClusterAddress Bean in OmegaSpringEurekaConfig,it's from Eureka
use this AlphaClusterAddress if it is not empty, otherwise use the default ${alpha.cluster.address address}
@WillemJiang I reconstructed the code according to your idea |
MessageFormat messageFormat = new KryoMessageFormat(); | ||
AlphaClusterConfig clusterConfig = AlphaClusterConfig.builder() | ||
.addresses(ImmutableList.copyOf(addresses)) | ||
.addresses(ImmutableList.copyOf(alphaClusterDiscovery.getAddresses())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we implement the dynamic address lookup? I think we need to add the alphaClusterDiscovery address here.
Get the access address of Alpah Server from Eureka Server
Turn this feautre on by set alpha.cluster.register.type=spring-cloud
First omega gets the Alpha address from Eureka with ${alpha.cluster.serviceId}
If omega can't get it in Eureka then use ${alpha.cluster.address}
Add dependencie
About AutoConfiguration
Deprecated @EnableOmega
Add Alpha configuration to the application.yml
alpha.cluster.serviceId=servicecomb-alpha-server
alpha.cluster.register.type=spring-cloud
Add Eureka Client configuration to the application.yml