Skip to content

Commit a6947fa

Browse files
committed
Inital work on detailed statuses for runtimes
1 parent c227828 commit a6947fa

38 files changed

+546
-36
lines changed

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.47'
82+
gem 'tucana', '0.0.0', path: '../tucana/build/ruby'
8383

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

Gemfile.lock

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
PATH
2+
remote: ../tucana/build/ruby
3+
specs:
4+
tucana (0.0.0)
5+
grpc (~> 1.64)
6+
17
GEM
28
remote: https://rubygems.org/
39
specs:
@@ -376,8 +382,6 @@ GEM
376382
thor (1.4.0)
377383
timeout (0.4.4)
378384
tsort (0.2.0)
379-
tucana (0.0.47)
380-
grpc (~> 1.64)
381385
tzinfo (2.0.6)
382386
concurrent-ruby (~> 1.0)
383387
unicode-display_width (2.6.0)
@@ -430,7 +434,7 @@ DEPENDENCIES
430434
simplecov (~> 0.22.0)
431435
simplecov-cobertura (~> 3.0)
432436
test-prof (~> 1.0)
433-
tucana (= 0.0.47)
437+
tucana (= 0.0.0)!
434438
tzinfo-data
435439

436440
RUBY VERSION
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
class RuntimeStatusConfigurationEndpointType < Types::BaseObject
5+
description 'Detailed information about a runtime status'
6+
7+
field :endpoint, String, null: false, description: 'The endpoint URL of the runtime'
8+
9+
id_field ::RuntimeStatusConfiguration
10+
timestamps
11+
end
12+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
class RuntimeStatusConfigurationType < Types::BaseUnion
5+
description 'Detailed configuration about a runtime status, either: endpoint, ...'
6+
7+
possible_types Types::RuntimeStatusConfigurationEndpointType
8+
9+
def self.resolve_type(object, _context)
10+
return Types::RuntimeStatusConfigurationEndpointType if object.endpoint.present?
11+
12+
raise "Unknown RuntimeStatusInformation type: #{object.class.name}"
13+
end
14+
end
15+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
class RuntimeStatusEnum < BaseEnum
5+
description 'Represent all available aquila statuses'
6+
7+
value :CONNECTED, 'No problem with the connection to aquila', value: :connected
8+
value :DISCONNECTED, 'The runtime is disconnected, cause unknown', value: :disconnected
9+
end
10+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
class RuntimeStatusStatusEnum < Types::BaseEnum
5+
description 'The enum status of the detailed status'
6+
7+
value :NOT_RESPONDING, 'The runtime is not responding to heartbeats', value: 'NOT_RESPONDING'
8+
value :NOT_READY, 'The runtime is not ready to compute stuff', value: 'NOT_READY'
9+
value :RUNNING, 'The runtime is running and healthy', value: 'RUNNING'
10+
value :STOPPED, 'The runtime has been stopped', value: 'STOPPED'
11+
end
12+
end
Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
# frozen_string_literal: true
22

33
module Types
4-
class RuntimeStatusType < BaseEnum
5-
description 'Represent all available types of statuses of a runtime'
4+
class RuntimeStatusType < Types::BaseObject
5+
description 'A runtime status information entry'
66

7-
value :CONNECTED, 'No problem with connection, everything works as expected', value: 'connected'
8-
value :DISCONNECTED, 'The runtime is disconnected, cause unknown', value: 'disconnected'
7+
field :configurations, Types::RuntimeStatusConfigurationType.connection_type,
8+
null: false,
9+
description: 'The detailed configuration entries for this runtime status (only for adapters)',
10+
method: :runtime_status_configurations
11+
field :feature_set, [String], null: false, description: 'The set of features supported by the runtime'
12+
field :identifier, String, null: false, description: 'The unique identifier for this runtime status'
13+
field :last_heartbeat, Types::TimeType, null: true,
14+
description: 'The timestamp of the last heartbeat received from the runtime'
15+
field :status, Types::RuntimeStatusStatusEnum,
16+
null: false,
17+
description: 'The current status of the runtime (e.g. running, stopped)'
18+
field :type, Types::RuntimeStatusTypeEnum,
19+
null: false,
20+
description: 'The type of runtime status information (e.g. adapter, execution)', method: :status_type
21+
22+
id_field RuntimeStatus
23+
timestamps
924
end
1025
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
class RuntimeStatusTypeEnum < Types::BaseEnum
5+
description 'The type of runtime status'
6+
7+
value :ADAPTER, 'Indicates that the runtime status is related to an adapter.', value: 'adapter'
8+
value :EXECUTION, 'Indicates that the runtime status is related to an execution.', value: 'execution'
9+
end
10+
end

app/graphql/types/runtime_type.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ class RuntimeType < Types::BaseObject
1616
field :runtime_function_definitions, Types::RuntimeFunctionDefinitionType.connection_type,
1717
null: false,
1818
description: 'Functions of the runtime'
19-
field :status, Types::RuntimeStatusType, null: false, description: 'The status of the runtime'
2019

2120
field :token, String, null: true, description: 'Token belonging to the runtime, only present on creation'
2221

22+
field :status, Types::RuntimeStatusStatusEnum,
23+
null: false,
24+
description: 'Wheater the last heartbeat was recent enough to consider the runtime as connected'
25+
field :statuses, Types::RuntimeStatusType.connection_type, null: false,
26+
description: 'Statuses of the runtime',
27+
method: :runtime_statuses
28+
2329
expose_abilities %i[
2430
delete_runtime
2531
update_runtime
@@ -29,6 +35,17 @@ class RuntimeType < Types::BaseObject
2935
id_field Runtime
3036
timestamps
3137

38+
# If the last heartbeat was within the last 10 minutes, consider the runtime as 'running'
39+
def status
40+
last_heartbeat = object.last_heartbeat
41+
42+
if last_heartbeat && last_heartbeat >= 10.minutes.ago
43+
:connected
44+
else
45+
:disconnected
46+
end
47+
end
48+
3249
def token
3350
object.token if object.token_previously_changed?
3451
end

app/grpc/flow_handler.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,12 @@ def self.update_runtime(runtime)
2525
)
2626
end
2727

28-
def self.update_started(runtime_id)
29-
runtime = Runtime.find(runtime_id)
30-
runtime.connected!
31-
runtime.save
32-
28+
def self.update_started(_runtime_id)
3329
logger.info(message: 'Runtime connected', runtime_id: runtime.id)
3430

3531
update_runtime(runtime)
3632
end
3733

38-
def self.update_died(runtime_id)
39-
runtime = Runtime.find(runtime_id)
40-
runtime.disconnected!
41-
runtime.save
42-
end
43-
4434
def self.encoders = { update: ->(grpc_object) { Tucana::Sagittarius::FlowResponse.encode(grpc_object) } }
4535

4636
def self.decoders = { update: ->(string) { Tucana::Sagittarius::FlowResponse.decode(string) } }

0 commit comments

Comments
 (0)