Skip to content
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

added redis tls support #522

Merged
merged 4 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ jobs:

- name: Install chromedriver
uses: nanasess/[email protected]

with:
# Optional: do not specify to match Chrome's version
chromedriver-version: '114.0.5735.90'

- name: Install, unit test
run: mvn install -Dmaven.javadoc.skip=true -PpublicRepos -B -V

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ public void start() {

String redisHost = (String) props.get("redis.host");
Integer redisPort = (Integer) props.get("redis.port");
Boolean redisEnableTls = (Boolean) props.get("redis.enableTls");

props.put(ExpansionHandler.MAX_EXPANSION_LEVEL_HARD_PROPERTY, "100");
props.put(ExpansionHandler.MAX_EXPANSION_LEVEL_SOFT_PROPERTY, "50");

RunConfig.deployModules(vertx, Server.class, props, success -> {
if (success) {
redisClient = new RedisClient(vertx, new RedisOptions().setConnectionString("redis://" + redisHost + ":" + redisPort));
String protocol = redisEnableTls ? "rediss://" : "redis://";
ZhengXinCN marked this conversation as resolved.
Show resolved Hide resolved
redisClient = new RedisClient(vertx, new RedisOptions().setConnectionString(protocol + redisHost + ":" + redisPort));
redisApi = RedisAPI.api(redisClient);
RedisProvider redisProvider = () -> Future.succeededFuture(redisApi);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,17 @@ public RunConfig build(Vertx vertx, RedisProvider redisProvider, Class verticleC
* Builds redis properties configuration.
*/
public static Map<String, Object> buildRedisProps(String redisHost, int redisPort) {
return buildRedisProps(redisHost, redisPort, false);
}

/**
* Builds redis properties configuration.
*/
public static Map<String, Object> buildRedisProps(String redisHost, int redisPort, boolean redisEnableTls) {
final Map<String, Object> props = new HashMap<>();
props.put("redis.host", redisHost);
props.put("redis.port", redisPort);
props.put("redis.enableTls", redisEnableTls);
props.put("redis.encoding", "UTF-8");
return props;
}
Expand All @@ -393,9 +401,17 @@ public static Map<String, Object> buildRedisProps(String redisHost, int redisPor
* Builds a standard mod redis configuration.
*/
public static JsonObject buildModRedisConfig(String redisHost, int redisPort) {
return buildModRedisConfig(redisHost, redisPort, false);
}

/**
* Builds a standard mod redis configuration.
*/
public static JsonObject buildModRedisConfig(String redisHost, int redisPort, boolean redisEnableTls) {
JsonObject config = new JsonObject();
config.put("host", redisHost);
config.put("port", redisPort);
config.put("enableTls", redisEnableTls);
config.put("encoding", "UTF-8");
return config;
}
Expand Down Expand Up @@ -480,7 +496,8 @@ public static void deployModules(final Vertx vertx, Class verticleClass, Map<Str
final Logger log = LoggerFactory.getLogger(verticleClass);
String redisHost = (String) props.get("redis.host");
Integer redisPort = (Integer) props.get("redis.port");
log.info("deploying redis module with host:" + redisHost + " port:" + redisPort);
Boolean redisEnableTls = (Boolean) props.get("redis.enableTls");
log.info("deploying redis module with host:" + redisHost + " port:" + redisPort + " TLS: " + redisEnableTls);
ZhengXinCN marked this conversation as resolved.
Show resolved Hide resolved

// redisques module
vertx.deployVerticle("org.swisspush.redisques.RedisQues", new DeploymentOptions().setConfig(RunConfig.buildRedisquesConfig()).setInstances(4), event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ public static void setupBeforeClass(TestContext context) {

String redisHost = (String) props.get("redis.host");
Integer redisPort = (Integer) props.get("redis.port");
Boolean redisEnableTls = (Boolean) props.get("redis.enableTls");

props.put(ExpansionHandler.MAX_EXPANSION_LEVEL_HARD_PROPERTY, "100");
props.put(ExpansionHandler.MAX_EXPANSION_LEVEL_SOFT_PROPERTY, "4");

RunConfig.deployModules(vertx, AbstractTest.class, props, success -> {
if (success) {
RedisClient redisClient = new RedisClient(vertx, new RedisOptions().setConnectionString("redis://" + redisHost + ":" + redisPort));
String protocol = redisEnableTls ? "rediss://" : "redis://";
ZhengXinCN marked this conversation as resolved.
Show resolved Hide resolved
RedisClient redisClient = new RedisClient(vertx, new RedisOptions().setConnectionString(protocol + redisHost + ":" + redisPort));
RedisAPI redisAPI = RedisAPI.api(redisClient);
RedisProvider redisProvider = () -> Future.succeededFuture(redisAPI);

Expand Down