Class: Karafka::Licenser

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/licenser.rb

Overview

Checks the license presence for pro and loads pro components when needed (if any)

Constant Summary collapse

EXPIRED_CHECKSUMS_LOCATION =

Location of file containing expired/revoked license checksums

File.join(Karafka.gem_root, "certs", "expired.txt")

Class Method Summary collapse

Class Method Details

.detect ⇒ Object

Tries to load the license and yields if successful



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/karafka/licenser.rb', line 16

def detect
  # If license module is already fully defined, don't touch it
  # This allows users to define their own License module for testing/custom setups
  unless license_fully_defined?
    # Try safe approach first (no code execution)
    loaded = safe_load_license || fallback_require_license

    # If neither method succeeded, return false
    return false unless loaded
  end

  yield

  true
rescue LoadError
  false
end

.prepare_and_verify(license_config) ⇒ Object

Tries to prepare license and verifies it

Parameters:

  • license_config (Karafka::Core::Configurable::Node) —

    config related to the licensing



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

def prepare_and_verify(license_config)
  # If license is not loaded, nothing to do
  return unless const_defined?("::Karafka::License")

  prepare(license_config)
  verify(license_config)
end