injest-client 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4475a67ea575aa7767fdc17cee8b603933775eabb521e18fcfa40e0328e1c542
4
- data.tar.gz: 8e16f7d280c10585d37c34e47793f7bd8629feb34d7f95ab7931ad65a2ae20bc
3
+ metadata.gz: 0d0693548127e95424b8163d5b76979759d60ab69360b48d97aa902bc6a4bf9b
4
+ data.tar.gz: 33337fa8f25784efc17e309945a309433b5b73441d18bb713a1df16f89dadfd3
5
5
  SHA512:
6
- metadata.gz: e3f70641b589fdf0e5f6e19f3b93fbc88a9d3248e535c5bd5a86382f1fdf90fce1cbb352a14c7da9b84ee09b92439abc2de4421befb4d731b81f661392aa3f32
7
- data.tar.gz: 67b802232e384eae6bb6501f967d4623976d0515ceee736395023975c98cb4c0fe37a05d22abbef73eb19a23fbe5f79936568e95414f4fc5d9b2cc2dc4ca577b
6
+ metadata.gz: d167f7a7baa9d1762bdf7cdff253c5bb12010c9a2c96b5e8ce4fd9666f8705b663d7fb845dda00a1e764689a1ee654068209a2b83635d3a09f976ce175c6e977
7
+ data.tar.gz: 1a6d1bb5f865c30a794273133fea236d05e6d7c22c1845ff05a05ae5d7b583c664c6f8de0482387e6c4ad1d2e253b045230873e40e70c5313732e3c5ec90f318
data/lib/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Changelog
4
4
 
5
+ ### 0.1.7
6
+
7
+ - Support multiple strategies via the `INJEST_STRATEGY` env var, example: `INJEST_STRATEGY="stdout,http"`
8
+ - Added the `jsonout` strategy
9
+
5
10
  ### 0.1.6
6
11
 
7
12
  - fix bad exception raise
@@ -26,7 +31,16 @@ ENV vars
26
31
  - `INJEST_JWT`: a JWT required with strategy `http` or `push`
27
32
  - `INJEST_CLIENT`: (optional) a string to bind to a specific client
28
33
 
34
+ ## Release
35
+
36
+ ```bash
37
+ ./console.sh build
38
+ ./console.sh release
39
+ ```
40
+
29
41
  ## TODO:
30
42
 
43
+ - **use json output wich ideally should not depend on sidekiq**
44
+
31
45
  - Customization with procs
32
46
  - Tests: https://guides.rubygems.org/make-your-own-gem/#writing-tests
@@ -43,6 +43,7 @@ class Injest::Middleware
43
43
  private
44
44
 
45
45
  def append(data)
46
+ puts @configuration.inspect
46
47
  Injest::Writer.instance.append(data)
47
48
  end
48
49
 
data/lib/injest/writer.rb CHANGED
@@ -4,27 +4,48 @@ class Injest::Writer
4
4
  attr_reader :configuration, :http_client
5
5
 
6
6
  def append(data, sync: false)
7
- case configuration.strategy
8
- when 'push', 'http'
7
+ if @strategies.include?('push') || @strategies.include?('http')
9
8
  if sync
10
9
  http_client.push(data)
11
10
  else
12
11
  Injest::Worker.perform_async(data)
13
12
  end
14
-
15
- when 'stdout'
13
+ end
14
+
15
+ if @strategies.include?('stdout')
16
16
  print(data)
17
+ end
17
18
 
18
- when 'null'
19
- # Do nothing
20
- else
21
- # Do nothing
19
+ if @strategies.include?('jsonout')
20
+ if Kernel.const_defined?('Rails')
21
+ Rails.logger.info(data.to_json)
22
+ else
23
+ puts data.to_json
24
+ end
22
25
  end
26
+
27
+ # case configuration.strategy
28
+ # when 'push', 'http'
29
+ # if sync
30
+ # http_client.push(data)
31
+ # else
32
+ # Injest::Worker.perform_async(data)
33
+ # end
34
+ #
35
+ # when 'stdout'
36
+ # print(data)
37
+ #
38
+ # when 'null'
39
+ # # Do nothing
40
+ # else
41
+ # # Do nothing
42
+ # end
23
43
  end
24
44
 
25
45
  private
26
46
  def initialize
27
47
  @configuration = Injest::Configuration.instance
48
+ set_strategies
28
49
  @http_client = Injest::HttpClient.new(configuration)
29
50
  end
30
51
 
@@ -60,4 +81,13 @@ class Injest::Writer
60
81
  puts "Response: #{data[:response][:status]}"
61
82
  puts data[:response][:body].inspect
62
83
  end
84
+
85
+ def set_strategies
86
+ raw = @configuration.strategy
87
+ if raw == nil || raw == ''
88
+ @strategies = ['null']
89
+ else
90
+ @strategies = raw.split(',')
91
+ end
92
+ end
63
93
  end
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.6
4
+ version: 0.1.7
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-05-25 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq