-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update singer with 0.7.3.25 changes (#3)
- Loading branch information
Showing
32 changed files
with
930 additions
and
209 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 |
---|---|---|
@@ -1 +1 @@ | ||
0.7.3.16 | ||
0.7.3.25 |
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
42 changes: 42 additions & 0 deletions
42
...r/src/main/java/com/pinterest/singer/environment/EnvVariableBasedEnvironmentProvider.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,42 @@ | ||
/** | ||
* Copyright 2019 Pinterest, Inc. | ||
* | ||
* Licensed 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 com.pinterest.singer.environment; | ||
|
||
/** | ||
* Uses environment variables to specify the provider. This class defaults to | ||
* Environment.PROD unless the environment variable is explicitly configured. | ||
*/ | ||
public class EnvVariableBasedEnvironmentProvider extends EnvironmentProvider { | ||
|
||
private static final String DEPLOYMENT_STAGE = "DEPLOYMENT_STAGE"; | ||
private static final String LOCALITY = "LOCALITY"; | ||
|
||
@Override | ||
protected String getLocality() { | ||
String locality = System.getenv(LOCALITY); | ||
if (locality != null) { | ||
return locality; | ||
} else { | ||
return Environment.LOCALITY_NOT_AVAILABLE; | ||
} | ||
} | ||
|
||
@Override | ||
protected String getDeploymentStage () { | ||
return System.getenv(DEPLOYMENT_STAGE); | ||
} | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
singer/src/main/java/com/pinterest/singer/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,79 @@ | ||
/** | ||
* Copyright 2019 Pinterest, Inc. | ||
* | ||
* Licensed 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 com.pinterest.singer.environment; | ||
|
||
import com.pinterest.singer.utils.SingerUtils; | ||
|
||
/** | ||
* This indicates what environment is Singer running in. | ||
* | ||
* Singer Environment indicator can subsequently be used by any component that | ||
* needs to switch functionality based on the environment it is running in. | ||
* | ||
* NOTE: all variable MUST have default initialized in case the loader doesn't | ||
* work, all getters must return a NON-NULL value unless NULLs are expected. | ||
*/ | ||
public class Environment { | ||
|
||
public static final String LOCALITY_NOT_AVAILABLE = "n/a"; | ||
public static final String DEFAULT_HOSTNAME = SingerUtils.getHostname(); | ||
private String locality = LOCALITY_NOT_AVAILABLE; | ||
private String deploymentStage; | ||
private String hostname = DEFAULT_HOSTNAME; | ||
|
||
/** | ||
* @return the locality | ||
*/ | ||
public String getLocality() { | ||
return locality; | ||
} | ||
|
||
/** | ||
* @param locality the locality to set | ||
*/ | ||
public void setLocality(String locality) { | ||
this.locality = locality; | ||
} | ||
|
||
/** | ||
* @return the deploymentStage | ||
*/ | ||
public String getDeploymentStage() { | ||
return deploymentStage; | ||
} | ||
|
||
/** | ||
* @param deploymentStage the deploymentStage to set | ||
*/ | ||
public void setDeploymentStage(String deploymentStage) { | ||
this.deploymentStage = deploymentStage; | ||
} | ||
|
||
/** | ||
* @return the hostname | ||
*/ | ||
public String getHostname() { | ||
return hostname; | ||
} | ||
|
||
/** | ||
* @param hostname the hostname to set | ||
*/ | ||
public void setHostname(String hostname) { | ||
this.hostname = hostname; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
singer/src/main/java/com/pinterest/singer/environment/EnvironmentProvider.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,44 @@ | ||
/** | ||
* Copyright 2019 Pinterest, Inc. | ||
* | ||
* Licensed 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 com.pinterest.singer.environment; | ||
|
||
/** | ||
* Environment provider for Singer, defaults to production. This class can be | ||
* extended to change the behavior of environment provider. | ||
*/ | ||
public abstract class EnvironmentProvider { | ||
|
||
protected Environment environment = new Environment(); | ||
|
||
public EnvironmentProvider() { | ||
environment.setDeploymentStage(getDeploymentStage()); | ||
environment.setLocality(getLocality()); | ||
environment.setHostname(getHostname()); | ||
} | ||
|
||
protected abstract String getLocality(); | ||
|
||
protected abstract String getDeploymentStage(); | ||
|
||
protected String getHostname() { | ||
return Environment.DEFAULT_HOSTNAME; | ||
} | ||
|
||
public Environment getEnvironment() { | ||
return environment; | ||
} | ||
|
||
} |
Oops, something went wrong.