wavefront-sdk 5.4.4 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +3 -3
  3. data/.github/workflows/test.yml +2 -2
  4. data/.rubocop.yml +1 -3
  5. data/HISTORY.md +17 -0
  6. data/README.md +5 -5
  7. data/lib/wavefront-sdk/api_mixins/acl.rb +1 -1
  8. data/lib/wavefront-sdk/core/api.rb +1 -1
  9. data/lib/wavefront-sdk/core/api_caller.rb +1 -7
  10. data/lib/wavefront-sdk/core/exception.rb +2 -0
  11. data/lib/wavefront-sdk/core/response.rb +1 -1
  12. data/lib/wavefront-sdk/credentials.rb +3 -5
  13. data/lib/wavefront-sdk/defs/version.rb +1 -1
  14. data/lib/wavefront-sdk/event.rb +64 -1
  15. data/lib/wavefront-sdk/maintenancewindow.rb +1 -1
  16. data/lib/wavefront-sdk/metric.rb +2 -2
  17. data/lib/wavefront-sdk/metric_helper.rb +1 -1
  18. data/lib/wavefront-sdk/metricspolicy.rb +57 -0
  19. data/lib/wavefront-sdk/paginator/base.rb +1 -1
  20. data/lib/wavefront-sdk/search.rb +3 -3
  21. data/lib/wavefront-sdk/spy.rb +22 -0
  22. data/lib/wavefront-sdk/support/mixins.rb +1 -1
  23. data/lib/wavefront-sdk/support/parse_time.rb +1 -1
  24. data/lib/wavefront-sdk/user.rb +1 -1
  25. data/lib/wavefront-sdk/validators.rb +18 -3
  26. data/lib/wavefront-sdk/write.rb +2 -2
  27. data/lib/wavefront-sdk/writers/api.rb +1 -1
  28. data/lib/wavefront-sdk/writers/core.rb +1 -1
  29. data/lib/wavefront-sdk/writers/proxy.rb +71 -0
  30. data/lib/wavefront-sdk/writers/socket.rb +15 -27
  31. data/lib/wavefront_sdk.rb +1 -1
  32. data/spec/constants.rb +2 -2
  33. data/spec/test_mixins/general.rb +1 -1
  34. data/spec/wavefront-sdk/core/api_spec.rb +1 -1
  35. data/spec/wavefront-sdk/core/response_spec.rb +2 -2
  36. data/spec/wavefront-sdk/credentials_spec.rb +9 -13
  37. data/spec/wavefront-sdk/event_spec.rb +46 -0
  38. data/spec/wavefront-sdk/metric_helper_spec.rb +2 -0
  39. data/spec/wavefront-sdk/metricspolicy_spec.rb +94 -0
  40. data/spec/wavefront-sdk/misc_spec.rb +2 -2
  41. data/spec/wavefront-sdk/savedsearch_spec.rb +2 -2
  42. data/spec/wavefront-sdk/spy_spec.rb +27 -0
  43. data/spec/wavefront-sdk/user_spec.rb +2 -2
  44. data/spec/wavefront-sdk/validators_spec.rb +10 -0
  45. data/spec/wavefront-sdk/write_spec.rb +1 -1
  46. data/spec/wavefront-sdk/writers/{unix_spec.rb → proxy_spec.rb} +29 -31
  47. data/spec/wavefront-sdk/writers/socket_spec.rb +26 -24
  48. data/wavefront-sdk.gemspec +10 -11
  49. metadata +27 -97
  50. data/lib/wavefront-sdk/writers/unix.rb +0 -59
@@ -11,16 +11,18 @@ require_relative '../../spec_helper'
11
11
  require_relative '../../../lib/wavefront-sdk/write'
12
12
  require_relative '../../../spec/support/mocket'
13
13
 
14
- WS_CREDS = { proxy: 'wavefront-proxy' }.freeze
14
+ UNIX_SOCK = '/tmp/testsock'
15
15
 
