-
Notifications
You must be signed in to change notification settings - Fork 23
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 #117 from ruslansennov/consul-connect-v5
Consul connect support
- Loading branch information
Showing
15 changed files
with
613 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,4 +158,4 @@ | |
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> | ||
</project> |
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
48 changes: 48 additions & 0 deletions
48
src/main/java/io/vertx/ext/consul/connect/ConnectOptions.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,48 @@ | ||
package io.vertx.ext.consul.connect; | ||
|
||
import io.vertx.codegen.annotations.DataObject; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
@DataObject | ||
public class ConnectOptions { | ||
private static final String SIDECAR = "SidecarService"; | ||
|
||
private SidecarServiceOptions sidecarService; | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
public ConnectOptions() { | ||
} | ||
|
||
/** | ||
* Constructor from JSON | ||
* | ||
* @param options the JSON | ||
*/ | ||
public ConnectOptions(JsonObject options) { | ||
this.sidecarService = new SidecarServiceOptions(options.getJsonObject(SIDECAR)); | ||
} | ||
|
||
/** | ||
* Convert to JSON | ||
* | ||
* @return the JSON | ||
*/ | ||
public JsonObject toJson() { | ||
JsonObject jsonObject = new JsonObject(); | ||
if (sidecarService != null) { | ||
jsonObject.put(SIDECAR, sidecarService.toJson()); | ||
} | ||
return jsonObject; | ||
} | ||
|
||
public SidecarServiceOptions getSidecarService() { | ||
return sidecarService; | ||
} | ||
|
||
public ConnectOptions setSidecarService(SidecarServiceOptions sidecarService) { | ||
this.sidecarService = sidecarService; | ||
return this; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/io/vertx/ext/consul/connect/ExposeOptions.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 io.vertx.ext.consul.connect; | ||
|
||
import io.vertx.codegen.annotations.DataObject; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@DataObject | ||
public class ExposeOptions { | ||
private static final String PATHS = "Paths"; | ||
|
||
private List<ExposePathOptions> paths; | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
public ExposeOptions() { | ||
} | ||
|
||
/** | ||
* Constructor from JSON | ||
* | ||
* @param options the JSON | ||
*/ | ||
public ExposeOptions(JsonObject options) { | ||
this.paths = options.getJsonArray(PATHS).stream() | ||
.map(o -> new ExposePathOptions((JsonObject) o)) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
/** | ||
* Convert to JSON | ||
* | ||
* @return the JSON | ||
*/ | ||
public JsonObject toJson() { | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.put(PATHS, paths.stream().map(ExposePathOptions::toJson).collect(Collectors.toList())); | ||
return jsonObject; | ||
} | ||
|
||
public List<ExposePathOptions> getPaths() { | ||
return paths; | ||
} | ||
|
||
public ExposeOptions setPaths(List<ExposePathOptions> paths) { | ||
this.paths = paths; | ||
return this; | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/main/java/io/vertx/ext/consul/connect/ExposePathOptions.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,85 @@ | ||
package io.vertx.ext.consul.connect; | ||
|
||
import io.vertx.codegen.annotations.DataObject; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
@DataObject | ||
public class ExposePathOptions { | ||
private static final String PATH = "Path"; | ||
private static final String PROTOCOL = "Protocol"; | ||
private static final String LOC_PATH = "LocalPathPort"; | ||
private static final String LIS_PORT = "ListenerPort"; | ||
|
||
private String path; | ||
private String protocol; | ||
private Integer localPathPort; | ||
private Integer listenerPort; | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
public ExposePathOptions() { | ||
} | ||
|
||
/** | ||
* Constructor from JSON | ||
* | ||
* @param options the JSON | ||
*/ | ||
public ExposePathOptions(JsonObject options) { | ||
this.path = options.getString(PATH); | ||
this.protocol = options.getString(PROTOCOL); | ||
this.localPathPort = options.getInteger(LOC_PATH); | ||
this.listenerPort = options.getInteger(LIS_PORT); | ||
} | ||
|
||
/** | ||
* Convert to JSON | ||
* | ||
* @return the JSON | ||
*/ | ||
public JsonObject toJson() { | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.put(PATH, path); | ||
jsonObject.put(PROTOCOL, protocol); | ||
jsonObject.put(LOC_PATH, localPathPort); | ||
jsonObject.put(LIS_PORT, listenerPort); | ||
return jsonObject; | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
public ExposePathOptions setPath(String path) { | ||
this.path = path; | ||
return this; | ||
} | ||
|
||
public String getProtocol() { | ||
return protocol; | ||
} | ||
|
||
public ExposePathOptions setProtocol(String protocol) { | ||
this.protocol = protocol; | ||
return this; | ||
} | ||
|
||
public Integer getLocalPathPort() { | ||
return localPathPort; | ||
} | ||
|
||
public ExposePathOptions setLocalPathPort(Integer localPathPort) { | ||
this.localPathPort = localPathPort; | ||
return this; | ||
} | ||
|
||
public Integer getListenerPort() { | ||
return listenerPort; | ||
} | ||
|
||
public ExposePathOptions setListenerPort(Integer listenerPort) { | ||
this.listenerPort = listenerPort; | ||
return this; | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
src/main/java/io/vertx/ext/consul/connect/ProxyOptions.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,83 @@ | ||
package io.vertx.ext.consul.connect; | ||
|
||
import io.vertx.codegen.annotations.DataObject; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@DataObject | ||
public class ProxyOptions { | ||
private static final String CONFIG = "Config"; | ||
private static final String UPSTREAMS = "Upstreams"; | ||
private static final String EXPOSE = "Expose"; | ||
|
||
private JsonObject config; | ||
private List<UpstreamOptions> upstreams; | ||
private ExposeOptions expose; | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
public ProxyOptions() { | ||
} | ||
|
||
/** | ||
* Constructor from JSON | ||
* | ||
* @param options the JSON | ||
*/ | ||
public ProxyOptions(JsonObject options) { | ||
this.config = options.getJsonObject(CONFIG); | ||
this.upstreams = options.getJsonArray(UPSTREAMS).stream() | ||
.map(o -> new UpstreamOptions((JsonObject) o)) | ||
.collect(Collectors.toList()); | ||
this.expose = new ExposeOptions(options.getJsonObject(EXPOSE)); | ||
} | ||
|
||
/** | ||
* Convert to JSON | ||
* | ||
* @return the JSON | ||
*/ | ||
public JsonObject toJson() { | ||
JsonObject jsonObject = new JsonObject(); | ||
if (upstreams != null) { | ||
jsonObject.put(UPSTREAMS, upstreams.stream().map(UpstreamOptions::toJson).collect(Collectors.toList())); | ||
} | ||
if (config != null) { | ||
jsonObject.put(CONFIG, config); | ||
} | ||
if (expose != null) { | ||
jsonObject.put(EXPOSE, expose.toJson()); | ||
} | ||
return jsonObject; | ||
} | ||
|
||
public JsonObject getConfig() { | ||
return config; | ||
} | ||
|
||
public ProxyOptions setConfig(JsonObject config) { | ||
this.config = config; | ||
return this; | ||
} | ||
|
||
public List<UpstreamOptions> getUpstreams() { | ||
return upstreams; | ||
} | ||
|
||
public ProxyOptions setUpstreams(List<UpstreamOptions> upstreams) { | ||
this.upstreams = upstreams; | ||
return this; | ||
} | ||
|
||
public ExposeOptions getExpose() { | ||
return expose; | ||
} | ||
|
||
public ProxyOptions setExpose(ExposeOptions expose) { | ||
this.expose = expose; | ||
return this; | ||
} | ||
} |
Oops, something went wrong.