<commit_before>require 'travis/config'
require 'travis/config/heroku'

module Travis
  module Hub
    class Config < Travis::Config
      class << self
        def http_basic_auth
          tokens = ENV['HTTP_BASIC_AUTH'] || ''
          tokens.split(',').map { |token| token.split(':').map(&:strip) }.to_h
        end

        def logs_api_url
          ENV['TRAVIS_HUB_LOGS_API_URL'] ||
            ENV['LOGS_API_URL'] ||
            'http://travis-logs-notset.example.com:1234'
        end

        def logs_api_auth_token
          ENV['TRAVIS_HUB_LOGS_API_AUTH_TOKEN'] ||
            ENV['LOGS_API_AUTH_TOKEN'] ||
            'notset'
        end
      end

      define amqp:           { username: 'guest', password: '<PASSWORD>', host: 'localhost', prefetch: 1 },
             database:       { adapter: 'postgresql', database: "travis_#{env}", encoding: 'unicode', min_messages: 'warning', pool: 25, reaping_frequency: 60, variables: { statement_timeout: 10000 } },
             logs_api:       { url: logs_api_url, token: logs_api_auth_token },
             redis:          { url: 'redis://localhost:6379' },
             sidekiq:        { namespace: 'sidekiq', pool_size: 1 },
             lock:           { strategy: :redis },
             states_cache:   { memcached_servers: 'localhost:11211', memcached_options: {} },
             logs:           { url: ENV['LOGS_URL'], token: ENV['LOGS_TOKEN'] },
             name:           'hub',
             host:           'travis-ci.org',
             encryption:     env == 'development' || env == 'test' ? { key: 'secret' * 10 } : {},
             logger:         { thread_id: true },
             librato:        {},
             sentry:         {},
             metrics:        { reporter: 'librato' },
             repository:     { ssl_key: { size: 4096 } },
             queue:          'builds',
             limit:          { resets: { max: 50, after: 6 * 60 * 60 } },
             notifications:  [],
             auth:           { jwt_public_key: ENV['JWT_RSA_PUBLIC_KEY'], http_basic_auth: http_basic_auth }

      def metrics
        # TODO cleanup keychain?
        super.to_h.merge(librato: librato.to_h.merge(source: librato_source), graphite: graphite)
      end

      def queue
        ENV['QUEUE'] || 'builds' # super
      end

      def threads<commit_msg>add ssl to the default config now that we account for it elsewhere<commit_after>require 'travis/config'
require 'travis/config/heroku'

module Travis
  module Hub
    class Config < Travis::Config
      class << self
        def http_basic_auth
          tokens = ENV['HTTP_BASIC_AUTH'] || ''
          tokens.split(',').map { |token| token.split(':').map(&:strip) }.to_h
        end

        def logs_api_url
          ENV['TRAVIS_HUB_LOGS_API_URL'] ||
            ENV['LOGS_API_URL'] ||
            'http://travis-logs-notset.example.com:1234'
        end

        def logs_api_auth_token
          ENV['TRAVIS_HUB_LOGS_API_AUTH_TOKEN'] ||
            ENV['LOGS_API_AUTH_TOKEN'] ||
            'notset'
        end
      end

      define amqp:           { username: 'guest', password: '<PASSWORD>', host: 'localhost', prefetch: 1 },
             database:       { adapter: 'postgresql', database: "travis_#{env}", encoding: 'unicode', min_messages: 'warning', pool: 25, reaping_frequency: 60, variables: { statement_timeout: 10000 } },
             logs_api:       { url: logs_api_url, token: logs_api_auth_token },
             redis:          { url: 'redis://localhost:6379' },
             sidekiq:        { namespace: 'sidekiq', pool_size: 1 },
             lock:           { strategy: :redis },
             states_cache:   { memcached_servers: 'localhost:11211', memcached_options: {} },
             logs:           { url: ENV['LOGS_URL'], token: ENV['LOGS_TOKEN'] },
             name:           'hub',
             host:           'travis-ci.org',
             encryption:     env == 'development' || env == 'test' ? { key: 'secret' * 10 } : {},
             logger:         { thread_id: true },
             librato:        {},
             sentry:         {},
             metrics:        { reporter: 'librato' },
             repository:     { ssl_key: { size: 4096 } },
             queue:          'builds',
             limit:          { resets: { max: 50, after: 6 * 60 * 60 } },
             notifications:  [],
             auth:           { jwt_public_key: ENV['JWT_RSA_PUBLIC_KEY'], http_basic_auth: http_basic_auth },
             ssl:            {}

      def metrics
        # TODO cleanup keychain?
        super.to_h.merge(librato: librato.to_h.merge(source: librato_source), graphite: graphite)
      end

      def queue
        ENV['QUEUE'] || 'builds' # super
      end

      def threads
{'fraction_non_alphanumeric': 0.12957509465713082, 'fraction_numerical': 0.015565839293226757, 'mean_word_length': 1.7629285299244626, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '2453314', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1435, 'n_words': 302}