Skip to content

Commit 9cee217

Browse files
Merge pull request #1026 from code0-tech/#1023-function-identifier-to-execution-result
function identifier to execution result & runtime module definition
2 parents 88ec3e1 + 1a4c2fc commit 9cee217

38 files changed

Lines changed: 348 additions & 51 deletions

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ gem 'good_job', '~> 4.0'
7979
gem 'rotp'
8080

8181
gem 'grpc', '~> 1.67'
82-
gem 'tucana', '0.0.73'
82+
gem 'tucana', '0.0.74'
8383

8484
gem 'code0-identities', '~> 0.0.3'
8585

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ GEM
390390
open3 (~> 0.2)
391391
tucana (~> 0.0, >= 0.0.72)
392392
tsort (0.2.0)
393-
tucana (0.0.73)
393+
tucana (0.0.74)
394394
grpc (~> 1.64)
395395
tzinfo (2.0.6)
396396
concurrent-ruby (~> 1.0)
@@ -446,7 +446,7 @@ DEPENDENCIES
446446
simplecov-cobertura (~> 3.0)
447447
test-prof (~> 1.0)
448448
triangulum (= 0.21.0)
449-
tucana (= 0.0.73)
449+
tucana (= 0.0.74)
450450
tzinfo-data
451451

452452
RUBY VERSION

app/graphql/types/execution_node_result_type.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class ExecutionNodeResultType < Types::BaseObject
1212
field :finished_at, Types::BigIntType,
1313
null: false,
1414
description: 'Unix epoch time in microseconds when this node execution finished'
15+
field :function_definition, Types::FunctionDefinitionType,
16+
null: true,
17+
description: 'Function definition associated with this sub-flow result'
1518
field :node_function, Types::NodeFunctionType, null: true, description: 'Node function associated with this result'
1619
field :parameter_results, [Types::ExecutionParameterResultType],
1720
null: false,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
class RuntimeModuleDefinitionType < Types::BaseObject
5+
description 'A runtime module definition endpoint'
6+
7+
authorize :read_runtime_module
8+
9+
field :endpoint, String, null: false, description: 'Endpoint path of the module definition'
10+
field :host, String, null: false, description: 'Host of the module definition endpoint'
11+
field :port, Types::BigIntType, null: false, description: 'Port of the module definition endpoint'
12+
13+
id_field RuntimeModuleDefinition
14+
timestamps
15+
end
16+
end

app/graphql/types/runtime_module_type.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class RuntimeModuleType < Types::BaseObject
1212
description: 'Configuration definitions of the runtime module',
1313
method: :module_configuration_definitions
1414
field :data_types, Types::DataTypeType.connection_type, null: false, description: 'Data types of the runtime module'
15+
field :definitions, Types::RuntimeModuleDefinitionType.connection_type,
16+
null: false,
17+
description: 'Definitions of the runtime module',
18+
method: :runtime_module_definitions
1519
field :descriptions, [Types::TranslationType], null: true, description: 'Descriptions of the runtime module'
1620
field :documentation, String, null: false, description: 'Documentation URL of the runtime module'
1721
field :flow_types, Types::FlowTypeType.connection_type, null: false, description: 'Flow types of the runtime module'

app/graphql/types/runtime_status_type.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ class RuntimeStatusType < Types::BaseObject
55
description 'A runtime status information entry'
66

77
authorize :read_runtime
8-
98
field :configurations, Types::RuntimeStatusConfigurationType.connection_type,
109
null: false,
1110
description: 'The detailed configuration entries for this runtime status (only for adapters)',
@@ -18,10 +17,10 @@ class RuntimeStatusType < Types::BaseObject
1817
description: 'The timestamp of the last heartbeat received from the runtime'
1918
field :status, Types::RuntimeStatusStatusEnum,
2019
null: false,
21-
description: 'The current status of the runtime (e.g. running, stopped)'
22-
field :type, Types::RuntimeStatusTypeEnum,
20+
description: 'The current status of the runtime'
21+
field :type, RuntimeStatusTypeEnum,
2322
null: false,
24-
description: 'The type of runtime status information (e.g. adapter, execution)',
23+
description: 'Type of the runtime status',
2524
method: :status_type
2625

2726
id_field RuntimeStatus

app/grpc/runtime_status_handler.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ class RuntimeStatusHandler < Tucana::Sagittarius::RuntimeStatusService::Service
44
include Code0::ZeroTrack::Loggable
55
include GrpcHandler
66

7-
def update(request, _call)
7+
# TODO: Implement in #1018
8+
def update_disabled(request, _call)
89
current_runtime = Runtime.find(Code0::ZeroTrack::Context.current[:runtime][:id])
9-
status_info = case request.status
10-
when :adapter_runtime_status
11-
request.adapter_runtime_status
12-
when :execution_runtime_status
13-
request.execution_runtime_status
14-
else
15-
return Tucana::Sagittarius::RuntimeStatusUpdateResponse.new(success: false)
16-
end
10+
status_info = request.status
11+
return Tucana::Sagittarius::RuntimeStatusUpdateResponse.new(success: false) if status_info.nil?
1712

1813
response = Runtimes::Grpc::RuntimeStatusUpdateService.new(
1914
runtime: current_runtime,

app/models/execution_node_result.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33
class ExecutionNodeResult < ApplicationRecord
44
belongs_to :execution_result, inverse_of: :node_results
55
belongs_to :node_function, optional: true
6+
belongs_to :function_definition, optional: true
67

78
has_many :parameter_results,
89
class_name: 'ExecutionParameterResult',
910
inverse_of: :execution_node_result
1011

1112
validates :position, presence: true, numericality: { only_integer: true }
1213
validates :started_at, :finished_at, numericality: { only_integer: true }
14+
validate :only_one_execution_target_present
1315
validate :only_one_result_present
1416

1517
private
1618

19+
def only_one_execution_target_present
20+
return if [node_function.present?, function_definition.present?].count(true) == 1
21+
22+
errors.add(:base, 'Only one of node_function or function_definition must be present')
23+
end
24+
1725
def only_one_result_present
1826
return if [!success.nil?, !error.nil?].count(true) == 1
1927

app/models/runtime_module.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class RuntimeModule < ApplicationRecord
1111
has_many :runtime_function_definitions, inverse_of: :runtime_module
1212
has_many :function_definitions, inverse_of: :runtime_module
1313
has_many :module_configuration_definitions, inverse_of: :runtime_module
14+
has_many :runtime_module_definitions, inverse_of: :runtime_module
1415

1516
has_translation :names, purpose: :name
1617
has_translation :descriptions, purpose: :description
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
class RuntimeModuleDefinition < ApplicationRecord
4+
belongs_to :runtime_module, inverse_of: :runtime_module_definitions
5+
6+
validates :host, presence: true, length: { maximum: 253 }
7+
validates :endpoint, presence: true, length: { maximum: 2048 }
8+
validates :port, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 65_535 }
9+
end

0 commit comments

Comments
 (0)