Class: Gjallarhorn::Deployment::Strategy Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/gjallarhorn/deployment/strategy.rb

Overview

This class is abstract.

Subclass and override deployment methods

Base class for deployment strategies

Defines the interface that all deployment strategies must implement. Each strategy handles the specifics of how containers are deployed, updated, and managed during the deployment process.

Since:

  • 0.1.0

Direct Known Subclasses

Basic, Legacy, ZeroDowntime

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, proxy_manager, logger = nil) ⇒ Strategy

Initialize a deployment strategy

Parameters:

  • adapter (Adapter::Base)

    The cloud adapter to use

  • proxy_manager (Proxy::Manager)

    The proxy manager for traffic switching

  • logger (Logger) (defaults to: nil)

    Logger instance

Since:

  • 0.1.0



23
24
25
26
27
# File 'lib/gjallarhorn/deployment/strategy.rb', line 23

def initialize(adapter, proxy_manager, logger = nil)
  @adapter = adapter
  @proxy_manager = proxy_manager
  @logger = logger || Logger.new($stdout)
end

Instance Attribute Details

#adapterObject (readonly)

Since:

  • 0.1.0



16
17
18
# File 'lib/gjallarhorn/deployment/strategy.rb', line 16

def adapter
  @adapter
end

#loggerObject (readonly)

Since:

  • 0.1.0



16
17
18
# File 'lib/gjallarhorn/deployment/strategy.rb', line 16

def logger
  @logger
end

#proxy_managerObject (readonly)

Since:

  • 0.1.0



16
17
18
# File 'lib/gjallarhorn/deployment/strategy.rb', line 16

def proxy_manager
  @proxy_manager
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 services using this strategy

Parameters:

  • image (String)

    Container image to deploy

  • environment (String)

    Target environment

  • services (Array<Hash>)

    Services to deploy

Raises:

  • (NotImplementedError)

    If not implemented by subclass

Since:

  • 0.1.0



37
38
39
# File 'lib/gjallarhorn/deployment/strategy.rb', line 37

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

#nameString

Get strategy name

Returns:

  • (String)

    Strategy name

Since:

  • 0.1.0



51
52
53
# File 'lib/gjallarhorn/deployment/strategy.rb', line 51

def name
  self.class.name.split("::").last.downcase
end

#zero_downtime?Boolean

Check if strategy supports zero-downtime deployments

Returns:

  • (Boolean)

    True if strategy supports zero-downtime

Since:

  • 0.1.0



44
45
46
# File 'lib/gjallarhorn/deployment/strategy.rb', line 44

def zero_downtime?
  false
end