Class: Ci::BuildRunnerSession

Inherits:
ApplicationRecord show all
Includes:
Partitionable, SafelyChangeColumnDefault
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 included from Partitionable

Partitionable::MUTEX

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Method Summary collapse

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, 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 SensitiveSerializableHash

#serializable_hash

Instance Method Details

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



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

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



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

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