Class: Gjallarhorn::Adapter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gjallarhorn/adapter/base.rb

Overview

Abstract base class for all cloud provider adapters

Since:

  • 0.1.0

Direct Known Subclasses

AWSAdapter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Initialize a new adapter instance

Parameters:

  • config (Hash)

    Configuration hash containing provider-specific settings

Since:

  • 0.1.0



36
37
38
39
# File 'lib/gjallarhorn/adapter/base.rb', line 36

def initialize(config)
  @config = config
  @logger = Logger.new($stdout)
end

Instance Attribute Details

#configHash (readonly)

Returns Configuration hash for this adapter.

Returns:

  • (Hash)

    Configuration hash for this adapter

Since:

  • 0.1.0



28
29
30
# File 'lib/gjallarhorn/adapter/base.rb', line 28

def config
  @config
end

#loggerLogger (readonly)

Returns Logger instance for adapter operations.

Returns:

  • (Logger)

    Logger instance for adapter operations

Since:

  • 0.1.0



31
32
33
# File 'lib/gjallarhorn/adapter/base.rb', line 31

def logger
  @logger
end

Instance Method Details

#deploy(image:, environment:, services: []) ⇒ void

This method is abstract.

Subclasses must implement this method

This method returns an undefined value.

Deploy a container image with the specified services

Parameters:

  • image (String)

    Container image tag to deploy

  • environment (String)

    Target environment name

  • services (Array<Hash>) (defaults to: [])

    List of service configurations to deploy

Raises:

  • (NotImplementedError)

    If not implemented by subclass

Since:

  • 0.1.0



49
50
51
# File 'lib/gjallarhorn/adapter/base.rb', line 49

def deploy(image:, environment:, services: [])
  raise NotImplementedError, "Subclasses must implement deploy"
end

#health_check(service:) ⇒ Boolean

This method is abstract.

Subclasses must implement this method

Check the health status of a specific service

Parameters:

  • service (String)

    Service name to check

Returns:

  • (Boolean)

    True if service is healthy, false otherwise

Raises:

  • (NotImplementedError)

    If not implemented by subclass

Since:

  • 0.1.0



78
79
80
# File 'lib/gjallarhorn/adapter/base.rb', line 78

def health_check(service:)
  raise NotImplementedError, "Subclasses must implement health_check"
end

#logs(service:, lines: 100) ⇒ String

This method is abstract.

Subclasses must implement this method

Retrieve logs from a specific service

Parameters:

  • service (String)

    Service name to get logs from

  • lines (Integer) (defaults to: 100)

    Number of log lines to retrieve (default: 100)

Returns:

  • (String)

    Service logs

Raises:

  • (NotImplementedError)

    If not implemented by subclass

Since:

  • 0.1.0



100
101
102
# File 'lib/gjallarhorn/adapter/base.rb', line 100

def logs(service:, lines: 100)
  raise NotImplementedError, "Subclasses must implement logs"
end

#rollback(version:) ⇒ void

This method is abstract.

Subclasses must implement this method

This method returns an undefined value.

Rollback services to a previous version

Parameters:

  • version (String)

    Version to rollback to

Raises:

  • (NotImplementedError)

    If not implemented by subclass

Since:

  • 0.1.0



59
60
61
# File 'lib/gjallarhorn/adapter/base.rb', line 59

def rollback(version:)
  raise NotImplementedError, "Subclasses must implement rollback"
end

#scale(service:, replicas:) ⇒ void

This method is abstract.

Subclasses must implement this method

This method returns an undefined value.

Scale a service to the specified number of replicas

Parameters:

  • service (String)

    Service name to scale

  • replicas (Integer)

    Target number of replicas

Raises:

  • (NotImplementedError)

    If not implemented by subclass

Since:

  • 0.1.0



89
90
91
# File 'lib/gjallarhorn/adapter/base.rb', line 89

def scale(service:, replicas:)
  raise NotImplementedError, "Subclasses must implement scale"
end

#statusArray<String>

This method is abstract.

Subclasses must implement this method

Get the current status of all services

Returns:

  • (Array<String>)

    Status information for all services

Raises:

  • (NotImplementedError)

    If not implemented by subclass

Since:

  • 0.1.0



68
69
70
# File 'lib/gjallarhorn/adapter/base.rb', line 68

def status
  raise NotImplementedError, "Subclasses must implement status"
end