Class: AzIdentity::Identity::BaseClient
- Inherits:
-
Object
- Object
- AzIdentity::Identity::BaseClient
- Includes:
- AzureEnvironment
- Defined in:
- lib/az_identity/identity/base_client.rb
Direct Known Subclasses
Defined Under Namespace
Classes: FetchCredentialsError
Constant Summary collapse
- DEFAULT_TIMEOUT_S =
30
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
Instance Method Summary collapse
- #fetch_credentials ⇒ Object
- #fetch_credentials_if_needed ⇒ Object
-
#initialize ⇒ BaseClient
constructor
A new instance of BaseClient.
- #refresh_needed? ⇒ Boolean
Methods included from AzureEnvironment
#authority_url, #redis_resource, #storage_resource
Constructor Details
#initialize ⇒ BaseClient
Returns a new instance of BaseClient.
19 20 21 |
# File 'lib/az_identity/identity/base_client.rb', line 19 def initialize @mutex = Mutex.new end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
17 18 19 |
# File 'lib/az_identity/identity/base_client.rb', line 17 def credentials @credentials end |
Instance Method Details
#fetch_credentials ⇒ Object
23 24 25 |
# File 'lib/az_identity/identity/base_client.rb', line 23 def fetch_credentials raise NotImplementedError end |
#fetch_credentials_if_needed ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/az_identity/identity/base_client.rb', line 27 def fetch_credentials_if_needed # Serialize refreshes so concurrent callers (for example pooled Redis # connections across threads) don't each hit the token endpoint. @mutex.synchronize do @credentials = fetch_credentials if @credentials.nil? || refresh_needed? credentials end end |
#refresh_needed? ⇒ Boolean
37 38 39 40 41 |
# File 'lib/az_identity/identity/base_client.rb', line 37 def refresh_needed? return true unless @credentials @credentials.refresh_needed? end |