Class: TRMNLP::TransformClient
- Inherits:
-
Object
- Object
- TRMNLP::TransformClient
- Defined in:
- lib/trmnlp/transform_client.rb
Overview
Strategy host for serverless transform execution. Local plugin development hits the Subprocess backend by default — transforms run in trmnlp’s own image alongside Ruby, no daemon required. Setting ‘serverless_daemon_url` in .trmnlp.yml swaps in the Http backend so plugin authors can target a real remote transform daemon (production parity testing, shared team daemons, etc.).
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
Class Method Summary collapse
- .backend_for(project_config) ⇒ Object
-
.from_config(project_config) ⇒ Object
Returns nil when serverless is disabled in .trmnlp.yml so the pipeline can short-circuit without a per-request check.
Instance Method Summary collapse
- #execute(code:, language:, stdin: '', timeout_seconds: 30) ⇒ Object
-
#initialize(backend:) ⇒ TransformClient
constructor
A new instance of TransformClient.
Constructor Details
#initialize(backend:) ⇒ TransformClient
Returns a new instance of TransformClient.
36 37 38 |
# File 'lib/trmnlp/transform_client.rb', line 36 def initialize(backend:) @backend = backend end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
17 18 19 |
# File 'lib/trmnlp/transform_client.rb', line 17 def backend @backend end |
Class Method Details
.backend_for(project_config) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/trmnlp/transform_client.rb', line 28 def self.backend_for(project_config) if (url = project_config.serverless_daemon_url) TransformBackend::Http.new(url: url, api_key: project_config.serverless_daemon_api_key) else TransformBackend::Subprocess.new end end |
.from_config(project_config) ⇒ Object
Returns nil when serverless is disabled in .trmnlp.yml so the pipeline can short-circuit without a per-request check.
21 22 23 24 25 26 |
# File 'lib/trmnlp/transform_client.rb', line 21 def self.from_config(project_config) runtime = project_config.transform_runtime return nil if runtime.nil? || runtime.to_s == 'disabled' new(backend: backend_for(project_config)) end |
Instance Method Details
#execute(code:, language:, stdin: '', timeout_seconds: 30) ⇒ Object
40 41 42 |
# File 'lib/trmnlp/transform_client.rb', line 40 def execute(code:, language:, stdin: '', timeout_seconds: 30) backend.execute(code:, language:, stdin:, timeout_seconds:) end |