Class: Rubcask::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/rubcask/config.rb,
lib/rubcask/config.rb

Overview

Server runner config

Constant Summary collapse

DEFAULT_SERVER_CONFIG =
configure { |c| c.io_strategy = :os }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|config| ... } ⇒ Config

Returns a new instance of Config.

Yield Parameters:

  • config (self)


38
39
40
41
42
43
44
45
# File 'lib/rubcask/config.rb', line 38

def initialize
  self.max_file_size = Bytes::GIGABYTE * 2
  self.io_strategy = :ruby
  self.threadsafe = true
  self.worker = :direct

  yield(self) if block_given?
end

Instance Attribute Details

#io_strategy:ruby, ...

Guarantees; listed fastest first

:ruby is safe as long as you exit gracefully

:os is safe as long as no os or hardware failures occures

:os_sync is always safe

Default :ruby

Returns:

  • (:ruby, :os, :os_sync)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rubcask/config.rb', line 36

Config = Struct.new(:max_file_size, :io_strategy, :threadsafe, :worker) do
  # @yieldparam [self] config
  def initialize
    self.max_file_size = Bytes::GIGABYTE * 2
    self.io_strategy = :ruby
    self.threadsafe = true
    self.worker = :direct

    yield(self) if block_given?
  end

  def self.configure(&block)
    new(&block).freeze
  end
end

#max_file_sizeInteger

Maximum single file size.

New file is created after the current file is larger than this field

Default: Bytes::GIGABYTE * 2

Returns:

  • (Integer)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rubcask/config.rb', line 36

Config = Struct.new(:max_file_size, :io_strategy, :threadsafe, :worker) do
  # @yieldparam [self] config
  def initialize
    self.max_file_size = Bytes::GIGABYTE * 2
    self.io_strategy = :ruby
    self.threadsafe = true
    self.worker = :direct

    yield(self) if block_given?
  end

  def self.configure(&block)
    new(&block).freeze
  end
end

#threadsafeboolean

Set to true if you want to use Rubcask with many threads concurrently

Default: true

Returns:

  • (boolean)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rubcask/config.rb', line 36

Config = Struct.new(:max_file_size, :io_strategy, :threadsafe, :worker) do
  # @yieldparam [self] config
  def initialize
    self.max_file_size = Bytes::GIGABYTE * 2
    self.io_strategy = :ruby
    self.threadsafe = true
    self.worker = :direct

    yield(self) if block_given?
  end

  def self.configure(&block)
    new(&block).freeze
  end
end

#worker:direct, ...

Type of worker used for async jobs

Currently it is only used for deleting files after merge

Default: :direct

Returns:

  • (:direct, :ractor, :thread)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rubcask/config.rb', line 36

Config = Struct.new(:max_file_size, :io_strategy, :threadsafe, :worker) do
  # @yieldparam [self] config
  def initialize
    self.max_file_size = Bytes::GIGABYTE * 2
    self.io_strategy = :ruby
    self.threadsafe = true
    self.worker = :direct

    yield(self) if block_given?
  end

  def self.configure(&block)
    new(&block).freeze
  end
end

Class Method Details

.configure(&block) ⇒ Object



47
48
49
# File 'lib/rubcask/config.rb', line 47

def self.configure(&block)
  new(&block).freeze
end