Class: Sbmt::Outbox::V2::Tasks::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/sbmt/outbox/v2/tasks/base.rb

Direct Known Subclasses

Default, Poll, Process

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_class:, worker_name:, worker_version: 2) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sbmt/outbox/v2/tasks/base.rb', line 14

def initialize(item_class:, worker_name:, worker_version: 2)
  @item_class = item_class
  @worker_name = worker_name
  @worker_version = worker_version

  @log_tags = {
    box_type: item_class.box_type,
    box_name: item_class.box_name,
    worker_name: worker_name,
    worker_version: worker_version
  }

  @yabeda_labels = {
    type: item_class.box_type,
    name: Sbmt::Outbox::Metrics::Utils.metric_safe(item_class.box_name),
    owner: owner,
    worker_version: 2,
    worker_name: worker_name
  }
end

Instance Attribute Details

#item_classObject (readonly)

Returns the value of attribute item_class.



10
11
12
# File 'lib/sbmt/outbox/v2/tasks/base.rb', line 10

def item_class
  @item_class
end

#log_tagsObject (readonly)

Returns the value of attribute log_tags.



10
11
12
# File 'lib/sbmt/outbox/v2/tasks/base.rb', line 10

def log_tags
  @log_tags
end

#worker_nameObject (readonly)

Returns the value of attribute worker_name.



10
11
12
# File 'lib/sbmt/outbox/v2/tasks/base.rb', line 10

def worker_name
  @worker_name
end

#worker_versionObject (readonly)

Returns the value of attribute worker_version.



10
11
12
# File 'lib/sbmt/outbox/v2/tasks/base.rb', line 10

def worker_version
  @worker_version
end

#yabeda_labelsObject (readonly)

Returns the value of attribute yabeda_labels.



10
11
12
# File 'lib/sbmt/outbox/v2/tasks/base.rb', line 10

def yabeda_labels
  @yabeda_labels
end

Instance Method Details

#to_hObject



35
36
37
38
39
40
41
42
# File 'lib/sbmt/outbox/v2/tasks/base.rb', line 35

def to_h
  result = {}
  instance_variables.each do |iv|
    iv = iv.to_s[1..]
    result[iv.to_sym] = instance_variable_get(:"@#{iv}")
  end
  result
end