<commit_before>require "sneakers"
require "sneakers_packer/version"
require "sneakers_packer/configuration"
require "sneakers_packer/message_packer"
require "sneakers_packer/common_worker"
require "sneakers_packer/rpc_worker"
require "sneakers_packer/rpc_client"

module SneakersPacker
  class RemoteCallTimeoutError < Exception; end

  # sender message to sneaker exchange
  # @param name route_key for message
  # @param data
  def self.publish(name, data)
    message = message_packer.pack_request(data)

    publisher.publish message, to_queue: name
  end

  # call remote service via rabbitmq rpc
  # @param name route_key for service
  # @param data
  # @param options{timeout} [int] timeout. seconds.   optional
  # @return result of service
  # @raise RemoteCallTimeoutError if timeout
  #
  def self.remote_call(name, data, options = {})
    @client ||= RpcClient.new(publisher)
    message = packer.pack_request(data)
    response = @client.call name, message, options
    response_data, from, status = message_packer.unpack_response(response)
    response_data
  end

  def self.publisher
    @publisher ||= ::Sneakers::Publisher.new
  end

  # message_packer is a singleton object
  def self.message_packer
    @message_packer ||= MessagePacker.new(self.conf.app_name)<commit_msg>Bugfix: typo.<commit_after>require "sneakers"
require "sneakers_packer/version"
require "sneakers_packer/configuration"
require "sneakers_packer/message_packer"
require "sneakers_packer/common_worker"
require "sneakers_packer/rpc_worker"
require "sneakers_packer/rpc_client"

module SneakersPacker
  class RemoteCallTimeoutError < Exception; end

  # sender message to sneaker exchange
  # @param name route_key for message
  # @param data
  def self.publish(name, data)
    message = message_packer.pack_request(data)

    publisher.publish message, to_queue: name
  end

  # call remote service via rabbitmq rpc
  # @param name route_key for service
  # @param data
  # @param options{timeout} [int] timeout. seconds.   optional
  # @return result of service
  # @raise RemoteCallTimeoutError if timeout
  #
  def self.remote_call(name, data, options = {})
    @client ||= RpcClient.new(publisher)
    message = message_packer.pack_request(data)
    response = @client.call name, message, options
    response_data, from, status = message_packer.unpack_response(response)
    response_data
  end

  def self.publisher
    @publisher ||= ::Sneakers::Publisher.new
  end

  # message_packer is a singleton object
  def self.message_packer
    @message_packer ||= MessagePacker.new(self.conf.app_name)
{'fraction_non_alphanumeric': 0.08564814814814815, 'fraction_numerical': 0.0, 'mean_word_length': 4.698901098901099, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7211427', 'n_tokens_mistral': 834, 'n_tokens_neox': 817, 'n_words': 204}