persistence-providers 0.0.3.1 → 0.0.3.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/persistence_providers.rb +1 -1
- data/lib/state/component/attribute.rb +7 -7
- data/lib/state/component/providers/influxdb/measurement/attribute_measurement.rb +1 -1
- data/lib/state/component/providers/influxdb/measurement/errors.rb +1 -1
- data/lib/state/component/providers/influxdb/measurement.rb +1 -1
- data/lib/state/component/providers/influxdb.rb +8 -8
- data/lib/state/component/providers/kube_crd.rb +4 -4
- data/lib/state/component.rb +6 -6
- data/lib/state/{crd_component.rb → crd_assembly.rb} +3 -3
- data/lib/state/executable_action.rb +2 -2
- data/persistence-providers.gemspec +1 -1
- data/test.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30043309dd4928f64a7577e8045035f0208b9fd8bde9c9a4f378ddc1f6cadc2d
|
4
|
+
data.tar.gz: 46e990e3aa194698a9a8930a3529a4068ba3f9d9dae836bc6353e22504fd3e2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61edcdffbc29dd611e1874e1f8b4d422f5cf3183b675d11aedb446c7c78932946b76086e367f7ce1c1f2447f6bbba86341ae191f7071b1c4a2c0456ed6c0fa41
|
7
|
+
data.tar.gz: 635650ee5cba06e3d5cb46cd953dba7bc6349d3a90c96f877c23087f12848b718d9a0b782beed7fffbc60117f8d47355e7332a6b13221e8af779ee5c3367e7e7
|
@@ -31,21 +31,21 @@ module DTK::State
|
|
31
31
|
# @encrypted = attribute_content[:encrypted] || false
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.get(namespace,
|
34
|
+
def self.get(namespace, assembly_name, component_name, attribute_name, opts = {})
|
35
35
|
# getting attribute here because we can reuse it if it's stored in crd
|
36
|
-
# when we decide to not store attribute value as part of
|
37
|
-
|
38
|
-
attribute_content =
|
36
|
+
# when we decide to not store attribute value as part of assembly crd we can overwrite this
|
37
|
+
assembly = Component.get(namespace, assembly_name, component_name, opts)
|
38
|
+
attribute_content = assembly.attributes.find{ |attribute| attribute.name == attribute_name }
|
39
39
|
|
40
|
-
fail Error.new("Unable to find attribute '#{attribute_name}' in provided
|
40
|
+
fail Error.new("Unable to find attribute '#{attribute_name}' in provided assembly") if attribute_content.nil? || attribute_content.empty?
|
41
41
|
|
42
|
-
attribute = self.new(attribute_name, attribute_content,
|
42
|
+
attribute = self.new(attribute_name, attribute_content, assembly)
|
43
43
|
provider_class = provider_class_name(attribute, opts)
|
44
44
|
# return already fetched attribute value if provider is KubeCrd
|
45
45
|
return attribute if provider_class == 'KubeCrd'
|
46
46
|
|
47
47
|
# for KubeCrd this will do the same work we did in provider_class_name method to find temporal param
|
48
|
-
self.class.const_get(provider_class).get(
|
48
|
+
self.class.const_get(provider_class).get(component_name, attribute_name, opts)
|
49
49
|
end
|
50
50
|
|
51
51
|
def to_hash
|
@@ -11,7 +11,7 @@ module DTK::State
|
|
11
11
|
protected
|
12
12
|
|
13
13
|
def required_params
|
14
|
-
[:namespace, :
|
14
|
+
[:namespace, :component_name, :assembly_name, :task_id, :attribute_name, :task_id, :correlator_type]
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -22,7 +22,7 @@ module DTK::State
|
|
22
22
|
def get_last_point(params_hash = {})
|
23
23
|
begin
|
24
24
|
check_params_hash(params_hash)
|
25
|
-
flux_query = 'from(bucket:"' + client.connection_parameters[:bucket] + '") |> range(start:-5) |> filter(fn: (r) => r._measurement == "' + name.to_s + '")' + flux_filter(params_hash) + ' |> last()' + '|> drop(columns: ["_start", "_stop", "_field", "_measurement", "attribute_name", "
|
25
|
+
flux_query = 'from(bucket:"' + client.connection_parameters[:bucket] + '") |> range(start:-5) |> filter(fn: (r) => r._measurement == "' + name.to_s + '")' + flux_filter(params_hash) + ' |> last()' + '|> drop(columns: ["_start", "_stop", "_field", "_measurement", "attribute_name", "assembly_name", "task_id", "component_name", "namespace"])'
|
26
26
|
result = self.client.query(flux_query)
|
27
27
|
result.values.map(&:records).flatten.map(&:values)
|
28
28
|
rescue => error
|
@@ -11,8 +11,8 @@ module DTK::State
|
|
11
11
|
@measurement = @client.measurement_helper(measurement_name)
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(namespace,
|
15
|
-
required_tags = get_required_tags(namespace,
|
14
|
+
def get(namespace, component_name, assembly_name, attribute_name, opts = {})
|
15
|
+
required_tags = get_required_tags(namespace, component_name, assembly_name, attribute_name)
|
16
16
|
if opts[:provider] == "correlation"
|
17
17
|
errors = client.measurement_helper(:errors)
|
18
18
|
required_tags.merge!({ correlator_type: opts[:entrypoint].split("/").last.split(".")[0] })
|
@@ -23,14 +23,14 @@ module DTK::State
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def write(namespace,
|
26
|
+
def write(namespace, component_name, assembly_name, attribute_name, value, opts = {}, timestamp = nil)
|
27
27
|
if opts[:provider] == "correlation"
|
28
28
|
errors = client.measurement_helper(:errors)
|
29
|
-
required_tags = get_required_tags(namespace,
|
29
|
+
required_tags = get_required_tags(namespace, component_name, assembly_name, attribute_name)
|
30
30
|
required_tags.merge!({ correlator_type: opts[:entrypoint].split("/").last.split(".")[0] })
|
31
31
|
errors.write(value.to_s, required_tags, timestamp)
|
32
32
|
elsif
|
33
|
-
required_tags = get_required_tags(namespace,
|
33
|
+
required_tags = get_required_tags(namespace, component_name, assembly_name, attribute_name)
|
34
34
|
measurement.write(value, required_tags, timestamp)
|
35
35
|
end
|
36
36
|
end
|
@@ -86,11 +86,11 @@ module DTK::State
|
|
86
86
|
|
87
87
|
private
|
88
88
|
|
89
|
-
def get_required_tags(namespace,
|
89
|
+
def get_required_tags(namespace, component_name, assembly_name, attribute_name)
|
90
90
|
required_tags = {
|
91
91
|
namespace: namespace,
|
92
|
-
|
93
|
-
|
92
|
+
component_name: component_name,
|
93
|
+
assembly_name: assembly_name,
|
94
94
|
attribute_name: attribute_name,
|
95
95
|
task_id: "1"
|
96
96
|
}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module DTK::State
|
2
2
|
class Component::Attribute
|
3
3
|
class KubeCrd < self
|
4
|
-
def get(namespace,
|
5
|
-
|
6
|
-
attribute =
|
7
|
-
Attribute.new(attribute_name, attribute,
|
4
|
+
def get(namespace, assembly_name, component_name, attribute_name, opts = {})
|
5
|
+
assembly = Component.get(namespace, assembly_name, component_name, opts)
|
6
|
+
attribute = assembly.attributes.find{ |attribute| attribute.name == attribute_name }
|
7
|
+
Attribute.new(attribute_name, attribute, assembly)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/lib/state/component.rb
CHANGED
@@ -15,10 +15,10 @@ module DTK::State
|
|
15
15
|
|
16
16
|
# opts can have keys
|
17
17
|
# task_id
|
18
|
-
def self.get(
|
19
|
-
|
20
|
-
if matching_component =
|
21
|
-
Component.new(component_name, matching_component[component_name],
|
18
|
+
def self.get(crd_assembly_namespace, crd_assembly_name, component_name, opts = {})
|
19
|
+
crd_assembly = CrdAssembly.get(crd_assembly_namespace, crd_assembly_name, opts)
|
20
|
+
if matching_component = crd_assembly.components.find{ |cmp| cmp.to_hash.keys.first.to_s == component_name }
|
21
|
+
Component.new(component_name, matching_component[component_name], crd_assembly, opts)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -27,8 +27,8 @@ module DTK::State
|
|
27
27
|
# format:
|
28
28
|
# hash
|
29
29
|
# kubernetes - return attributes in raw format from kubeclient
|
30
|
-
def self.get_attributes(
|
31
|
-
component = get(
|
30
|
+
def self.get_attributes(crd_assembly_namespace, crd_assembly_name, component_name, opts = {})
|
31
|
+
component = get(crd_assembly_namespace, crd_assembly_name, component_name, opts)
|
32
32
|
component.attributes(opts)
|
33
33
|
end
|
34
34
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module DTK::State
|
2
|
-
class
|
2
|
+
class CrdAssembly
|
3
3
|
attr_reader :name, :namespace, :crd_content, :components, :references
|
4
4
|
|
5
5
|
def initialize(namespace, name, crd_content)
|
@@ -12,8 +12,8 @@ module DTK::State
|
|
12
12
|
|
13
13
|
def self.get(namespace, name, opts = {})
|
14
14
|
# crd_component = ::DTK::CrdClient.instance.kubeclient.get_component(name, namespace)
|
15
|
-
|
16
|
-
|
15
|
+
crd_assembly = ::DTK::CrdClient.get_kubeclient(opts).get_assembly(name, namespace)
|
16
|
+
CrdAssembly.new(namespace, name, crd_assembly)
|
17
17
|
end
|
18
18
|
|
19
19
|
# components can be:
|
@@ -9,8 +9,8 @@ module DTK::State
|
|
9
9
|
@bash_script = params[:bash_script]
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.get(
|
13
|
-
component_obj = Component.get(
|
12
|
+
def self.get(crd_assembly_namespace, crd_assembly_name, component_name, action_name, opts = {})
|
13
|
+
component_obj = Component.get(crd_assembly_namespace, crd_assembly_name, component_name, opts)
|
14
14
|
actions = component_obj.component_def.executable_actions
|
15
15
|
action = actions[action_name]
|
16
16
|
|
data/test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative 'lib/persistence_providers'
|
2
2
|
require 'byebug'
|
3
3
|
byebug
|
4
|
-
DTK::State::
|
5
|
-
DTK::State::
|
4
|
+
DTK::State::CrdAssembly.get('aldin', 'aldin', {kubeclient: 'test'})
|
5
|
+
DTK::State::CrdAssembly.new('aaa', 'bbb', { spec: { components: 'some_components'}}, {kubernetes_client: 'test'})
|
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.3.
|
4
|
+
version: 0.0.3.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-04-
|
11
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kubeclient
|
@@ -73,7 +73,7 @@ files:
|
|
73
73
|
- lib/state/component/providers/kube_crd.rb
|
74
74
|
- lib/state/component_def.rb
|
75
75
|
- lib/state/component_def/attribute_type_info.rb
|
76
|
-
- lib/state/
|
76
|
+
- lib/state/crd_assembly.rb
|
77
77
|
- lib/state/executable_action.rb
|
78
78
|
- lib/state/workflow_instance.rb
|
79
79
|
- lib/state/workflow_instance/attribute_type_info.rb
|