Class: Pvectl::Commands::Top::Handlers::Nodes

Inherits:
Object
  • Object
show all
Includes:
ResourceHandler
Defined in:
lib/pvectl/commands/top/handlers/nodes.rb

Overview

Handler for Top command node metrics display.

Wraps Get::Handlers::Nodes to fetch node data and pairs it with TopNode presenter for metrics-focused output.

Examples:

Using via ResourceRegistry

handler = Top::ResourceRegistry.for("nodes")
nodes = handler.list(sort: "cpu")
presenter = handler.presenter

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(get_handler: nil) ⇒ Nodes

Creates handler with optional Get handler for dependency injection.

Parameters:



26
27
28
# File 'lib/pvectl/commands/top/handlers/nodes.rb', line 26

def initialize(get_handler: nil)
  @get_handler = get_handler
end

Instance Method Details

#list(sort: nil, **_) ⇒ Array<Models::Node>

Lists nodes with optional sorting.

Parameters:

  • sort (String, nil) (defaults to: nil)

    sort field (cpu, memory, disk)

Returns:



34
35
36
# File 'lib/pvectl/commands/top/handlers/nodes.rb', line 34

def list(sort: nil, **_)
  get_handler.list(sort: sort)
end

#presenterPresenters::TopNode

Returns Top-specific presenter for nodes.

Returns:



41
42
43
# File 'lib/pvectl/commands/top/handlers/nodes.rb', line 41

def presenter
  Presenters::TopNode.new
end