16
- # The Socket class writes to a proxy
16
+ WU_CREDS = { socket: UNIX_SOCK }.freeze
17
+
18
+ # Test UNIX Datagram socket writing
17
19
  #
18
- class WavefrontWriterSocketTest < MiniTest::Test
20
+ class WavefrontWriterUnixTest < MiniTest::Test
19
21
  attr_reader :wf, :wf_noop
20
22
 
21
23
  def setup
22
- @wf = Wavefront::Write.new(WS_CREDS, writer: :socket)
23
- @wf_noop = Wavefront::Write.new(WS_CREDS, writer: :socket, noop: true)
24
+ @wf = Wavefront::Write.new(WU_CREDS, writer: :socket)
25
+ @wf_noop = Wavefront::Write.new(WU_CREDS, writer: :socket, noop: true)
24
26
  end
25
27
 
26
28
  def test_writer_class
@@ -29,16 +31,16 @@ class WavefrontWriterSocketTest < MiniTest::Test
29
31
 
30
32
  def test_write_openclose
31
33
  mocket = Mocket.new
32
- Spy.on(TCPSocket, :new).and_return(mocket)
33
- mocket_spy = Spy.on(mocket, :puts)
34
+ Spy.on(UNIXSocket, :new).and_return(mocket)
35
+ mocket_spy = Spy.on(mocket, :write)
34
36
  wf.write(POINT)
35
37
  assert mocket_spy.has_been_called?
36
38
  end
37
39
 
38
40
  def test_write_noop
39
41
  mocket = Mocket.new
40
- Spy.on(TCPSocket, :new).and_return(mocket)
41
- mocket_spy = Spy.on(mocket, :puts)
42
+ Spy.on(UNIXSocket, :new).and_return(mocket)
43
+ mocket_spy = Spy.on(mocket, :write)
42
44
  wf_noop.open
43
45
  wf_noop.write(POINT, false)
44
46
  refute mocket_spy.has_been_called?
@@ -46,16 +48,16 @@ class WavefrontWriterSocketTest < MiniTest::Test
46
48
 
47
49
  def test_write_noop_openclose
48
50
  mocket = Mocket.new
49
- Spy.on(TCPSocket, :new).and_return(mocket)
50
- mocket_spy = Spy.on(mocket, :puts)
51
+ Spy.on(UNIXSocket, :new).and_return(mocket)
52
+ mocket_spy = Spy.on(mocket, :write)
51
53
  wf_noop.write(POINT)
52
54
  refute mocket_spy.has_been_called?
53
55
  end
54
56
 
55
57
  def test_write
56
58
  mocket = Mocket.new
57
- Spy.on(TCPSocket, :new).and_return(mocket)
58
- mocket_spy = Spy.on(mocket, :puts)
59
+ Spy.on(UNIXSocket, :new).and_return(mocket)
60
+ mocket_spy = Spy.on(mocket, :write)
59
61
  wf.open
60
62
  wf.write(POINT, false)
61
63
  assert mocket_spy.has_been_called?
@@ -63,8 +65,8 @@ class WavefrontWriterSocketTest < MiniTest::Test
63
65
 
64
66
  def test_write_array
65
67
  mocket = Mocket.new
66
- Spy.on(TCPSocket, :new).and_return(mocket)
67
- mocket_spy = Spy.on(mocket, :puts)
68
+ Spy.on(UNIXSocket, :new).and_return(mocket)
69
+ mocket_spy = Spy.on(mocket, :write)
68
70
  wf.open
69
71
  wf.write(POINT_A, false)
70
72
  assert mocket_spy.has_been_called?
@@ -72,32 +74,32 @@ class WavefrontWriterSocketTest < MiniTest::Test
72
74
 
73
75
  def test_noop_send_point
74
76
  mocket = Mocket.new
