Class: Karafka::Web::Pro::Commanding::Handlers::Topics::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/web/pro/commanding/handlers/topics/executor.rb

Overview

Selects proper command for running prior to next poll and executes its flow

Instance Method Summary collapse

Instance Method Details

#call(listener, client, request) ⇒ Object

Parameters:

  • listener (Karafka::Connection::Listener)
  • client (Karafka::Connection::Client)
  • request (Request)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/karafka/web/pro/commanding/handlers/topics/executor.rb', line 42

def call(listener, client, request)
  command = case request.name
  when Commanding::Commands::Topics::Resume.name
    Commands::Resume
  when Commanding::Commands::Topics::Pause.name
    Commands::Pause
  else
    raise ::Karafka::Errors::UnsupportedCaseError, request.name
  end

  command.new(
    listener,
    client,
    request
  ).call
end

#reject(request) ⇒ Object

Publishes the reject event as the final result. Used to indicate, that given request will not be processed because it is not valid anymore.

Parameters:



63
64
65
66
67
68
69
# File 'lib/karafka/web/pro/commanding/handlers/topics/executor.rb', line 63

def reject(request)
  Dispatcher.result(
    request.name,
    process_id,
    request.to_h.merge(status: "rebalance_rejected")
  )
end