Class: Elasticsnap::FreezeElasticsearch
- Inherits:
-
Object
- Object
- Elasticsnap::FreezeElasticsearch
show all
- Defined in:
- lib/elasticsnap/freeze_elasticsearch.rb
Defined Under Namespace
Classes: DisableFlushFailed, EnableFlushFailed, Error, FlushFailed
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of FreezeElasticsearch.
10
11
12
13
14
|
# File 'lib/elasticsnap/freeze_elasticsearch.rb', line 10
def initialize(url: nil)
raise ArgumentError, 'url required' if url.nil?
@url = url
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
8
9
10
|
# File 'lib/elasticsnap/freeze_elasticsearch.rb', line 8
def url
@url
end
|
Instance Method Details
#disable_flush ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/elasticsnap/freeze_elasticsearch.rb', line 36
def disable_flush
Flex::Configuration.http_client.base_uri = url
result = Flex.update_index_settings(
index: '_all',
data: {
index: {
translog: {
disable_flush: true
}
}
}
)
raise DisableFlushFailed unless result.fetch('ok', false) == true
result
end
|
#enable_flush ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/elasticsnap/freeze_elasticsearch.rb', line 54
def enable_flush
Flex::Configuration.http_client.base_uri = url
result = Flex.update_index_settings(
index: '_all',
data: {
index: {
translog: {
disable_flush: false
}
}
}
)
raise EnableFlushFailed unless result.fetch('ok', false) == true
result
end
|
#flush ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/elasticsnap/freeze_elasticsearch.rb', line 27
def flush
Flex::Configuration.http_client.base_uri = url
result = Flex.flush_index(index: '_all')
raise FlushFailed unless result.fetch('ok', false) == true
result
end
|
#freeze(&block) ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/elasticsnap/freeze_elasticsearch.rb', line 16
def freeze(&block)
begin
flush
disable_flush
block.call unless block.nil?
ensure
enable_flush
end
end
|