75
- Spy.on(TCPSocket, :new).and_return(mocket)
76
- mocket_spy = Spy.on(mocket, :puts)
77
+ Spy.on(UNIXSocket, :new).and_return(mocket)
78
+ mocket_spy = Spy.on(mocket, :write)
77
79
  wf_noop.open
78
80
  wf_noop.send_point(POINT_L)
79
81
  refute mocket_spy.has_been_called?
80
82
  end
81
83
 
82
84
  def test_open
83
- tcp_spy = Spy.on(TCPSocket, :new)
85
+ tcp_spy = Spy.on(UNIXSocket, :new)
84
86
  wf.open
85
87
  assert tcp_spy.has_been_called?
86
- assert_equal(['wavefront-proxy', 2878], tcp_spy.calls.first.args)
88
+ assert_equal([UNIX_SOCK], tcp_spy.calls.first.args)
87
89
  end
88
90
 
89
91
  def test_noop_open
90
- tcp_spy = Spy.on(TCPSocket, :new)
92
+ tcp_spy = Spy.on(UNIXSocket, :new)
91
93
  log_spy = Spy.on(wf_noop.logger, :log)
92
94
  wf_noop.open
93
95
  refute tcp_spy.has_been_called?
94
- assert_equal(['No-op requested. Not opening connection to proxy.'],
96
+ assert_equal(['No-op requested. Not opening socket connection.'],
95
97
  log_spy.calls.last.args)
96
98
  assert_equal(1, log_spy.calls.size)
97
99
  end
98
100
 
99
101
  def test_noop_close
100
- tcp_spy = Spy.on(TCPSocket, :new)
102
+ tcp_spy = Spy.on(UNIXSocket, :new)
101
103
  log_spy = Spy.on(wf_noop.logger, :log)
102
104
  wf_noop.close
103
105
  refute tcp_spy.has_been_called?
@@ -105,10 +107,10 @@ class WavefrontWriterSocketTest < MiniTest::Test
105
107
  end
106
108
 
107
109
  def test_validate_credentials
108
- assert(Wavefront::Write.new(WS_CREDS, writer: :socket))
110
+ assert(Wavefront::Write.new(WU_CREDS, writer: :socket))
109
111
 
110
112
  assert_instance_of(Wavefront::Write,
111
- Wavefront::Write.new(WS_CREDS, writer: :socket))
113
+ Wavefront::Write.new(WU_CREDS, writer: :socket))
112
114
 
113
115
  assert_raises(Wavefront::Exception::CredentialError) do
114
116
  Wavefront::Write.new({}, writer: :socket)
@@ -7,7 +7,6 @@ require_relative 'lib/wavefront-sdk/defs/version'
7
7
  Gem::Specification.new do |gem|
8
8
  gem.name = 'wavefront-sdk'
9
9
  gem.version = WF_SDK_VERSION
10
- gem.date = Date.today.to_s
11
10
 
12
11
  gem.summary = 'SDK for Wavefront API v2'
13
12
  gem.description = 'SDK for Wavefront (wavefront.com) API v2 '
@@ -18,25 +17,25 @@ Gem::Specification.new do |gem|
18
17
  gem.license = 'BSD-2-Clause'
19
18
 
20
19
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
21
- gem.test_files = gem.files.grep(/^spec/)
22
20
  gem.require_paths = %w[lib]
23
21
  gem.bindir = 'bin'
24
22
 
25
- gem.add_dependency 'addressable', '~> 2.7'
23
+ gem.add_dependency 'addressable', '~> 2.8'
26
24
  gem.add_dependency 'faraday', '~> 1.1'
27
25
  gem.add_dependency 'inifile', '~> 3.0'
28
26
  gem.add_dependency 'map', '~> 6.6'
29
27
 
30
- gem.add_development_dependency 'minitest', '~> 5.14'
28
+ gem.add_development_dependency 'minitest', '~> 5.17'
31
29
  gem.add_development_dependency 'rake', '~> 13.0'
