class TinyPresto::Cluster

Represents a Presto cluster

Public Class Methods

new(image = 'trinodb/trino', tag = 'latest') click to toggle source
# File lib/tiny-presto/cluster.rb, line 9
def initialize(image = 'trinodb/trino', tag = 'latest')
  @tag = tag
  @image_name = "#{image}:#{@tag}"
end

Public Instance Methods

run() click to toggle source

Launch Presto cluster running on Docker container

# File lib/tiny-presto/cluster.rb, line 15
def run
  # Ensure to pull the specified image
  Docker::Image.create('fromImage' => @image_name)
  @container = Docker::Container.create(
    'Image' => @image_name,
    'HostConfig' => {
      'PortBindings' => {
        '8080/tcp' => [
          {
            'HostPort' => '8080'
          }
        ]
      }
    }
  )
  @container.start
  @container
end
stop() click to toggle source

Kill Presto cluster process

# File lib/tiny-presto/cluster.rb, line 35
def stop
  @container.stop
end