Sha256: f205d102932c1faf99fe025e5f6bcacf71b1765ec7488f73f46a9ed59583c360
Contents?: true
Size: 995 Bytes
Versions: 2
Compression:
Stored size: 995 Bytes
Contents
# frozen_string_literal: true module PubSubModelSync class ServiceBase SERVICE_KEY = 'service_model_sync' def listen_messages raise 'method :listen_messages must be defined in service' end def publish(_data, _attributes) raise 'method :publish must be defined in service' end def stop raise 'method :stop must be defined in service' end private # @param payload (String JSON): '{"data":{}, "attributes":{..}}' # refer: PubSubModelSync::Publisher (.publish_model | .publish_data) def perform_message(payload) data, attrs = parse_message_payload(payload) args = [data, attrs[:klass], attrs[:action]] PubSubModelSync::MessageProcessor.new(*args).process end def parse_message_payload(payload) message_payload = JSON.parse(payload).symbolize_keys data = message_payload[:data].symbolize_keys attrs = message_payload[:attributes].symbolize_keys [data, attrs] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pub_sub_model_sync-0.3.1 | lib/pub_sub_model_sync/service_base.rb |
pub_sub_model_sync-0.3.0 | lib/pub_sub_model_sync/service_base.rb |