32
- gem.add_development_dependency 'rubocop', '~> 1.9'
33
- gem.add_development_dependency 'rubocop-minitest', '~> 0.10'
34
- gem.add_development_dependency 'rubocop-performance', '~> 1.3'
35
- gem.add_development_dependency 'rubocop-rake', '~> 0.5'
30
+ gem.add_development_dependency 'rubocop', '~> 1.43'
31
+ gem.add_development_dependency 'rubocop-minitest', '~> 0.26'
32
+ gem.add_development_dependency 'rubocop-performance', '~> 1.15'
33
+ gem.add_development_dependency 'rubocop-rake', '~> 0.6'
36
34
  gem.add_development_dependency 'simplecov', '~> 0.18'
37
- gem.add_development_dependency 'spy', '1.0.0'
38
- gem.add_development_dependency 'webmock', '~> 3.9'
35
+ gem.add_development_dependency 'spy', '1.0'
36
+ gem.add_development_dependency 'webmock', '~> 3.18'
39
37
  gem.add_development_dependency 'yard', '~> 0.9'
40
38
 
41
- gem.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
39
+ gem.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
40
+ gem.metadata['rubygems_mfa_required'] = 'true'
42
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.4
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-01 00:00:00.000000000 Z
11
+ date: 2023-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.7'
19
+ version: '2.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.7'
26
+ version: '2.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.14'
75
+ version: '5.17'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.14'
82
+ version: '5.17'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,56 +100,56 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.9'
103
+ version: '1.43'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.9'
110
+ version: '1.43'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop-minitest
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.10'
117
+ version: '0.26'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0.10'
124
+ version: '0.26'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop-performance
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.3'
131
+ version: '1.15'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1.3'
138
+ version: '1.15'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rubocop-rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0.5'
145
+ version: '0.6'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0.5'
152
+ version: '0.6'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,28 +170,28 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 1.0.0
173
+ version: '1.0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 1.0.0
180
+ version: '1.0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: webmock
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '3.9'
187
+ version: '3.18'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '3.9'
194
+ version: '3.18'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: yard
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +248,7 @@ files:
248
248
  - lib/wavefront-sdk/message.rb
249
249
  - lib/wavefront-sdk/metric.rb
250
250
  - lib/wavefront-sdk/metric_helper.rb
251
+ - lib/wavefront-sdk/metricspolicy.rb
251
252
  - lib/wavefront-sdk/notificant.rb
252
253
  - lib/wavefront-sdk/paginator/base.rb
253
254
  - lib/wavefront-sdk/paginator/delete.rb
@@ -283,9 +284,9 @@ files:
283
284
  - lib/wavefront-sdk/writers/api.rb
284
285
  - lib/wavefront-sdk/writers/core.rb
285
286
  - lib/wavefront-sdk/writers/http.rb
287
+ - lib/wavefront-sdk/writers/proxy.rb
286
288
  - lib/wavefront-sdk/writers/socket.rb
287
289
  - lib/wavefront-sdk/writers/summary.rb
288
- - lib/wavefront-sdk/writers/unix.rb
289
290
  - lib/wavefront_sdk.rb
290
291
  - spec/.rubocop.yml
291
292
  - spec/constants.rb
@@ -318,6 +319,7 @@ files:
318
319
  - spec/wavefront-sdk/message_spec.rb
319
320
  - spec/wavefront-sdk/metric_helper_spec.rb
320
321
  - spec/wavefront-sdk/metric_spec.rb
322
+ - spec/wavefront-sdk/metricspolicy_spec.rb
321
323
  - spec/wavefront-sdk/misc_spec.rb
322
324
  - spec/wavefront-sdk/notificant_spec.rb
323
325
  - spec/wavefront-sdk/paginator/base_spec.rb
@@ -357,14 +359,15 @@ files:
357
359
  - spec/wavefront-sdk/writers/api_spec.rb
