Class: Karafka::Pro::RecurringTasks::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/pro/recurring_tasks/dispatcher.rb

Overview

Dispatches appropriate recurring tasks related messages to expected topics

Class Method Summary collapse

Class Method Details

.command(name, task_id) ⇒ Object

Dispatches the command request

Parameters:

  • name (String, Symbol)

    name of the command we want to deal with in the process

  • task_id (String)

    id of the process. We use name instead of id only because in the web ui we work with the full name and it is easier. Since



34
35
36
37
38
39
40
# File 'lib/karafka/pro/recurring_tasks/dispatcher.rb', line 34

def command(name, task_id)
  produce(
    topics.schedules,
    "command:#{name}:#{task_id}",
    serializer.command(name, task_id)
  )
end

.log(event) ⇒ Object

Dispatches the task execution log record

Parameters:

  • event (Karafka::Core::Monitoring::Event)


44
45
46
47
48
49
50
# File 'lib/karafka/pro/recurring_tasks/dispatcher.rb', line 44

def log(event)
  produce(
    topics.logs,
    event[:task].id,
    serializer.log(event)
  )
end

.scheduleObject

Snapshots to Kafka current schedule state



21
22
23
24
25
26
27
# File 'lib/karafka/pro/recurring_tasks/dispatcher.rb', line 21

def schedule
  produce(
    topics.schedules,
    'state:schedule',
    serializer.schedule(::Karafka::Pro::RecurringTasks.schedule)
  )
end