Module: GDK::Services

Defined in:
lib/gdk/services.rb,
lib/gdk/services/base.rb,
lib/gdk/services/minio.rb,
lib/gdk/services/redis.rb,
lib/gdk/services/vault.rb,
lib/gdk/services/open_bao.rb,
lib/gdk/services/required.rb,
lib/gdk/services/open_ldap.rb,
lib/gdk/services/rails_web.rb,
lib/gdk/services/clickhouse.rb,
lib/gdk/services/postgresql.rb,
lib/gdk/services/redis_cluster.rb,
lib/gdk/services/gitlab_workhorse.rb,
lib/gdk/services/gitlab_ai_gateway.rb,
lib/gdk/services/gitlab_http_router.rb,
lib/gdk/services/postgresql_replica.rb,
lib/gdk/services/rails_background_jobs.rb,
lib/gdk/services/gitlab_topology_service.rb

Overview

Services module contains individual service classes (e.g. Redis) that are responsible for producing the correct command line to execute and if the service should in fact be executed.

Defined Under Namespace

Classes: Base, Clickhouse, GitlabAiGateway, GitlabHttpRouter, GitlabTopologyService, GitlabWorkhorse, Minio, OpenBao, OpenLDAP, Postgresql, PostgresqlReplica, RailsBackgroundJobs, RailsWeb, Redis, RedisCluster, Required, Vault

Constant Summary collapse

SERVICE_BASE_CLASSES =

This are the classes in Services modules that are used as base classes for services

%i[
  Base
  Required
  InvalidEnvironmentKeyError
].freeze
InvalidEnvironmentKeyError =
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.allArray<Class>

Returns an Array of all services, including enabled and not enabled.

Returns:

  • (Array<Class>)

    all services



27
28
29
30
31
# File 'lib/gdk/services.rb', line 27

def self.all
  all_service_names.map do |const|
    const_get(const).new
  end
end

.all_service_namesArray<Symbol>

Return a list of class names that represent a Service

Returns:

  • (Array<Symbol>)

    array of class names exposing a service



19
20
21
# File 'lib/gdk/services.rb', line 19

def self.all_service_names
  ::GDK::Services.constants.select { |c| ::GDK::Services.const_get(c).is_a? Class } - SERVICE_BASE_CLASSES
end

.enabledArray<Class>

Returns an Array of enabled services only.

Returns:

  • (Array<Class>)

    enabled services



48
49
50
# File 'lib/gdk/services.rb', line 48

def self.enabled
  all.select(&:enabled?)
end

.fetch(name) ⇒ ::GDK::Services::Base|nil

Return the service that matches the given name

Parameters:

  • name (Symbol|String)

Returns:



37
38
39
40
41
42
43
# File 'lib/gdk/services.rb', line 37

def self.fetch(name)
  service = all_service_names.find { |srv| srv == name.to_sym }

  return unless service

  const_get(service).new
end