From 35830054da4520801c061e81bc9b0dfaa1477f80 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 23 Sep 2020 11:40:16 -0500 Subject: [PATCH] Add more @!attribute tags [skip ci] --- lib/puma.rb | 3 +++ lib/puma/binder.rb | 2 ++ lib/puma/client.rb | 2 ++ lib/puma/cluster.rb | 2 ++ lib/puma/launcher.rb | 8 ++++++++ lib/puma/minissl.rb | 8 ++++++++ lib/puma/single.rb | 1 + lib/puma/thread_pool.rb | 2 ++ lib/puma/util.rb | 1 + 9 files changed, 29 insertions(+) diff --git a/lib/puma.rb b/lib/puma.rb index 1e098bffc0..98bbed55df 100644 --- a/lib/puma.rb +++ b/lib/puma.rb @@ -18,15 +18,18 @@ module Puma autoload :Server, 'puma/server' autoload :Launcher, 'puma/launcher' + # @!attribute [rw] stats_object= def self.stats_object=(val) @get_stats = val end + # @!attribute [rw] stats_object def self.stats require 'json' @get_stats.stats.to_json end + # @!attribute [r] stats_hash # @version 5.0.0 def self.stats_hash @get_stats.stats diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index ae300f3795..3f969d204f 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -66,6 +66,7 @@ def close @ios.each { |i| i.close } end + # @!attribute [r] connected_ports # @version 5.0.0 def connected_ports ios.map { |io| io.addr[1] }.uniq @@ -391,6 +392,7 @@ def redirects_for_restart_env private + # @!attribute [r] loopback_addresses def loopback_addresses Socket.ip_address_list.select do |addrinfo| addrinfo.ipv6_loopback? || addrinfo.ipv4_loopback? diff --git a/lib/puma/client.rb b/lib/puma/client.rb index 1b7c0ea018..4289f592c8 100644 --- a/lib/puma/client.rb +++ b/lib/puma/client.rb @@ -85,6 +85,7 @@ def initialize(io, env=nil) def_delegators :@io, :closed? + # @!attribute [r] inspect def inspect "#" end @@ -96,6 +97,7 @@ def call env[HIJACK_IO] ||= @io end + # @!attribute [r] in_data_phase def in_data_phase !@read_header end diff --git a/lib/puma/cluster.rb b/lib/puma/cluster.rb index c1bcc3169b..95f97deb29 100644 --- a/lib/puma/cluster.rb +++ b/lib/puma/cluster.rb @@ -194,6 +194,7 @@ def cull_workers end end + # @!attribute [r] next_worker_index def next_worker_index all_positions = 0...@options[:workers] occupied_positions = @workers.map { |w| w.index } @@ -396,6 +397,7 @@ def reload_worker_directory # Inside of a child process, this will return all zeroes, as @workers is only populated in # the master process. + # @!attribute [r] stats def stats old_worker_count = @workers.count { |w| w.phase != @phase } worker_status = @workers.map do |w| diff --git a/lib/puma/launcher.rb b/lib/puma/launcher.rb index 1b8c9ed9d7..06ae028412 100644 --- a/lib/puma/launcher.rb +++ b/lib/puma/launcher.rb @@ -188,11 +188,13 @@ def run end # Return all tcp ports the launcher may be using, TCP or SSL + # @!attribute [r] connected_ports # @version 5.0.0 def connected_ports @binder.connected_ports end + # @!attribute [r] restart_args def restart_args cmd = @options[:restart_cmd] if cmd @@ -207,6 +209,7 @@ def close_binder_listeners @binder.close_listeners end + # @!attribute [r] thread_status # @version 5.0.0 def thread_status Thread.list.each do |thread| @@ -261,6 +264,7 @@ def restart! end end + # @!attribute [r] dependencies_and_files_to_require_after_prune def dependencies_and_files_to_require_after_prune puma = spec_for_gem("puma") @@ -271,6 +275,7 @@ def dependencies_and_files_to_require_after_prune [deps, require_paths_for_gem(puma) + extra_runtime_deps_directories] end + # @!attribute [r] extra_runtime_deps_directories def extra_runtime_deps_directories Array(@options[:extra_runtime_dependencies]).map do |d_name| if (spec = spec_for_gem(d_name)) @@ -282,6 +287,7 @@ def extra_runtime_deps_directories end.flatten.compact end + # @!attribute [r] puma_wild_location def puma_wild_location puma = spec_for_gem("puma") dirs = require_paths_for_gem(puma) @@ -345,6 +351,7 @@ def set_process_title Process.respond_to?(:setproctitle) ? Process.setproctitle(title) : $0 = title end + # @!attribute [r] title def title buffer = "puma #{Puma::Const::VERSION} (#{@options[:binds].join(',')})" buffer += " [#{@options[:tag]}]" if @options[:tag] && !@options[:tag].empty? @@ -356,6 +363,7 @@ def set_rack_environment ENV['RACK_ENV'] = environment end + # @!attribute [r] environment def environment @environment end diff --git a/lib/puma/minissl.rb b/lib/puma/minissl.rb index 3f2e89673d..86468d5eb4 100644 --- a/lib/puma/minissl.rb +++ b/lib/puma/minissl.rb @@ -24,6 +24,7 @@ def initialize(socket, engine) @peercert = nil end + # @!attribute [r] to_io def to_io @socket end @@ -38,6 +39,7 @@ def closed? # # Used for dropping tcp connections to ssl. # See OpenSSL ssl/ssl_stat.c SSL_state_string for info + # @!attribute [r] ssl_version_state # @version 5.0.0 # def ssl_version_state @@ -188,10 +190,12 @@ def close end end + # @!attribute [r] peeraddr def peeraddr @socket.peeraddr end + # @!attribute [r] peercert def peercert return @peercert if @peercert @@ -264,12 +268,14 @@ def check end # disables TLSv1 + # @!attribute [w] no_tlsv1= def no_tlsv1=(tlsv1) raise ArgumentError, "Invalid value of no_tlsv1=" unless ['true', 'false', true, false].include?(tlsv1) @no_tlsv1 = tlsv1 end # disables TLSv1 and TLSv1.1. Overrides `#no_tlsv1=` + # @!attribute [w] no_tlsv1_1= def no_tlsv1_1=(tlsv1_1) raise ArgumentError, "Invalid value of no_tlsv1_1=" unless ['true', 'false', true, false].include?(tlsv1_1) @no_tlsv1_1 = tlsv1_1 @@ -287,6 +293,7 @@ def initialize(socket, ctx) @ctx = ctx end + # @!attribute [r] to_io def to_io @socket end @@ -307,6 +314,7 @@ def accept_nonblock Socket.new io, engine end + # @!attribute [r] addr # @version 5.0.0 def addr @socket.addr diff --git a/lib/puma/single.rb b/lib/puma/single.rb index 96b235db87..cd4edaf119 100644 --- a/lib/puma/single.rb +++ b/lib/puma/single.rb @@ -13,6 +13,7 @@ module Puma # gets created via the `start_server` method from the `Puma::Runner` class # that this inherits from. class Single < Runner + # @!attribute [r] stats def stats { started_at: @started_at.utc.iso8601 diff --git a/lib/puma/thread_pool.rb b/lib/puma/thread_pool.rb index a7966bcd78..7a8ff83ee0 100644 --- a/lib/puma/thread_pool.rb +++ b/lib/puma/thread_pool.rb @@ -82,10 +82,12 @@ def backlog with_mutex { @todo.size } end + # @!attribute [r] pool_capacity def pool_capacity waiting + (@max - spawned) end + # @!attribute [r] busy_threads # @version 5.0.0 def busy_threads with_mutex { @spawned - @waiting + @todo.size } diff --git a/lib/puma/util.rb b/lib/puma/util.rb index 51ea0b2ce6..ff36cc9771 100644 --- a/lib/puma/util.rb +++ b/lib/puma/util.rb @@ -72,6 +72,7 @@ def each end end + # @!attribute [r] to_hash def to_hash hash = {} each { |k,v| hash[k] = v }