Skip to content

Commit

Permalink
Add more @!attribute tags [skip ci] (#2385)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Sep 25, 2020
1 parent d557c0a commit 4e78060
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/puma.rb
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/puma/binder.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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?
Expand Down
2 changes: 2 additions & 0 deletions lib/puma/client.rb
Expand Up @@ -85,6 +85,7 @@ def initialize(io, env=nil)

def_delegators :@io, :closed?

# @!attribute [r] inspect
def inspect
"#<Puma::Client:0x#{object_id.to_s(16)} @ready=#{@ready.inspect}>"
end
Expand All @@ -96,6 +97,7 @@ def call
env[HIJACK_IO] ||= @io
end

# @!attribute [r] in_data_phase
def in_data_phase
!@read_header
end
Expand Down
2 changes: 2 additions & 0 deletions lib/puma/cluster.rb
Expand Up @@ -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 }
Expand Down Expand Up @@ -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|
Expand Down
8 changes: 8 additions & 0 deletions lib/puma/launcher.rb
Expand Up @@ -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
Expand All @@ -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|
Expand Down Expand Up @@ -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")

Expand All @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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?
Expand All @@ -356,6 +363,7 @@ def set_rack_environment
ENV['RACK_ENV'] = environment
end

# @!attribute [r] environment
def environment
@environment
end
Expand Down
8 changes: 8 additions & 0 deletions lib/puma/minissl.rb
Expand Up @@ -24,6 +24,7 @@ def initialize(socket, engine)
@peercert = nil
end

# @!attribute [r] to_io
def to_io
@socket
end
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -287,6 +293,7 @@ def initialize(socket, ctx)
@ctx = ctx
end

# @!attribute [r] to_io
def to_io
@socket
end
Expand All @@ -307,6 +314,7 @@ def accept_nonblock
Socket.new io, engine
end

# @!attribute [r] addr
# @version 5.0.0
def addr
@socket.addr
Expand Down
1 change: 1 addition & 0 deletions lib/puma/single.rb
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/puma/thread_pool.rb
Expand Up @@ -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 }
Expand Down
1 change: 1 addition & 0 deletions lib/puma/util.rb
Expand Up @@ -72,6 +72,7 @@ def each
end
end

# @!attribute [r] to_hash
def to_hash
hash = {}
each { |k,v| hash[k] = v }
Expand Down

0 comments on commit 4e78060

Please sign in to comment.