Skip to content

Commit 502e008

Browse files
committed
feat: added protocol to endpoint
1 parent caf6622 commit 502e008

10 files changed

Lines changed: 22 additions & 3 deletions

File tree

app/graphql/types/runtime_module_definition_type.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class RuntimeModuleDefinitionType < Types::BaseObject
99
field :endpoint, String, null: false, description: 'Endpoint path of the module definition'
1010
field :host, String, null: false, description: 'Host of the module definition endpoint'
1111
field :port, Types::BigIntType, null: false, description: 'Port of the module definition endpoint'
12+
field :protocol, String, null: false, description: 'Protocol of the module definition endpoint'
1213

1314
id_field RuntimeModuleDefinition
1415
timestamps

app/models/runtime_module_definition.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class RuntimeModuleDefinition < ApplicationRecord
55

66
validates :host, presence: true, length: { maximum: 253 }
77
validates :endpoint, presence: true, length: { maximum: 2048 }
8+
validates :protocol, presence: true, length: { maximum: 255 }
89
validates :port, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 65_535 }
910

1011
def nilify_attributes!(except = %w[id runtime_module_id created_at updated_at])

app/services/runtimes/grpc/modules/update_service.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def update_module_definitions(module_records, t)
126126
db_module_definitions[index].assign_attributes(
127127
host: endpoint.host,
128128
port: endpoint.port,
129-
endpoint: endpoint.endpoint
129+
endpoint: endpoint.endpoint,
130+
protocol: endpoint.protocol
130131
)
131132

132133
next if db_module_definitions[index].save
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class AddProtocolToRuntimeModuleDefinitions < Code0::ZeroTrack::Database::Migration[1.0]
4+
def change
5+
add_column :runtime_module_definitions, :protocol, :text, null: false, limit: 255 # rubocop:disable Rails/NotNullColumn
6+
end
7+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0e26705576a3693d4c97e0b356d76dd1404bff272b550da59753960fe2e28d74

db/structure.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,10 @@ CREATE TABLE runtime_module_definitions (
931931
endpoint text NOT NULL,
932932
created_at timestamp with time zone NOT NULL,
933933
updated_at timestamp with time zone NOT NULL,
934+
protocol text NOT NULL,
934935
CONSTRAINT check_5328b69b6f CHECK ((char_length(host) <= 253)),
935-
CONSTRAINT check_5a8231f609 CHECK ((char_length(endpoint) <= 2048))
936+
CONSTRAINT check_5a8231f609 CHECK ((char_length(endpoint) <= 2048)),
937+
CONSTRAINT check_cdbfabb698 CHECK ((char_length(protocol) <= 255))
936938
);
937939

938940
CREATE SEQUENCE runtime_module_definitions_id_seq

spec/factories/runtime_module_definitions.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
host { 'localhost' }
77
port { 3000 }
88
endpoint { '/runtime' }
9+
protocol { 'https' }
910
end
1011
end

spec/graphql/types/runtime_module_definition_type_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
host
1010
port
1111
endpoint
12+
protocol
1213
createdAt
1314
updatedAt
1415
]

spec/models/runtime_module_definition_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
describe 'validations' do
1313
it { is_expected.to validate_presence_of(:host) }
1414
it { is_expected.to validate_presence_of(:endpoint) }
15+
it { is_expected.to validate_presence_of(:protocol) }
16+
it { is_expected.to validate_length_of(:protocol).is_at_most(255) }
1517

1618
it {
1719
is_expected.to validate_numericality_of(:port)

spec/requests/grpc/sagittarius/module_service_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
host: 'localhost',
130130
port: 8080,
131131
endpoint: '/execute',
132+
protocol: 'https',
132133
},
133134
}
134135
],
@@ -193,7 +194,8 @@
193194
expect(module_definition).to have_attributes(
194195
host: 'localhost',
195196
port: 8080,
196-
endpoint: '/execute'
197+
endpoint: '/execute',
198+
protocol: 'https'
197199
)
198200
end
199201

0 commit comments

Comments
 (0)