injest-client 0.1.3 → 0.1.5
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/README.md +10 -0
- data/lib/injest/http_client.rb +9 -0
- data/lib/injest/middleware.rb +1 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 993d376f31a687775d97c75154c909570579864c600a4d304ceb23a1bbaf6549
|
4
|
+
data.tar.gz: e65f194830ea42e1b43a1c939a421c8a663f3256328741cfb6612a0ae59aadf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 232df2b57f81d5b6c6d931a07fce60226ec45448a1e7b3a2584116994a02af0bfa323a00321886b853b788d0a25dd7466ceb9a1677f3df3fe36a5c67e9e1faa5
|
7
|
+
data.tar.gz: 6de732e492c9a68a2568d76b1f018fc3973ae9f0efefc520da0e0f6272b5cb0cb09aaaf32c735fe2b93b5bd30ac33221170755a6c6017847a1737f149d7dd79a
|
data/lib/README.md
CHANGED
data/lib/injest/http_client.rb
CHANGED
@@ -5,6 +5,7 @@ class Injest::HttpClient
|
|
5
5
|
attr_reader :root_url,
|
6
6
|
:push_url,
|
7
7
|
:search_url,
|
8
|
+
:raw_search_url,
|
8
9
|
:jwt,
|
9
10
|
:client_code
|
10
11
|
def initialize(configuration)
|
@@ -16,6 +17,7 @@ class Injest::HttpClient
|
|
16
17
|
@push_url = [root_url, 'api/v1/logs', client_code].join('/')
|
17
18
|
end
|
18
19
|
@search_url = [root_url, 'api/v1/logs/search'].join('/')
|
20
|
+
@raw_search_url = [root_url, 'api/v1/logs/raw_search'].join('/')
|
19
21
|
@jwt = configuration.injest_token
|
20
22
|
end
|
21
23
|
|
@@ -37,6 +39,13 @@ class Injest::HttpClient
|
|
37
39
|
post_http_request search_url, payload
|
38
40
|
end
|
39
41
|
|
42
|
+
def raw_search(body:, index_postfix: nil)
|
43
|
+
payload = { body: body }
|
44
|
+
payload[:index_postfix] = index_postfix unless index_postfix.nil?
|
45
|
+
|
46
|
+
post_http_request raw_search_url, payload
|
47
|
+
end
|
48
|
+
|
40
49
|
# Push a log
|
41
50
|
def push(data)
|
42
51
|
data = data_as_hash(data)
|
data/lib/injest/middleware.rb
CHANGED
@@ -2,7 +2,7 @@ class Injest::Middleware
|
|
2
2
|
HEADERS_BLACKLIST = %w[HTTP_COOKIE].freeze
|
3
3
|
|
4
4
|
attr_reader :configuration
|
5
|
-
attr_reader :request_type, :env, :
|
5
|
+
attr_reader :request_type, :env, :subject
|
6
6
|
|
7
7
|
def initialize(app, processor: nil)
|
8
8
|
@app = app
|
@@ -10,7 +10,6 @@ class Injest::Middleware
|
|
10
10
|
|
11
11
|
@processor = processor
|
12
12
|
|
13
|
-
@consumer = nil
|
14
13
|
@subject = nil
|
15
14
|
end
|
16
15
|
|
@@ -28,7 +27,6 @@ class Injest::Middleware
|
|
28
27
|
@request_ended_on = Time.now
|
29
28
|
|
30
29
|
set_subject
|
31
|
-
set_consumer
|
32
30
|
|
33
31
|
data = build_data
|
34
32
|
data = @processor.call(env, data) unless @processor.nil?
|
@@ -96,7 +94,6 @@ class Injest::Middleware
|
|
96
94
|
action: data['action'],
|
97
95
|
params: params,
|
98
96
|
version: Gem.loaded_specs["injest-client"].version.to_s,
|
99
|
-
consumer: consumer
|
100
97
|
}
|
101
98
|
end
|
102
99
|
|
@@ -135,14 +132,6 @@ class Injest::Middleware
|
|
135
132
|
end
|
136
133
|
end
|
137
134
|
|
138
|
-
def set_consumer
|
139
|
-
if !subject.nil?
|
140
|
-
@consumer = [subject[:type].downcase, subject[:id]].join(':')
|
141
|
-
elsif env.key?("action_dispatch.request.parameters")
|
142
|
-
@consumer = env["action_dispatch.request.parameters"].fetch('_consumer', 'unknown')
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
135
|
def set_request_type
|
147
136
|
# TODO: maybe we should check some header instead
|
148
137
|
if env['PATH_INFO'].match?(/.*\.(?:png|css|jpeg|ico|gif)/)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: injest-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Lampis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|