Method: Faulty.init
- Defined in:
- lib/faulty.rb
.init(default_name = :default, **config) {|Faulty::Options| ... } ⇒ self
Start the Faulty environment
This creates a global shared Faulty state for configuration and for re-using State objects.
Not thread safe, should be executed before any worker threads are spawned.
If you prefer dependency-injection instead of global state, you can skip
init
and use new to pass an instance directoy to your
dependencies.
to nil
to skip creating a default instance.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/faulty.rb', line 44 def init(default_name = :default, **config, &block) raise AlreadyInitializedError if @instances @default_instance = default_name @instances = Concurrent::Map.new register(default_name, new(**config, &block)) unless default_name.nil? self rescue StandardError @instances = nil raise end |