358
360
  - spec/wavefront-sdk/writers/core_spec.rb
359
361
  - spec/wavefront-sdk/writers/http_spec.rb
362
+ - spec/wavefront-sdk/writers/proxy_spec.rb
360
363
  - spec/wavefront-sdk/writers/socket_spec.rb
361
364
  - spec/wavefront-sdk/writers/summary_spec.rb
362
- - spec/wavefront-sdk/writers/unix_spec.rb
363
365
  - wavefront-sdk.gemspec
364
366
  homepage: https://github.com/snltd/wavefront-sdk
365
367
  licenses:
366
368
  - BSD-2-Clause
367
- metadata: {}
369
+ metadata:
370
+ rubygems_mfa_required: 'true'
368
371
  post_install_message:
369
372
  rdoc_options: []
370
373
  require_paths:
@@ -373,88 +376,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
373
376
  requirements:
374
377
  - - ">="
375
378
  - !ruby/object:Gem::Version
376
- version: 2.4.0
379
+ version: 2.7.0
377
380
  required_rubygems_version: !ruby/object:Gem::Requirement
378
381
  requirements:
379
382
  - - ">="
380
383
  - !ruby/object:Gem::Version
381
384
  version: '0'
382
385
  requirements: []
383
- rubygems_version: 3.1.4
386
+ rubygems_version: 3.4.1
384
387
  signing_key:
385
388
  specification_version: 4
386
389
  summary: SDK for Wavefront API v2
