Sha256: 8aafd0c0f571da812e2dd70d34aa306b9a94746d384f737a3e5a6456ad4dded2

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module RestFtpDaemon
  module API
    class Debug < Grape::API

      ### HELPERS
      helpers do

        def debug_metrics
          Metrics.sample
        end

        def debug_encodings
          # Encodings
          encodings = {}
          jobs = $queue.jobs

          jobs.each do |job|
            # here = out[job.id] = {}
            me = encodings[job.id] = {}

            me[:error] = job.error.encoding.to_s unless job.error.nil?
            me[:status] = job.status.encoding.to_s unless job.status.nil?

            Job::FIELDS.each do |name|
              value = job.send(name)
              me[name] = value.encoding.to_s if value.is_a? String
            end

            job.infos.each do |name, value|
              me["infos_#{name}"] = value.encoding.to_s if value.is_a? String
            end
          end
        end

      end

      ### ENDPOINTS
      desc "debug"
      get "/" do
       # Build response
       return  {
          metrics: debug_metrics,
          routes: RestFtpDaemon::API::Root.routes,
          encodings: debug_encodings,
          }
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.300.3 lib/rest-ftp-daemon/api/debug.rb
rest-ftp-daemon-0.300.2 lib/rest-ftp-daemon/api/debug.rb
rest-ftp-daemon-0.300.1 lib/rest-ftp-daemon/api/debug.rb