Class: Yabeda::ActionCable::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/yabeda/action_cable/config.rb

Constant Summary collapse

DEFAULT_BUCKETS =
[ 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10 ].freeze
DEFAULT_STREAM_NAME =
"yabeda.action_cable.metrics"
DEFAULT_COLLECTION_PERIOD =
60.seconds.freeze
DEFAULT_CHANNEL_CLASS_NAME =
"ApplicationCable::Channel"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



23
24
25
# File 'lib/yabeda/action_cable/config.rb', line 23

def initialize
  reset!
end

Instance Attribute Details

#bucketsObject

Returns the value of attribute buckets.



14
15
16
# File 'lib/yabeda/action_cable/config.rb', line 14

def buckets
  @buckets
end

#channel_class_nameObject

Returns the value of attribute channel_class_name.



14
15
16
# File 'lib/yabeda/action_cable/config.rb', line 14

def channel_class_name
  @channel_class_name
end

#collection_cooldown_periodObject



38
39
40
41
42
43
44
# File 'lib/yabeda/action_cable/config.rb', line 38

def collection_cooldown_period
  if @collection_cooldown_period.nil?
    collection_period / 2.0
  else
    @collection_cooldown_period
  end
end

#collection_periodObject

Returns the value of attribute collection_period.



14
15
16
# File 'lib/yabeda/action_cable/config.rb', line 14

def collection_period
  @collection_period
end

#default_bucketsObject

Returns the value of attribute default_buckets.



14
15
16
# File 'lib/yabeda/action_cable/config.rb', line 14

def default_buckets
  @default_buckets
end

#default_tagsObject

Returns the value of attribute default_tags.



14
15
16
# File 'lib/yabeda/action_cable/config.rb', line 14

def default_tags
  @default_tags
end

#stream_nameObject

Returns the value of attribute stream_name.



14
15
16
# File 'lib/yabeda/action_cable/config.rb', line 14

def stream_name
  @stream_name
end

#tagsObject

Returns the value of attribute tags.



14
15
16
# File 'lib/yabeda/action_cable/config.rb', line 14

def tags
  @tags
end

Instance Method Details

#buckets_for(metric) ⇒ Object



46
47
48
# File 'lib/yabeda/action_cable/config.rb', line 46

def buckets_for(metric)
  buckets[metric] || default_buckets
end

#reset!Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/yabeda/action_cable/config.rb', line 27

def reset!
  @default_buckets = DEFAULT_BUCKETS.dup
  @buckets = {}
  @default_tags = {}
  @tags = {}
  @stream_name = DEFAULT_STREAM_NAME
  @collection_period = DEFAULT_COLLECTION_PERIOD.dup
  @collection_cooldown_period = nil
  @channel_class_name = DEFAULT_CHANNEL_CLASS_NAME
end

#tags_for(metric) ⇒ Object



50
51
52
# File 'lib/yabeda/action_cable/config.rb', line 50

def tags_for(metric)
  tags[metric] || default_tags
end