persistence-providers 0.0.2.1 → 0.0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/state/component/providers/influxdb.rb +51 -2
- data/lib/state/component/providers/influxdb/measurement.rb +2 -0
- data/lib/state/component/providers/influxdb/measurement/attribute_measurement.rb +0 -1
- data/lib/state/component/providers/influxdb/measurement/events.rb +20 -0
- data/lib/state/component/providers/influxdb/measurement/states.rb +20 -0
- data/persistence-providers.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8136cc320cf5d2ad265d4a3c966a7838f1c6a1d09d13a1e5aad7143fe510ea2a
|
4
|
+
data.tar.gz: b64999cabad79d62721921049e71f8b2e45b0b4c70256aeb8d496e157ae556bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2fea0ace3f115d3c1168952f6664bf1f2618df80c4f7ce6b53dae51a41f81e91c3ae452f9d11afd050e9c5a219d3537d43cadb947155aa55e53a724e11fb5ad
|
7
|
+
data.tar.gz: 8e0c57d6e478f9db48e1e548a0ada0a9974e4cf68799d5adf55f00e8f4aeac9c47cd6c26252d030df9bba4c36895c188e098db5881282ae9311861ee1fad230a
|
@@ -6,9 +6,9 @@ module DTK::State
|
|
6
6
|
|
7
7
|
attr_reader :client, :measurement
|
8
8
|
|
9
|
-
def initialize
|
9
|
+
def initialize(measurement_name)
|
10
10
|
@client = Influxdb::Client.new('dtk')
|
11
|
-
@measurement = @client.measurement_helper(
|
11
|
+
@measurement = @client.measurement_helper(measurement_name)
|
12
12
|
end
|
13
13
|
|
14
14
|
def get(namespace, crd_component_name, component_instance_name, attribute_name, opts = {})
|
@@ -25,6 +25,55 @@ module DTK::State
|
|
25
25
|
puts error
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
def write_event(event_id, pod_name, pod_namespace, event_source, event_message, component_name, attribute_name, task_id, timestamp)
|
30
|
+
begin
|
31
|
+
fail "Bad timestamp input, write operation wont be completed" if timestamp > Time.new
|
32
|
+
value_to_write = { event_source: event_source, event_message: event_message }
|
33
|
+
required_tags = {
|
34
|
+
event_id: event_id,
|
35
|
+
pod_name: pod_name,
|
36
|
+
pod_namespace: pod_namespace,
|
37
|
+
component_name: component_name,
|
38
|
+
attribute_name: attribute_name,
|
39
|
+
task_id: task_id
|
40
|
+
}
|
41
|
+
measurement.write(value_to_write.to_s, required_tags, timestamp)
|
42
|
+
rescue => error
|
43
|
+
puts error
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_event(event_id, pod_name, pod_namespace, component_name, attribute_name, task_id)
|
48
|
+
required_tags = {
|
49
|
+
event_id: event_id,
|
50
|
+
pod_name: pod_name,
|
51
|
+
pod_namespace: pod_namespace,
|
52
|
+
component_name: component_name,
|
53
|
+
attribute_name: attribute_name,
|
54
|
+
task_id: task_id
|
55
|
+
}
|
56
|
+
last_point = measurement.get_last_point(required_tags)
|
57
|
+
end
|
58
|
+
|
59
|
+
def write_state(type, name, namespace, object_state, spec, status, component_name, attribute_name, task_id, timestamp)
|
60
|
+
begin
|
61
|
+
fail "Bad timestamp input, write operation wont be completed" if timestamp > Time.new
|
62
|
+
value_to_write = { spec: spec, status: status }
|
63
|
+
required_tags = {
|
64
|
+
type: type,
|
65
|
+
name: name,
|
66
|
+
namespace: namespace,
|
67
|
+
object_state: object_state,
|
68
|
+
component_name: component_name,
|
69
|
+
attribute_name: attribute_name,
|
70
|
+
task_id: task_id
|
71
|
+
}
|
72
|
+
measurement.write(value_to_write.to_s, required_tags, timestamp)
|
73
|
+
rescue => error
|
74
|
+
puts error
|
75
|
+
end
|
76
|
+
end
|
28
77
|
|
29
78
|
private
|
30
79
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DTK::State
|
2
|
+
class Component::Attribute::Influxdb
|
3
|
+
class Measurement
|
4
|
+
class Events < self
|
5
|
+
|
6
|
+
def write(value, params_hash = {}, timestamp)
|
7
|
+
checked_params_hash = check_params_hash(params_hash)
|
8
|
+
write_point(value, checked_params_hash, timestamp)
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def required_params
|
14
|
+
[:event_id, :pod_name, :pod_namespace, :component_name, :attribute_name, :task_id]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DTK::State
|
2
|
+
class Component::Attribute::Influxdb
|
3
|
+
class Measurement
|
4
|
+
class States < self
|
5
|
+
|
6
|
+
def write(value, params_hash = {}, timestamp)
|
7
|
+
checked_params_hash = check_params_hash(params_hash)
|
8
|
+
write_point(value, checked_params_hash, timestamp)
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def required_params
|
14
|
+
[:type, :name, :namespace, :object_state, :component_name, :attribute_name, :task_id]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: persistence-providers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.2.
|
4
|
+
version: 0.0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reactor8
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kubeclient
|
@@ -67,6 +67,8 @@ files:
|
|
67
67
|
- lib/state/component/providers/influxdb/client.rb
|
68
68
|
- lib/state/component/providers/influxdb/measurement.rb
|
69
69
|
- lib/state/component/providers/influxdb/measurement/attribute_measurement.rb
|
70
|
+
- lib/state/component/providers/influxdb/measurement/events.rb
|
71
|
+
- lib/state/component/providers/influxdb/measurement/states.rb
|
70
72
|
- lib/state/component/providers/kube_crd.rb
|
71
73
|
- lib/state/component_def.rb
|
72
74
|
- lib/state/component_def/attribute_type_info.rb
|