Class: Yes::Core::ProcessManagers::CommandRunner Abstract

Inherits:
Base
  • Object
show all
Defined in:
lib/yes/core/process_managers/command_runner.rb

Overview

This class is abstract.

Subclass and override Base#call to implement command publishing logic.

Publishes commands to a command API client with automatic access token retrieval.

Examples:

class MyCommandRunner < Yes::Core::ProcessManagers::CommandRunner
  def call(event)
    publish(
      client_id: ENV['CLIENT_ID'],
      client_secret: ENV['CLIENT_SECRET'],
      commands_data: [{ context: 'Foo', aggregate: 'Bar', command: 'create', params: {} }]
    )
  end
end

Instance Method Summary collapse

Methods inherited from Base

#call

Constructor Details

#initialize(command_api_client: nil) ⇒ CommandRunner

Initializes a new CommandRunner instance.

Parameters:

  • command_api_client (ServiceClient, nil) (defaults to: nil)

    the API client to use for sending commands



35
36
37
38
39
40
41
# File 'lib/yes/core/process_managers/command_runner.rb', line 35

def initialize(command_api_client: nil)
  super()

  @command_api_client = command_api_client
  @access_token_client = AccessTokenClient.new
  @logger = Rails.logger
end