forked from Linyuzai/concept
-
Notifications
You must be signed in to change notification settings - Fork 0
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
tanghanzheng
committed
Apr 20, 2022
1 parent
73165fb
commit 3e7df74
Showing
10 changed files
with
172 additions
and
1 deletion.
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
28 changes: 28 additions & 0 deletions
28
concept-connection-loadbalance/concept-connection-loadbalance-netty/build.gradle
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
apply from: '../version.gradle' | ||
|
||
group 'com.github.linyuzai' | ||
version "${conceptConnectionLoadbalanceVersion}" | ||
sourceCompatibility = '1.8' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compileOnly project(path: ':concept-connection-loadbalance:concept-connection-loadbalance-core', configuration: 'default') | ||
|
||
compileOnly "io.netty:netty-all:${nettyVersion}" | ||
|
||
compileOnly "org.projectlombok:lombok:${lombokVersion}" | ||
annotationProcessor "org.projectlombok:lombok:${lombokVersion}" | ||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" | ||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}" | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
4 changes: 4 additions & 0 deletions
4
...ava/com/github/linyuzai/connection/loadbalance/netty/concept/NettyLoadBalanceConcept.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.github.linyuzai.connection.loadbalance.netty.concept; | ||
|
||
public class NettyLoadBalanceConcept { | ||
} |
33 changes: 33 additions & 0 deletions
33
...pt-connection-loadbalance/concept-connection-loadbalance-spring-boot-starter/build.gradle
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
apply from: '../version.gradle' | ||
|
||
group 'com.github.linyuzai' | ||
version "${conceptConnectionLoadbalanceVersion}" | ||
sourceCompatibility = '1.8' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
|
||
compileOnly project(':concept-connection-loadbalance:concept-connection-loadbalance-core') | ||
compileOnly project(':concept-connection-loadbalance:concept-connection-loadbalance-discovery') | ||
compileOnly project(':concept-connection-loadbalance:concept-connection-loadbalance-websocket') | ||
|
||
compileOnly "org.springframework.boot:spring-boot-starter:${springBootVersion}" | ||
compileOnly "org.springframework.cloud:spring-cloud-starter:${springCloudVersion}" | ||
compileOnly "org.projectlombok:lombok:${lombokVersion}" | ||
annotationProcessor "org.projectlombok:lombok:${lombokVersion}" | ||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" | ||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}" | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
//apply from: '../publish.gradle' |
17 changes: 17 additions & 0 deletions
17
...i/connection/loadbalance/autoconfigure/websocket/ApplicationConnectionEventPublisher.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.github.linyuzai.connection.loadbalance.autoconfigure.websocket; | ||
|
||
import com.github.linyuzai.connection.loadbalance.core.event.DefaultConnectionEventPublisher; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
|
||
@AllArgsConstructor | ||
public class ApplicationConnectionEventPublisher extends DefaultConnectionEventPublisher { | ||
|
||
private ApplicationEventPublisher publisher; | ||
|
||
@Override | ||
public void publish(Object event) { | ||
super.publish(event); | ||
publisher.publishEvent(event); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...zai/connection/loadbalance/autoconfigure/websocket/EnableWebSocketLoadBalanceConcept.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.linyuzai.connection.loadbalance.autoconfigure.websocket; | ||
|
||
import org.springframework.context.annotation.Import; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Inherited | ||
@Import({WebSocketDiscoveryConfiguration.class, WebSocketLoadBalanceConfiguration.class}) | ||
public @interface EnableWebSocketLoadBalanceConcept { | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...yuzai/connection/loadbalance/autoconfigure/websocket/WebSocketDiscoveryConfiguration.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.github.linyuzai.connection.loadbalance.autoconfigure.websocket; | ||
|
||
import com.github.linyuzai.connection.loadbalance.core.server.ConnectionServerProvider; | ||
import com.github.linyuzai.connection.loadbalance.discovery.DiscoveryConnectionServerProvider; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.cloud.client.discovery.DiscoveryClient; | ||
import org.springframework.cloud.client.serviceregistry.Registration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnClass({DiscoveryClient.class, Registration.class}) | ||
public class WebSocketDiscoveryConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public ConnectionServerProvider connectionServerProvider(DiscoveryClient client, Registration registration) { | ||
return new DiscoveryConnectionServerProvider(client, registration); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...zai/connection/loadbalance/autoconfigure/websocket/WebSocketLoadBalanceConfiguration.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.github.linyuzai.connection.loadbalance.autoconfigure.websocket; | ||
|
||
import com.github.linyuzai.connection.loadbalance.core.concept.ConnectionFactory; | ||
import com.github.linyuzai.connection.loadbalance.core.event.ConnectionEventPublisher; | ||
import com.github.linyuzai.connection.loadbalance.core.message.MessageFactory; | ||
import com.github.linyuzai.connection.loadbalance.core.proxy.ConnectionProxy; | ||
import com.github.linyuzai.connection.loadbalance.core.select.ConnectionSelector; | ||
import com.github.linyuzai.connection.loadbalance.core.server.ConnectionServerProvider; | ||
import com.github.linyuzai.connection.loadbalance.websocket.concept.WebSocketLoadBalanceConcept; | ||
import com.github.linyuzai.connection.loadbalance.websocket.proxy.WebSocketConnectionProxy; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.util.List; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
public class WebSocketLoadBalanceConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public ConnectionProxy connectionProxy() { | ||
return new WebSocketConnectionProxy(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public ConnectionEventPublisher connectionEventPublisher(ApplicationEventPublisher publisher) { | ||
return new ApplicationConnectionEventPublisher(publisher); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public WebSocketLoadBalanceConcept webSocketLoadBalanceConcept( | ||
ConnectionServerProvider provider, | ||
ConnectionProxy proxy, | ||
List<ConnectionFactory> connectionFactories, | ||
List<ConnectionSelector> connectionSelectors, | ||
List<MessageFactory> messageFactories, | ||
ConnectionEventPublisher publisher) { | ||
return new WebSocketLoadBalanceConcept.Builder() | ||
.connectionServerProvider(provider) | ||
.connectionProxy(proxy) | ||
.addConnectionFactories(connectionFactories) | ||
.addConnectionSelectors(connectionSelectors) | ||
.addMessageFactories(messageFactories) | ||
.eventPublisher(publisher) | ||
.build(); | ||
} | ||
} |
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