Vostok.Configuration
HomeQuickstartConcepts and basicsBasic scenarios
  • Home
  • Quickstart
  • Concepts and basics
    • Settings nodes
      • Value nodes
      • Array nodes
      • Object nodes
    • Settings nodes merging
    • Settings nodes scoping
    • Binding nodes to models
    • Configuration sources
    • Configuration provider
    • Caching and performance
    • Error handling
  • Modules
    • Abstractions
    • Configuration
    • Sources
    • Sources.CC
    • Sources.Json
    • Sources.Yaml
    • Sources.Xml
    • Sources.Vault
    • Logging
    • Microsoft
  • Sources
    • Constant sources
    • Object source
    • XML sources
    • YAML sources
    • JSON sources
    • Vault source
    • ClusterConfig source
    • Command line source
    • Environment variables source
  • Binders
    • Primitives
    • Collections
    • Classes and structs
    • Constructor injection
  • Basic scenarios
    • Assign sources to types
    • Obtain settings from provider
    • Observe settings via provider
    • Print settings
    • Log settings updates
    • Log errors
    • Combine sources
    • Scope sources
    • Make settings secret
    • Make settings required
  • Advanced scenarios
    • Use name aliases
    • Use dynamic interfaces
    • Use shared provider instance
    • Use value substitutions
    • Nest sources
    • Freeze sources
    • Transform sources
    • Create custom sources
    • Apply custom validators
    • Apply custom binders
    • Apply source data to existing object
    • Print contents of a source
Powered by GitBook
On this page
  • Get method behavior
  • Related pages

Was this helpful?

Export as PDF
  1. Basic scenarios

Obtain settings from provider

PreviousAssign sources to typesNextObserve settings via provider

Last updated 4 years ago

Was this helpful?

Requires: .

Settings can be obtained on-demand with 's Get method.

With prior :

var settings = provider.Get<MySettings>();

With sources passed on per-call basis:

var settings = provider.Get<MySettings>(new JsonFileSource("settings.json"));

Get method behavior

  • Always returns the most recent version of settings (updates may happen in background):

    • Call Get on every settings access for "hot" configuration;

    • Call Get once and cache the result for "cold" configuration;

  • First call for a type may block or due to source latency, data unavailability or incorrect data format. This behavior persists until a data update remedies the error;

  • Once warmed up, subsequent calls never block or throw errors and are extremely cheap due to . Future errors are not propagated to the calling code, but . Get calls return the last seen correct settings object;

Related pages

main module
configuration provider
assignment of sources
throw exceptions
caching
can be logged
Configuration provider
Configuration sources
Caching and performance
Error handling