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



30
31
32
33
34
35
36
# File 'lib/karafka/pro/recurring_tasks/dispatcher.rb', line 30

def command(name, task_id)
  produce(
    topics.schedules.name,
    "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)


40
41
42
43
44
45
46
# File 'lib/karafka/pro/recurring_tasks/dispatcher.rb', line 40

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

.scheduleObject

Snapshots to Kafka current schedule state



17
18
19
20
21
22
23
# File 'lib/karafka/pro/recurring_tasks/dispatcher.rb', line 17

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