Class: EventDrivenServices::HhSearch::Producers::RestaurantTagGroupProducer

Inherits:
Object
  • Object
show all
Defined in:
app/services/event_driven_services/hh_search/producers/restaurant_tag_group_producer.rb

Constant Summary collapse

VALID_EVENT_TYPES =
[
  EventDrivenClient::Constants::UPDATE_EVENT,
  EventDrivenClient::Constants::DELETE_EVENT,
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(restaurant_tag_group_id, event_type) ⇒ RestaurantTagGroupProducer

Returns a new instance of RestaurantTagGroupProducer.



13
14
15
16
17
18
# File 'app/services/event_driven_services/hh_search/producers/restaurant_tag_group_producer.rb', line 13

def initialize(restaurant_tag_group_id, event_type)
  @restaurant_tag_group_id = restaurant_tag_group_id
  @restaurant_tag_group = RestaurantTagGroup.find_by(id: restaurant_tag_group_id) if restaurant_tag_group_id.present?
  @event_type = validate_event_type(event_type)
  @topic = EventDrivenClient::Constants::RESTAURANT_TAG_GROUPS_TOPIC
end

Instance Attribute Details

#event_typeObject (readonly)

Returns the value of attribute event_type.



6
7
8
# File 'app/services/event_driven_services/hh_search/producers/restaurant_tag_group_producer.rb', line 6

def event_type
  @event_type
end

#restaurant_tag_groupObject (readonly)

Returns the value of attribute restaurant_tag_group.



6
7
8
# File 'app/services/event_driven_services/hh_search/producers/restaurant_tag_group_producer.rb', line 6

def restaurant_tag_group
  @restaurant_tag_group
end

#restaurant_tag_group_idObject (readonly)

Returns the value of attribute restaurant_tag_group_id.



6
7
8
# File 'app/services/event_driven_services/hh_search/producers/restaurant_tag_group_producer.rb', line 6

def restaurant_tag_group_id
  @restaurant_tag_group_id
end

#topicObject (readonly)

Returns the value of attribute topic.



6
7
8
# File 'app/services/event_driven_services/hh_search/producers/restaurant_tag_group_producer.rb', line 6

def topic
  @topic
end

Instance Method Details

#send_eventObject



20
21
22
23
24
25
26
# File 'app/services/event_driven_services/hh_search/producers/restaurant_tag_group_producer.rb', line 20

def send_event
  payload = generate_payload(restaurant_tag_group)
  client.send_event_async(payload)
rescue StandardError => e
  APMErrorHandler.report("Failed to send event to topic #{topic}", error: e)
  raise e
end