<commit_before>class Service::SqsQueue < Service

  string   :aws_access_key, :sqs_queue_name
  password :aws_secret_key

  # receive_push()
  def receive_push
    return unless data && payload

    if data['aws_access_key'].to_s.empty?
      raise_config_error "You must define an AWS access key."
    end

    if data['aws_secret_key'].to_s.empty?
      raise_config_error "You must define an AWS secret key."
    end

    if data['sqs_queue_name'].to_s.empty?
      raise_config_error "You must define an SQS queue."
    end

    # Send payload to SQS queue
    notify_sqs( access_key(), secret_key(), queue_name(), payload )
  end

  # notify_sqs()
  # Note: If the queue does not exist, it is automatically created
  def notify_sqs(aws_access_key, aws_secret_key, queue_name, payload)
    sqs = RightAws::SqsGen2.new(aws_access_key, aws_secret_key)
    queue = sqs.queue(queue_name)
    queue.send_message(payload)
  end

  def access_key
    data['aws_access_key'].strip
  end

  def secret_key
    data['aws_secret_key'].strip<commit_msg>Added JSON encoding for payload<commit_after>class Service::SqsQueue < Service

  string   :aws_access_key, :sqs_queue_name
  password :aws_secret_key

  # receive_push()
  def receive_push
    return unless data && payload

    if data['aws_access_key'].to_s.empty?
      raise_config_error "You must define an AWS access key."
    end

    if data['aws_secret_key'].to_s.empty?
      raise_config_error "You must define an AWS secret key."
    end

    if data['sqs_queue_name'].to_s.empty?
      raise_config_error "You must define an SQS queue."
    end

    # Encode payload to JSON
    payload_json_data = JSON.generate(payload)

    # Send payload to SQS queue
    notify_sqs( access_key(), secret_key(), queue_name(), payload_json_data )
  end

  # notify_sqs()
  # Note: If the queue does not exist, it is automatically created
  def notify_sqs(aws_access_key, aws_secret_key, queue_name, payload)
    sqs = RightAws::SqsGen2.new(aws_access_key, aws_secret_key)
    queue = sqs.queue(queue_name)
    queue.send_message(payload)
  end

  def access_key
    data['aws_access_key'].strip
  end

  def secret_key
    data['aws_secret_key'].strip
{'fraction_non_alphanumeric': 0.08610478359908884, 'fraction_numerical': 0.0009111617312072893, 'mean_word_length': 3.7429805615550755, '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': '4893289', 'n_tokens_mistral': 746, 'n_tokens_neox': 726, 'n_words': 187}