-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make instance config factory support custom amazon info provider
- Loading branch information
Ling Yuan
committed
Nov 6, 2020
1 parent
360d536
commit 5d2db6d
Showing
3 changed files
with
55 additions
and
4 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
9 changes: 9 additions & 0 deletions
9
...ient-archaius2/src/main/java/com/netflix/appinfo/providers/AmazonInfoProviderFactory.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,9 @@ | ||
package com.netflix.appinfo.providers; | ||
|
||
import com.netflix.appinfo.AmazonInfo; | ||
|
||
import javax.inject.Provider; | ||
|
||
public interface AmazonInfoProviderFactory { | ||
Provider<AmazonInfo> get(); | ||
} |
33 changes: 33 additions & 0 deletions
33
...ain/java/com/netflix/appinfo/providers/CustomAmazonInfoProviderInstanceConfigFactory.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 @@ | ||
package com.netflix.appinfo.providers; | ||
|
||
import com.netflix.appinfo.AmazonInfo; | ||
import com.netflix.appinfo.Ec2EurekaArchaius2InstanceConfig; | ||
import com.netflix.appinfo.EurekaInstanceConfig; | ||
import com.netflix.archaius.api.Config; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Provider; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
public class CustomAmazonInfoProviderInstanceConfigFactory implements EurekaInstanceConfigFactory { | ||
|
||
private final Config configInstance; | ||
private final Provider<AmazonInfo> amazonInfoProvider; | ||
private EurekaInstanceConfig eurekaInstanceConfig; | ||
|
||
@Inject | ||
public CustomAmazonInfoProviderInstanceConfigFactory(Config configInstance, AmazonInfoProviderFactory amazonInfoProviderFactory) { | ||
this.configInstance = configInstance; | ||
this.amazonInfoProvider = amazonInfoProviderFactory.get(); | ||
} | ||
|
||
@Override | ||
public EurekaInstanceConfig get() { | ||
if (eurekaInstanceConfig == null) { | ||
eurekaInstanceConfig = new Ec2EurekaArchaius2InstanceConfig(configInstance, amazonInfoProvider); | ||
} | ||
|
||
return eurekaInstanceConfig; | ||
} | ||
} |