387
- test_files:
388
- - spec/.rubocop.yml
389
- - spec/constants.rb
390
- - spec/spec_helper.rb
391
- - spec/support/bad_mocket.rb
392
- - spec/support/hash.rb
393
- - spec/support/minitest_assertions.rb
394
- - spec/support/mocket.rb
395
- - spec/test_mixins/acl.rb
396
- - spec/test_mixins/general.rb
397
- - spec/test_mixins/tag.rb
398
- - spec/wavefront-sdk/account_spec.rb
399
- - spec/wavefront-sdk/alert_spec.rb
400
- - spec/wavefront-sdk/api_mixins/user_mixins_spec.rb
401
- - spec/wavefront-sdk/apitoken_spec.rb
402
- - spec/wavefront-sdk/cloudintegration_spec.rb
403
- - spec/wavefront-sdk/core/api_caller_spec.rb
404
- - spec/wavefront-sdk/core/api_spec.rb
405
- - spec/wavefront-sdk/core/logger_spec.rb
406
- - spec/wavefront-sdk/core/response_spec.rb
407
- - spec/wavefront-sdk/credentials_spec.rb
408
- - spec/wavefront-sdk/dashboard_spec.rb
409
- - spec/wavefront-sdk/derivedmetric_spec.rb
410
- - spec/wavefront-sdk/distribution_spec.rb
411
- - spec/wavefront-sdk/event_spec.rb
412
- - spec/wavefront-sdk/externallink_spec.rb
413
- - spec/wavefront-sdk/ingestionpolicy_spec.rb
414
- - spec/wavefront-sdk/integration_spec.rb
415
- - spec/wavefront-sdk/maintenancewindow_spec.rb
416
- - spec/wavefront-sdk/message_spec.rb
417
- - spec/wavefront-sdk/metric_helper_spec.rb
418
- - spec/wavefront-sdk/metric_spec.rb
419
- - spec/wavefront-sdk/misc_spec.rb
420
- - spec/wavefront-sdk/notificant_spec.rb
421
- - spec/wavefront-sdk/paginator/base_spec.rb
422
- - spec/wavefront-sdk/paginator/post_spec.rb
423
- - spec/wavefront-sdk/proxy_spec.rb
424
- - spec/wavefront-sdk/query_spec.rb
425
- - spec/wavefront-sdk/report_spec.rb
426
- - spec/wavefront-sdk/resources/dummy_points.rb
427
- - spec/wavefront-sdk/resources/malformed.conf
428
- - spec/wavefront-sdk/resources/test.conf
429
- - spec/wavefront-sdk/resources/test2.conf
430
- - spec/wavefront-sdk/resources/user_responses/add_user_groups.json
431
- - spec/wavefront-sdk/resources/user_responses/create.json
432
- - spec/wavefront-sdk/resources/user_responses/delete_multiple.json
433
- - spec/wavefront-sdk/resources/user_responses/describe.json
434
- - spec/wavefront-sdk/resources/user_responses/grant.json
435
- - spec/wavefront-sdk/resources/user_responses/list.json
436
- - spec/wavefront-sdk/role_spec.rb
437
- - spec/wavefront-sdk/savedsearch_spec.rb
438
- - spec/wavefront-sdk/search_spec.rb
439
- - spec/wavefront-sdk/serviceaccount_spec.rb
440
- - spec/wavefront-sdk/settings_spec.rb
441
- - spec/wavefront-sdk/source_spec.rb
442
- - spec/wavefront-sdk/spy_spec.rb
443
- - spec/wavefront-sdk/stdlib/array_spec.rb
444
- - spec/wavefront-sdk/stdlib/hash_spec.rb
445
- - spec/wavefront-sdk/stdlib/string_spec.rb
446
- - spec/wavefront-sdk/support/mixins_spec.rb
447
- - spec/wavefront-sdk/support/parse_time_spec.rb
448
- - spec/wavefront-sdk/unstable/chart_spec.rb
449
- - spec/wavefront-sdk/usage_spec.rb
450
- - spec/wavefront-sdk/user_spec.rb
451
- - spec/wavefront-sdk/usergroup_spec.rb
452
- - spec/wavefront-sdk/validators_spec.rb
453
- - spec/wavefront-sdk/webhook_spec.rb
454
- - spec/wavefront-sdk/write_spec.rb
455
- - spec/wavefront-sdk/writers/api_spec.rb
456
- - spec/wavefront-sdk/writers/core_spec.rb
457
- - spec/wavefront-sdk/writers/http_spec.rb
458
- - spec/wavefront-sdk/writers/socket_spec.rb
459
- - spec/wavefront-sdk/writers/summary_spec.rb
460
- - spec/wavefront-sdk/writers/unix_spec.rb
390
+ test_files: []
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'socket'
4
- require_relative 'core'
5
-
6
- module Wavefront
7
- module Writer
8
- #
9
- # Everything specific to writing points to a Unix datagram socket.
10
- #
11
- class Unix < Core
12
- # Make a connection to a Unix datagram socket, putting the
13
- # descriptor in instance variable @conn.
14
- # This requires the name of the socket file in creds[:socket]
15
- # @return [UnixSocket]
16
- #
17
- def open
18
- if opts[:noop]
19
- logger.log('No-op requested. Not opening socket connection.')
20
- return true
21
- end
22
-
23
- logger.log("Connecting to #{creds[:socket]}.", :debug)
24
- open_socket(creds[:socket])
25
- end
26
-
27
- def close
28
- return if opts[:noop]
29
-
30
- logger.log('Closing socket connection.', :debug)
31
- conn.close
32
- end
33
-
34
- def validate_credentials(creds)
35
- return if creds.key?(:socket) && creds[:socket]
36
-
37
- raise(Wavefront::Exception::CredentialError,
38
- 'credentials must contain socket file path')
39
- end
40
-
41
- private
42
-
43
- def open_socket(socket)
44
- @conn = UNIXSocket.new(socket)
45
- rescue StandardError => e
46
- logger.log(e, :error)
47
- raise Wavefront::Exception::InvalidEndpoint
48
- end
49
-
50
- # @param point [String] point or points in native Wavefront format.
51
- #
52
- def _send_point(point)
53
- return if opts[:noop]
54
-
55
- conn.write(point)
56
- end
57
- end
58
- end
59
- end