-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace consul-client with consul-api library (#1158)
- Loading branch information
1 parent
3abfd88
commit e02d3bf
Showing
31 changed files
with
965 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -610,4 +610,4 @@ | |
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
...-commons/src/main/java/org/apache/streampipes/commons/environment/DefaultEnvironment.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,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.commons.environment; | ||
|
||
import org.apache.streampipes.commons.constants.Envs; | ||
import org.apache.streampipes.commons.environment.variable.BooleanEnvironmentVariable; | ||
import org.apache.streampipes.commons.environment.variable.IntEnvironmentVariable; | ||
import org.apache.streampipes.commons.environment.variable.StringEnvironmentVariable; | ||
|
||
public class DefaultEnvironment implements Environment { | ||
|
||
@Override | ||
public StringEnvironmentVariable getConsulHost() { | ||
return new StringEnvironmentVariable(Envs.SP_CONSUL_HOST); | ||
} | ||
|
||
@Override | ||
public IntEnvironmentVariable getConsulPort() { | ||
return new IntEnvironmentVariable(Envs.SP_CONSUL_PORT); | ||
} | ||
|
||
@Override | ||
public BooleanEnvironmentVariable getSpDebug() { | ||
return new BooleanEnvironmentVariable(Envs.SP_DEBUG); | ||
} | ||
|
||
@Override | ||
public StringEnvironmentVariable getConsulLocation() { | ||
return new StringEnvironmentVariable(Envs.SP_CONSUL_LOCATION); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ampipes-commons/src/main/java/org/apache/streampipes/commons/environment/Environment.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,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.commons.environment; | ||
|
||
import org.apache.streampipes.commons.environment.variable.BooleanEnvironmentVariable; | ||
import org.apache.streampipes.commons.environment.variable.IntEnvironmentVariable; | ||
import org.apache.streampipes.commons.environment.variable.StringEnvironmentVariable; | ||
|
||
public interface Environment { | ||
|
||
StringEnvironmentVariable getConsulHost(); | ||
|
||
IntEnvironmentVariable getConsulPort(); | ||
|
||
BooleanEnvironmentVariable getSpDebug(); | ||
|
||
@Deprecated(since = "0.90.0", forRemoval = true) | ||
StringEnvironmentVariable getConsulLocation(); | ||
} |
26 changes: 26 additions & 0 deletions
26
...mpipes-commons/src/main/java/org/apache/streampipes/commons/environment/Environments.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,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.commons.environment; | ||
|
||
public class Environments { | ||
|
||
public static Environment getEnvironment() { | ||
return new DefaultEnvironment(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
.../java/org/apache/streampipes/commons/environment/variable/BooleanEnvironmentVariable.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,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.commons.environment.variable; | ||
|
||
import org.apache.streampipes.commons.constants.Envs; | ||
|
||
public class BooleanEnvironmentVariable extends EnvironmentVariable<Boolean> { | ||
|
||
public BooleanEnvironmentVariable(Envs envVariable) { | ||
super(envVariable); | ||
} | ||
|
||
@Override | ||
public Boolean parse(String value) { | ||
return Boolean.parseBoolean(value.toLowerCase()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ommons/src/main/java/org/apache/streampipes/commons/environment/variable/EnvResolver.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 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.commons.environment.variable; | ||
|
||
public interface EnvResolver<T> { | ||
|
||
T resolve(); | ||
} |
62 changes: 62 additions & 0 deletions
62
...rc/main/java/org/apache/streampipes/commons/environment/variable/EnvironmentVariable.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,62 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.commons.environment.variable; | ||
|
||
import org.apache.streampipes.commons.constants.CustomEnvs; | ||
import org.apache.streampipes.commons.constants.Envs; | ||
|
||
public abstract class EnvironmentVariable<T> { | ||
|
||
private T defaultValue; | ||
private String envVariableName; | ||
|
||
public EnvironmentVariable(String envVariableName, | ||
T defaultValue) { | ||
this.envVariableName = envVariableName; | ||
this.defaultValue = defaultValue; | ||
} | ||
|
||
public EnvironmentVariable(Envs envVariable) { | ||
this.envVariableName = envVariable.getEnvVariableName(); | ||
this.defaultValue = parse(envVariable.getDefaultValue()); | ||
} | ||
|
||
public T getValue() { | ||
return parse(CustomEnvs.getEnv(envVariableName)); | ||
} | ||
|
||
public boolean exists() { | ||
return CustomEnvs.exists(envVariableName); | ||
} | ||
|
||
public T getValueOrDefault() { | ||
return exists() ? getValue() : defaultValue; | ||
} | ||
|
||
public T getValueOrReturn(T defaultValue) { | ||
return exists() ? getValue() : defaultValue; | ||
} | ||
|
||
public T getValueOrResolve(EnvResolver<T> resolver) { | ||
return resolver.resolve(); | ||
} | ||
|
||
public abstract T parse(String value); | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...main/java/org/apache/streampipes/commons/environment/variable/IntEnvironmentVariable.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,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.commons.environment.variable; | ||
|
||
import org.apache.streampipes.commons.constants.Envs; | ||
|
||
public class IntEnvironmentVariable extends EnvironmentVariable<Integer> { | ||
public IntEnvironmentVariable(Envs envVariable) { | ||
super(envVariable); | ||
} | ||
|
||
@Override | ||
public Integer parse(String value) { | ||
return Integer.parseInt(value); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...n/java/org/apache/streampipes/commons/environment/variable/StringEnvironmentVariable.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,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.commons.environment.variable; | ||
|
||
import org.apache.streampipes.commons.constants.Envs; | ||
|
||
public class StringEnvironmentVariable extends EnvironmentVariable<String> { | ||
|
||
public StringEnvironmentVariable(Envs envVariable) { | ||
super(envVariable); | ||
} | ||
|
||
@Override | ||
public String parse(String value) { | ||
return value; | ||
} | ||
} |
Oops, something went wrong.