Module: Droonga::Path

Defined in:
lib/droonga/path.rb

Constant Summary collapse

BASE_DIR_ENV_NAME =
"DROONGA_BASE_DIR"

Class Method Summary collapse

Class Method Details

.accidental_bufferObject



68
69
70
# File 'lib/droonga/path.rb', line 68

def accidental_buffer
  state + "buffer" + "accidental"
end

.baseObject



28
29
30
# File 'lib/droonga/path.rb', line 28

def base
  @base ||= Pathname.new(ENV[BASE_DIR_ENV_NAME] || Dir.pwd).expand_path
end

.base=(new_base) ⇒ Object



32
33
34
35
# File 'lib/droonga/path.rb', line 32

def base=(new_base)
  @base = nil
  ENV[BASE_DIR_ENV_NAME] = new_base
end

.catalogObject



59
60
61
62
# File 'lib/droonga/path.rb', line 59

def catalog
  base_file_name = ENV["DROONGA_CATALOG"] || "catalog.json"
  Pathname.new(base_file_name).expand_path(base)
end

.cluster_stateObject



47
48
49
# File 'lib/droonga/path.rb', line 47

def cluster_state
  state + "cluster-state.json"
end

.configObject



51
52
53
# File 'lib/droonga/path.rb', line 51

def config
  base + "droonga-engine.yaml"
end

.databases(base_path = nil) ⇒ Object



37
38
39
40
41
# File 'lib/droonga/path.rb', line 37

def databases(base_path=nil)
  base_path ||= base
  path = Pathname(base_path) + "databases"
  path.expand_path
end

.default_log_fileObject



55
56
57
# File 'lib/droonga/path.rb', line 55

def default_log_file
  base + "droonga-engine.log"
end

.intentional_bufferObject



72
73
74
# File 'lib/droonga/path.rb', line 72

def intentional_buffer
  state + "buffer" + "intentional"
end

.last_message_timestampObject



64
65
66
# File 'lib/droonga/path.rb', line 64

def last_message_timestamp
  base + "last-message-timestamp.txt"
end

.serf_commandObject



76
77
78
# File 'lib/droonga/path.rb', line 76

def serf_command
  base + "serf"
end

.serf_event_handler_error_fileObject



88
89
90
91
92
93
94
# File 'lib/droonga/path.rb', line 88

def serf_event_handler_error_file
  now = Time.now
  name = sprintf("%04d-%02d-%02d_%02d-%02d-%02d.%d.error",
                 now.year, now.month, now.day,
                 now.hour, now.min, now.sec, now.nsec)
  serf_event_handler_errors + name
end

.serf_event_handler_errorsObject



84
85
86
# File 'lib/droonga/path.rb', line 84

def serf_event_handler_errors
  state + "serf-event-handler-errors"
end

.serf_tags_fileObject



80
81
82
# File 'lib/droonga/path.rb', line 80

def serf_tags_file
  state + "serf-tags.json"
end

.setupObject



23
24
25
26
# File 'lib/droonga/path.rb', line 23

def setup
  base_dir = ENV[BASE_DIR_ENV_NAME] || Dir.pwd
  ENV[BASE_DIR_ENV_NAME] = File.expand_path(base_dir)
end

.stateObject



43
44
45
# File 'lib/droonga/path.rb', line 43

def state
  base + "state"
end

.unique_file_path(directory, basename, suffix) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/droonga/path.rb', line 96

def unique_file_path(directory, basename, suffix)
  directory = Pathname(directory)
  basename = basename.sub(/\.\z/, "")
  suffix   = suffix.sub(/\A\./, "")
  uniqueness_count = 0
  path = nil
  begin
    path = directory + "#{basename}.#{uniqueness_count}.#{suffix}"
    uniqueness_count += 1
  end while path.exist?
  path
end