Class ConfigServerConfigurationProvider
- Namespace
- Steeltoe.Extensions.Configuration.ConfigServer
- Assembly
- Steeltoe.Extensions.Configuration.ConfigServerBase.dll
A Spring Cloud Config Server based ConfigurationProvider.
public class ConfigServerConfigurationProvider : ConfigurationProvider, IConfigurationProvider, IConfigurationSource, IDisposable
- Inheritance
-
ConfigServerConfigurationProvider
- Implements
- Inherited Members
Constructors
ConfigServerConfigurationProvider(ILoggerFactory)
Initializes a new instance of the ConfigServerConfigurationProvider class with default configuration settings. ConfigServerClientSettings
public ConfigServerConfigurationProvider(ILoggerFactory logFactory = null)
Parameters
logFactory
ILoggerFactoryoptional logging factory
ConfigServerConfigurationProvider(ConfigServerClientSettings, ILoggerFactory)
Initializes a new instance of the ConfigServerConfigurationProvider class.
public ConfigServerConfigurationProvider(ConfigServerClientSettings settings, ILoggerFactory logFactory = null)
Parameters
settings
ConfigServerClientSettingsthe configuration settings the provider uses when accessing the server.
logFactory
ILoggerFactoryoptional logging factory
ConfigServerConfigurationProvider(ConfigServerClientSettings, HttpClient, ILoggerFactory)
Initializes a new instance of the ConfigServerConfigurationProvider class.
public ConfigServerConfigurationProvider(ConfigServerClientSettings settings, HttpClient httpClient, ILoggerFactory logFactory = null)
Parameters
settings
ConfigServerClientSettingsthe configuration settings the provider uses when accessing the server.
httpClient
HttpClienta HttpClient the provider uses to make requests of the server.
logFactory
ILoggerFactoryoptional logging factory
ConfigServerConfigurationProvider(ConfigServerConfigurationSource)
Initializes a new instance of the ConfigServerConfigurationProvider class from a ConfigServerConfigurationSource
public ConfigServerConfigurationProvider(ConfigServerConfigurationSource source)
Parameters
source
ConfigServerConfigurationSourcethe ConfigServerConfigurationSource the provider uses when accessing the server.
ConfigServerConfigurationProvider(ConfigServerConfigurationSource, HttpClient)
Initializes a new instance of the ConfigServerConfigurationProvider class from a ConfigServerConfigurationSource
public ConfigServerConfigurationProvider(ConfigServerConfigurationSource source, HttpClient httpClient)
Parameters
source
ConfigServerConfigurationSourcethe ConfigServerConfigurationSource the provider uses when accessing the server.
httpClient
HttpClientthe httpClient to use
Fields
PREFIX
The prefix (IConfigurationSection under which all Spring Cloud Config Server configuration settings (ConfigServerClientSettings are found. (e.g. spring:cloud:config:env, spring:cloud:config:uri, spring:cloud:config:enabled, etc.)
public const string PREFIX = "spring:cloud:config"
Field Value
STATE_HEADER
public const string STATE_HEADER = "X-Config-State"
Field Value
TOKEN_HEADER
public const string TOKEN_HEADER = "X-Config-Token"
Field Value
_configuration
protected IConfiguration _configuration
Field Value
_hasConfiguration
protected bool _hasConfiguration
Field Value
_httpClient
protected HttpClient _httpClient
Field Value
_logger
protected ILogger _logger
Field Value
_loggerFactory
protected ILoggerFactory _loggerFactory
Field Value
_refreshTimer
protected Timer _refreshTimer
Field Value
_settings
protected ConfigServerClientSettings _settings
Field Value
_tokenRenewTimer
protected Timer _tokenRenewTimer
Field Value
Properties
Settings
Gets the configuration settings the provider uses when accessing the server.
public virtual ConfigServerClientSettings Settings { get; }
Property Value
Methods
AddConfigServerClientSettings()
Adds the client settings for the Configuration Server to the Data dictionary
protected virtual void AddConfigServerClientSettings()
AddConfigServerClientSettings(IDictionary<string, string>)
Adds the client settings for the Configuration Server to the data dictionary
protected virtual void AddConfigServerClientSettings(IDictionary<string, string> data)
Parameters
data
IDictionary<string, string>
AddPropertySource(PropertySource)
Adds values from a PropertySource to the Configurtation Data dictionary managed by this provider
[Obsolete("Will be removed in next release.")]
protected virtual void AddPropertySource(PropertySource source)
Parameters
source
PropertySourcea property source to add
AddPropertySource(PropertySource, IDictionary<string, string>)
Adds values from a PropertySource to the provided dictionary.
protected void AddPropertySource(PropertySource source, IDictionary<string, string> data)
Parameters
source
PropertySourcea property source to add
data
IDictionary<string, string>the dictionary to add the property source to
Build(IConfigurationBuilder)
Builds the IConfigurationProvider for this source.
[Obsolete("Will be removed in next release, use the ConfigServerConfigurationSource")]
public virtual IConfigurationProvider Build(IConfigurationBuilder builder)
Parameters
builder
IConfigurationBuilder
Returns
ConvertArrayKey(string)
protected virtual string ConvertArrayKey(string key)
Parameters
key
string
Returns
ConvertKey(string)
protected virtual string ConvertKey(string key)
Parameters
key
string
Returns
ConvertValue(object)
protected virtual string ConvertValue(object value)
Parameters
value
object
Returns
Dispose()
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
FetchAccessToken()
Conduct the OAuth2 client_credentials grant flow returning a task that can be used to obtain the results
protected string FetchAccessToken()
Returns
- string
The task object representing asynchronous operation
GetConfigServerUri(string)
Create the Uri that will be used in accessing the Configuration Server
[Obsolete("Will be removed in next release. See GetConfigServerUri(string, string)")]
protected virtual string GetConfigServerUri(string label)
Parameters
label
stringa label to add
Returns
- string
The request URI for the Configuration Server
GetConfigServerUri(string, string)
Create the Uri that will be used in accessing the Configuration Server
protected virtual string GetConfigServerUri(string baseRawUri, string label)
Parameters
Returns
- string
The request URI for the Configuration Server
GetEncoded(string, string)
Encode the username password for a http request
protected string GetEncoded(string user, string password)
Parameters
Returns
- string
Encoded user + password
GetHttpClient(ConfigServerClientSettings)
Creates an appropriately configured HttpClient that will be used in communicating with the Spring Cloud Configuration Server
protected static HttpClient GetHttpClient(ConfigServerClientSettings settings)
Parameters
settings
ConfigServerClientSettingsthe settings used in configuring the HttpClient
Returns
- HttpClient
The HttpClient used by the provider
GetRequestMessage(string)
Create the HttpRequestMessage that will be used in accessing the Spring Cloud Configuration server
[Obsolete("Will be removed in next release. See GetRequestMessage(string, string, string)")]
protected virtual HttpRequestMessage GetRequestMessage(string requestUri)
Parameters
requestUri
stringthe Uri used when accessing the server
Returns
- HttpRequestMessage
The HttpRequestMessage built from the path
GetRequestMessage(string, string, string)
Create the HttpRequestMessage that will be used in accessing the Spring Cloud Configuration server
protected virtual HttpRequestMessage GetRequestMessage(string requestUri, string username, string password)
Parameters
requestUri
stringthe Uri used when accessing the server
username
stringusername to use if required
password
stringpassword to use if required
Returns
- HttpRequestMessage
The HttpRequestMessage built from the path
GetValutRenewMessage(string)
[Obsolete("Will be removed in next release. See GetVaultRenewMessage(string)")]
protected virtual HttpRequestMessage GetValutRenewMessage(string requestUri)
Parameters
requestUri
string
Returns
GetVaultRenewMessage(string)
protected virtual HttpRequestMessage GetVaultRenewMessage(string requestUri)
Parameters
requestUri
string
Returns
GetVaultRenewUri()
protected virtual string GetVaultRenewUri()
Returns
IsDiscoveryFirstEnabled()
protected bool IsDiscoveryFirstEnabled()
Returns
Load()
Loads configuration data from the Spring Cloud Configuration Server as specified by the Settings
public override void Load()
RefreshVaultTokenAsync(object)
protected void RefreshVaultTokenAsync(object state)
Parameters
state
object
RemoteLoadAsync(string)
Asynchronously calls the Spring Cloud Configuration Server using the provided Uri and returning a a task that can be used to obtain the results
[Obsolete("Will be removed in next release. See RemoteLoadAsync(string[], string)")]
protected virtual Task<ConfigEnvironment> RemoteLoadAsync(string requestUri)
Parameters
requestUri
stringthe Uri used in accessing the Spring Cloud Configuration Server
Returns
- Task<ConfigEnvironment>
The task object representing the asynchronous operation
RemoteLoadAsync(string[], string)
protected Task<ConfigEnvironment> RemoteLoadAsync(string[] requestUris, string label)
Parameters
Returns
RenewToken(string)
protected virtual void RenewToken(string token)
Parameters
token
string
Split(string)
protected virtual string[] Split(string source)
Parameters
source
string
Returns
- string[]