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



26
27
28
29
30
31
32
# File 'lib/karafka/pro/recurring_tasks/dispatcher.rb', line 26

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)


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

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

.scheduleObject

Snapshots to Kafka current schedule state



13
14
15
16
17
18
19
# File 'lib/karafka/pro/recurring_tasks/dispatcher.rb', line 13

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