Sha256: ac68d3321a1f92f936a291ec850d939f9c5e161c710a00feac7d4f0cfa208de4

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'dry-struct'
require 'host_status/types'

module HostStatus
  class Application < Dry::Struct
    transform_keys(&:to_sym)

    attribute :name, HostStatus::Types::Strict::String
    attribute :id, Types::Optional
    attribute :url, Types::Url
    attribute :api_url, Types::Url
    attribute :language, Types::Optional
    attribute :process_count, Types::Count
    attribute :online, Types::IsUp

    # all numbers are per minute
    attribute :errors, Types::RatePerMinute
    attribute :throughput, Types::RatePerMinute
    attribute :latency_p50, Types::RatePerMinute
    attribute :latency_p90, Types::RatePerMinute

    class Proxy
      attr_accessor :app

      def initialize(**opts, &block)
        options  = transform_arguments(**opts)
        self.app = Application.new(**options, &block)
      end

      def method_missing(method, *args, &block)
        if app&.respond_to?(method)
          app&.send(method, *args, &block)
        else
          super(method, *args, &block)
        end
      end

      def transform_arguments(**opts)
        opts
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
host_status-0.1.0 lib/host_status/application.rb