Sha256: 6e026841c7add1b6a3f24f9565a90d3c8a283bc873151c7d11f9891a5e5ac36f

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require 'socket'
require 'timeout'
require 'thwait'
require 'yaml'

require 'nonnative/version'
require 'nonnative/error'
require 'nonnative/timeout'
require 'nonnative/port'
require 'nonnative/configuration'
require 'nonnative/configuration_process'
require 'nonnative/configuration_server'
require 'nonnative/system'
require 'nonnative/pool'
require 'nonnative/server'
require 'nonnative/logger'

module Nonnative
  class << self
    def logger
      @logger ||= Nonnative::Logger.create
    end

    def load_configuration(path)
      @configuration ||= Nonnative::Configuration.load_file(path) # rubocop:disable Naming/MemoizedInstanceVariableName
    end

    def configuration
      @configuration ||= Nonnative::Configuration.new
    end

    def configure
      yield configuration if block_given?

      require "nonnative/#{configuration.strategy}"
    end

    def start
      @pool ||= Nonnative::Pool.new(configuration)

      @pool.start do |id, result|
        logger.error('Process has started though did respond in time', id: id) unless result
      end
    end

    def stop
      return if @pool.nil?

      @pool.stop do |id, result|
        logger.error('Process has stopped though did respond in time', id: id) unless result
      end
    end

    def clear
      @logger = nil
      @configuration = nil
      @process_pool = nil
      @pool = nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nonnative-1.3.0 lib/nonnative.rb