<commit_before>require 'flatware/socket'
module Flatware
  module Sink
    extend self
    attr_accessor :client

    class Client
      attr_reader :die

      def initialize(sink_endpoint)
        @socket = Flatware.socket ZMQ::PUSH, connect: sink_endpoint
        @die = Flatware.socket ZMQ::SUB, connect: 'ipc://die'
        die.setsockopt ZMQ::SUBSCRIBE, ''
      end

      %w[finished started progress checkpoint].each do |message|
        define_method message do |content|
          push [message.to_sym, content]
        end
      end

      private

      def push(message)
        if die.recv(false) == 'seppuku'
          Flatware.close
          exit(0)
        else
          @socket.send message
        end
      end
    end
  end
end<commit_msg>Use named arguments for non-blocking recv<commit_after>require 'flatware/socket'
module Flatware
  module Sink
    extend self
    attr_accessor :client

    class Client
      attr_reader :die

      def initialize(sink_endpoint)
        @socket = Flatware.socket ZMQ::PUSH, connect: sink_endpoint
        @die = Flatware.socket ZMQ::SUB, connect: 'ipc://die'
        die.setsockopt ZMQ::SUBSCRIBE, ''
      end

      %w[finished started progress checkpoint].each do |message|
        define_method message do |content|
          push [message.to_sym, content]
        end
      end

      private

      def push(message)
        if die.recv(block: false) == 'seppuku'
          Flatware.close
          exit(0)
        else
          @socket.send message
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07943625880845612, 'fraction_numerical': 0.0012812299807815502, 'mean_word_length': 2.062745098039216, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6930685', 'n_tokens_mistral': 486, 'n_tokens_neox': 458, 'n_words': 125}