Class: Faulty::Scope::Options

Inherits:
Struct
  • Object
show all
Includes:
ImmutableOptions
Defined in:
lib/faulty/scope.rb

Overview

Options for Faulty::Scope

Instance Attribute Summary collapse

Method Summary

Methods included from ImmutableOptions

#initialize

Instance Attribute Details

#cacheCache::Interface (readonly)

Returns A cache backend if you want to use Faulty's cache support. Automatically wrapped in a Cache::FaultTolerantProxy. Default Cache::Default.new.

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/faulty/scope.rb', line 32

Options = Struct.new(
  :cache,
  :storage,
  :listeners,
  :notifier
) do
  include ImmutableOptions

  private

  def finalize
    self.notifier ||= Events::Notifier.new(listeners || [])

    self.storage ||= Storage::Memory.new
    unless storage.fault_tolerant?
      self.storage = Storage::FaultTolerantProxy.new(storage, notifier: notifier)
    end

    self.cache ||= Cache::Default.new
    unless cache.fault_tolerant?
      self.cache = Cache::FaultTolerantProxy.new(cache, notifier: notifier)
    end
  end

  def required
    %i[cache storage notifier]
  end

  def defaults
    {
      listeners: [Events::LogListener.new]
    }
  end
end

#listenersArray (readonly)

Returns listeners Faulty event listeners.

Returns:

  • (Array)

    listeners Faulty event listeners



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/faulty/scope.rb', line 32

Options = Struct.new(
  :cache,
  :storage,
  :listeners,
  :notifier
) do
  include ImmutableOptions

  private

  def finalize
    self.notifier ||= Events::Notifier.new(listeners || [])

    self.storage ||= Storage::Memory.new
    unless storage.fault_tolerant?
      self.storage = Storage::FaultTolerantProxy.new(storage, notifier: notifier)
    end

    self.cache ||= Cache::Default.new
    unless cache.fault_tolerant?
      self.cache = Cache::FaultTolerantProxy.new(cache, notifier: notifier)
    end
  end

  def required
    %i[cache storage notifier]
  end

  def defaults
    {
      listeners: [Events::LogListener.new]
    }
  end
end

#notifierEvents::Notifier (readonly)

Returns A Faulty notifier. If given, listeners are ignored.

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/faulty/scope.rb', line 32

Options = Struct.new(
  :cache,
  :storage,
  :listeners,
  :notifier
) do
  include ImmutableOptions

  private

  def finalize
    self.notifier ||= Events::Notifier.new(listeners || [])

    self.storage ||= Storage::Memory.new
    unless storage.fault_tolerant?
      self.storage = Storage::FaultTolerantProxy.new(storage, notifier: notifier)
    end

    self.cache ||= Cache::Default.new
    unless cache.fault_tolerant?
      self.cache = Cache::FaultTolerantProxy.new(cache, notifier: notifier)
    end
  end

  def required
    %i[cache storage notifier]
  end

  def defaults
    {
      listeners: [Events::LogListener.new]
    }
  end
end

#storageStorage::Interface (readonly)

Returns The storage backend. Automatically wrapped in a Faulty::Storage::FaultTolerantProxy. Default Storage::Memory.new.

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/faulty/scope.rb', line 32

Options = Struct.new(
  :cache,
  :storage,
  :listeners,
  :notifier
) do
  include ImmutableOptions

  private

  def finalize
    self.notifier ||= Events::Notifier.new(listeners || [])

    self.storage ||= Storage::Memory.new
    unless storage.fault_tolerant?
      self.storage = Storage::FaultTolerantProxy.new(storage, notifier: notifier)
    end

    self.cache ||= Cache::Default.new
    unless cache.fault_tolerant?
      self.cache = Cache::FaultTolerantProxy.new(cache, notifier: notifier)
    end
  end

  def required
    %i[cache storage notifier]
  end

  def defaults
    {
      listeners: [Events::LogListener.new]
    }
  end
end