Class: Ci::BuildRunnerSession

Inherits:
ApplicationRecord show all
Extended by:
Gitlab::Ci::Model
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'.freeze
DEFAULT_PORT_NAME =
'default_port'.freeze

Instance Method Summary collapse

Methods included from Gitlab::Ci::Model

model_name, table_name_prefix

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Instance Method Details

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


28
29
30
31
32
33
34
35
36
37
# File 'app/models/ci/build_runner_session.rb', line 28

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
  url = "#{self.url}/proxy/#{service}/#{port}/#{path}"
  subprotocols = subprotocols.presence || ::Ci::BuildRunnerSession::TERMINAL_SUBPROTOCOL

  channel_specification(url, subprotocols)
end

#terminal_specificationObject


20
21
22
23
24
25
26
# File 'app/models/ci/build_runner_session.rb', line 20

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

  wss_url = "#{wss_url}/exec"
  channel_specification(wss_url, TERMINAL_SUBPROTOCOL)
end