-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from cmgyqjj/feature_Support_reconnect_backof…
…f_interface feature:Support_reconnect_backoff_interface
- Loading branch information
Showing
9 changed files
with
108 additions
and
40 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
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
24 changes: 24 additions & 0 deletions
24
cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/io/backoff/BackoffStrategy.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,24 @@ | ||
package com.crossoverjie.cim.client.sdk.io.backoff; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* @author:qjj | ||
* @create: 2024-09-21 12:16 | ||
* @Description: backoff strategy interface | ||
*/ | ||
|
||
public interface BackoffStrategy { | ||
/** | ||
* @return the backoff time in milliseconds | ||
*/ | ||
long nextBackoff(); | ||
|
||
/** | ||
* Run the backoff strategy | ||
* @throws InterruptedException | ||
*/ | ||
default void runBackoff() throws InterruptedException { | ||
TimeUnit.SECONDS.sleep(nextBackoff()); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/io/backoff/RandomBackoff.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,19 @@ | ||
package com.crossoverjie.cim.client.sdk.io.backoff; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* @author:qjj | ||
* @create: 2024-09-21 12:22 | ||
* @Description: random backoff strategy | ||
*/ | ||
|
||
public class RandomBackoff implements BackoffStrategy { | ||
|
||
@Override | ||
public long nextBackoff() { | ||
int random = (int) (Math.random() * 7 + 3); | ||
return random; | ||
} | ||
|
||
} |
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
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,37 +1,37 @@ | ||
spring: | ||
application: | ||
name: cim-client | ||
|
||
# web port | ||
server: | ||
port: 8082 | ||
|
||
logging: | ||
level: | ||
root: error | ||
|
||
# enable swagger | ||
springdoc: | ||
swagger-ui: | ||
enabled: true | ||
|
||
# log path | ||
cim: | ||
msg: | ||
logger: | ||
path: /opt/logs/cim/ | ||
route: | ||
url: http://localhost:8083 # route url suggested that this is Nginx address | ||
user: # cim userId and userName | ||
id: 1725714450795 | ||
userName: cj4 | ||
callback: | ||
thread: | ||
queue: | ||
size: 2 | ||
pool: | ||
size: 2 | ||
heartbeat: | ||
time: 60 # cim heartbeat time (seconds) | ||
reconnect: | ||
count: 3 | ||
spring: | ||
application: | ||
name: cim-client | ||
|
||
# web port | ||
server: | ||
port: 8082 | ||
|
||
logging: | ||
level: | ||
root: error | ||
|
||
# enable swagger | ||
springdoc: | ||
swagger-ui: | ||
enabled: true | ||
|
||
# log path | ||
cim: | ||
msg: | ||
logger: | ||
path: /opt/logs/cim/ | ||
route: | ||
url: http://localhost:8083 # route url suggested that this is Nginx address | ||
user: # cim userId and userName | ||
id: 1725714450795 | ||
userName: cj4 | ||
callback: | ||
thread: | ||
queue: | ||
size: 2 | ||
pool: | ||
size: 2 | ||
heartbeat: | ||
time: 60 # cim heartbeat time (seconds) | ||
reconnect: | ||
count: 3 |