Class: Ci::BuildRunnerSession

Inherits:
ApplicationRecord show all
Includes:
Partitionable
Defined in:
app/models/ci/build_runner_session.rb

Overview

The purpose of this class is to store Build related runner session. Data will be removed after transitioning from running to any state.

Constant Summary collapse

TERMINAL_SUBPROTOCOL =
'terminal.gitlab.com'
DEFAULT_SERVICE_NAME =
'build'
DEFAULT_PORT_NAME =
'default_port'

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Instance Method Summary collapse

Methods included from Partitionable

registered_models

Methods inherited from ApplicationRecord

model_name, table_name_prefix

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Instance Method Details

#service_specification(service: nil, path: nil, port: nil, subprotocols: nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/ci/build_runner_session.rb', line 35

def service_specification(service: nil, path: nil, port: nil, subprotocols: nil)
  return {} unless url.present?

  port = port.presence || DEFAULT_PORT_NAME
  service = service.presence || DEFAULT_SERVICE_NAME
  parsed_url = URI.parse(Addressable::URI.escape(url))
  parsed_url.path += "/proxy/#{service}/#{port}/#{path}"
  subprotocols = subprotocols.presence || ::Ci::BuildRunnerSession::TERMINAL_SUBPROTOCOL

  channel_specification(parsed_url, subprotocols)
end

#terminal_specificationObject



26
27
28
29
30
31
32
33
# File 'app/models/ci/build_runner_session.rb', line 26

def terminal_specification
  wss_url = Gitlab::UrlHelpers.as_wss(Addressable::URI.escape(url))
  return {} unless wss_url.present?

  parsed_wss_url = URI.parse(wss_url)
  parsed_wss_url.path += '/exec'
  channel_specification(parsed_wss_url, TERMINAL_SUBPROTOCOL)
end