lex-health 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +61 -0
- data/.gitignore +11 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/lex-health.iml +38 -0
- data/.idea/misc.xml +7 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vagrant.xml +7 -0
- data/.idea/workspace.xml +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +25 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +74 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/legion-extensions-health.gemspec +37 -0
- data/lib/legion/extensions/health.rb +10 -0
- data/lib/legion/extensions/health/actors/health.rb +9 -0
- data/lib/legion/extensions/health/actors/watchdog.rb +21 -0
- data/lib/legion/extensions/health/runners/health.rb +39 -0
- data/lib/legion/extensions/health/runners/watchdog.rb +26 -0
- data/lib/legion/extensions/health/transport/exchanges/node.rb +10 -0
- data/lib/legion/extensions/health/transport/messages/watchdog.rb +23 -0
- data/lib/legion/extensions/health/transport/queues/health.rb +15 -0
- data/lib/legion/extensions/health/version.rb +7 -0
- metadata +185 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c4be3a4b0f0ef799e3fc2db38ea95e1d5522e184fd0433bce64ad30905543142
|
4
|
+
data.tar.gz: 5095b66029faf430a2b2f995ab1a77e7ca37cf8382bf7da47e44a9bdb1f949bf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8729e7a2242b0c6e7adc8474717a2e43b1d2b7473669a1d8b7a3aa05ac1640e5ad49308b52386df84fa65922013d9f819ce798c7c5fcdc5c86f9b78721c16db0
|
7
|
+
data.tar.gz: 5bff8c5455b5b85ff769d4dae2b4aa57a97e0664f354ee872d969a23dadc41c3af11744ea5799eb05c043713885cbb8ff3867c59d72fa79d75d4fb12592ef922
|
@@ -0,0 +1,61 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.2.1
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
"rubocop":
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:2.5-node
|
9
|
+
steps:
|
10
|
+
- checkout
|
11
|
+
- ruby/load-cache
|
12
|
+
- ruby/install-deps
|
13
|
+
- run:
|
14
|
+
name: Run Rubocop
|
15
|
+
command: bundle exec rubocop
|
16
|
+
- ruby/save-cache
|
17
|
+
"ruby-two-five":
|
18
|
+
docker:
|
19
|
+
- image: circleci/ruby:2.5
|
20
|
+
- image: memcached:1.5-alpine
|
21
|
+
steps:
|
22
|
+
- checkout
|
23
|
+
- ruby/load-cache
|
24
|
+
- ruby/install-deps
|
25
|
+
- ruby/run-tests
|
26
|
+
- ruby/save-cache
|
27
|
+
"ruby-two-six":
|
28
|
+
docker:
|
29
|
+
- image: circleci/ruby:2.6
|
30
|
+
- image: memcached:1.5-alpine
|
31
|
+
steps:
|
32
|
+
- checkout
|
33
|
+
- ruby/load-cache
|
34
|
+
- ruby/install-deps
|
35
|
+
- ruby/run-tests
|
36
|
+
- ruby/save-cache
|
37
|
+
"ruby-two-seven":
|
38
|
+
docker:
|
39
|
+
- image: circleci/ruby:2.7
|
40
|
+
- image: memcached:1.5-alpine
|
41
|
+
steps:
|
42
|
+
- checkout
|
43
|
+
- ruby/load-cache
|
44
|
+
- ruby/install-deps
|
45
|
+
- ruby/run-tests
|
46
|
+
- ruby/save-cache
|
47
|
+
|
48
|
+
workflows:
|
49
|
+
version: 2
|
50
|
+
rubocop-rspec:
|
51
|
+
jobs:
|
52
|
+
- rubocop
|
53
|
+
- ruby-two-five:
|
54
|
+
requires:
|
55
|
+
- rubocop
|
56
|
+
- ruby-two-six:
|
57
|
+
requires:
|
58
|
+
- ruby-two-five
|
59
|
+
- ruby-two-seven:
|
60
|
+
requires:
|
61
|
+
- ruby-two-five
|
data/.gitignore
ADDED
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build lex-health-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install lex-health-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install lex-health-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push lex-health-0.1.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$" />
|
8
|
+
<orderEntry type="inheritedJdk" />
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="chef (v15.8.23, RVM: ruby-2.6.3) [gem]" level="application" />
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="codecov (v0.1.16, RVM: ruby-2.6.3) [gem]" level="application" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="docile (v1.3.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="jaro_winkler (v1.5.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v2.3.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v2.7.0.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.80.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-md (v0.3.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.5.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-rspec (v1.38.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.18.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.6.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="url (v0.3.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
37
|
+
</component>
|
38
|
+
</module>
|
data/.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="JavaScriptSettings">
|
4
|
+
<option name="languageLevel" value="ES6" />
|
5
|
+
</component>
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.6.3" project-jdk-type="RUBY_SDK" />
|
7
|
+
</project>
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/lex-health.iml" filepath="$PROJECT_DIR$/.idea/lex-health.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
data/.idea/vagrant.xml
ADDED
data/.idea/workspace.xml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="CoverageOptionsProvider">
|
4
|
+
<option name="myAddOrReplace" value="0" />
|
5
|
+
</component>
|
6
|
+
<component name="Git.Settings">
|
7
|
+
<option name="PUSH_AUTO_UPDATE" value="true" />
|
8
|
+
<option name="ROOT_SYNC" value="DONT_SYNC" />
|
9
|
+
</component>
|
10
|
+
<component name="PropertiesComponent">
|
11
|
+
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.vagrant" />
|
12
|
+
</component>
|
13
|
+
</project>
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Layout/LineLength:
|
2
|
+
Max: 120
|
3
|
+
Metrics/MethodLength:
|
4
|
+
Max: 30
|
5
|
+
Metrics/ClassLength:
|
6
|
+
Max: 1500
|
7
|
+
Metrics/BlockLength:
|
8
|
+
Max: 50
|
9
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
10
|
+
EnforcedStyle: space
|
11
|
+
Style/SymbolArray:
|
12
|
+
Enabled: true
|
13
|
+
Layout/HashAlignment:
|
14
|
+
EnforcedHashRocketStyle: table
|
15
|
+
EnforcedColonStyle: table
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
AllCops:
|
19
|
+
TargetRubyVersion: 2.5
|
20
|
+
Style/FrozenStringLiteralComment:
|
21
|
+
Enabled: false
|
22
|
+
Naming/FileName:
|
23
|
+
Enabled: false
|
24
|
+
Style/ClassAndModuleChildren:
|
25
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lex-health (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
codecov (0.1.16)
|
11
|
+
json
|
12
|
+
simplecov
|
13
|
+
url
|
14
|
+
diff-lcs (1.3)
|
15
|
+
docile (1.3.2)
|
16
|
+
jaro_winkler (1.5.4)
|
17
|
+
json (2.3.0)
|
18
|
+
parallel (1.19.1)
|
19
|
+
parser (2.7.0.4)
|
20
|
+
ast (~> 2.4.0)
|
21
|
+
rainbow (3.0.0)
|
22
|
+
rake (13.0.1)
|
23
|
+
rexml (3.2.4)
|
24
|
+
rspec (3.9.0)
|
25
|
+
rspec-core (~> 3.9.0)
|
26
|
+
rspec-expectations (~> 3.9.0)
|
27
|
+
rspec-mocks (~> 3.9.0)
|
28
|
+
rspec-core (3.9.1)
|
29
|
+
rspec-support (~> 3.9.1)
|
30
|
+
rspec-expectations (3.9.0)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.9.0)
|
33
|
+
rspec-mocks (3.9.1)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.9.0)
|
36
|
+
rspec-support (3.9.2)
|
37
|
+
rubocop (0.80.1)
|
38
|
+
jaro_winkler (~> 1.5.1)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 2.7.0.1)
|
41
|
+
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
rexml
|
43
|
+
ruby-progressbar (~> 1.7)
|
44
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
45
|
+
rubocop-md (0.3.1)
|
46
|
+
rubocop (~> 0.60)
|
47
|
+
rubocop-performance (1.5.2)
|
48
|
+
rubocop (>= 0.71.0)
|
49
|
+
rubocop-rspec (1.38.1)
|
50
|
+
rubocop (>= 0.68.1)
|
51
|
+
ruby-progressbar (1.10.1)
|
52
|
+
simplecov (0.18.5)
|
53
|
+
docile (~> 1.1)
|
54
|
+
simplecov-html (~> 0.11)
|
55
|
+
simplecov-html (0.12.2)
|
56
|
+
unicode-display_width (1.6.1)
|
57
|
+
url (0.3.2)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
ruby
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
bundler
|
64
|
+
codecov
|
65
|
+
lex-health!
|
66
|
+
rake
|
67
|
+
rspec
|
68
|
+
rubocop
|
69
|
+
rubocop-md
|
70
|
+
rubocop-performance
|
71
|
+
rubocop-rspec
|
72
|
+
|
73
|
+
BUNDLED WITH
|
74
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 miverso2
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Legion::Extensions::Health
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/legion/extensions/health`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'legion-extensions-health'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install legion-extensions-health
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/legion-extensions-health.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'legion/extensions/health'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'legion/extensions/health/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'lex-health'
|
7
|
+
spec.version = Legion::Extensions::Health::VERSION
|
8
|
+
spec.authors = ['Miverson']
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Legion::Extensions::Health'
|
12
|
+
spec.description = 'Used to read heartbeats and update the db'
|
13
|
+
spec.homepage = 'https://bitbucket.org/legion-io/lex-health'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/lex-heartbeat'
|
18
|
+
spec.metadata['changelog_uri'] = 'https://bitbucket.org/legion-io/lex-heartbeat/CHANGELOG.md'
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler'
|
30
|
+
spec.add_development_dependency 'codecov'
|
31
|
+
spec.add_development_dependency 'rake'
|
32
|
+
spec.add_development_dependency 'rspec'
|
33
|
+
spec.add_development_dependency 'rubocop'
|
34
|
+
spec.add_development_dependency 'rubocop-md'
|
35
|
+
spec.add_development_dependency 'rubocop-performance'
|
36
|
+
spec.add_development_dependency 'rubocop-rspec'
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'legion/extensions/actors/every'
|
2
|
+
|
3
|
+
module Legion::Extensions::Health::Actor
|
4
|
+
class Watchdog < Legion::Extensions::Actors::Every
|
5
|
+
def runner_function
|
6
|
+
'expire'
|
7
|
+
end
|
8
|
+
|
9
|
+
def time
|
10
|
+
5
|
11
|
+
end
|
12
|
+
|
13
|
+
def run_now?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def use_runner?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Legion::Extensions::Health
|
2
|
+
module Runners
|
3
|
+
module Health
|
4
|
+
include Legion::Extensions::Helpers::Lex
|
5
|
+
|
6
|
+
def self.update(hostname:, **opts)
|
7
|
+
item = Legion::Data::Model::Node.where(name: hostname).first
|
8
|
+
|
9
|
+
if item.nil?
|
10
|
+
return { success: true, hostname: hostname, **opts } if insert(hostname: hostname, **opts)
|
11
|
+
|
12
|
+
return { success: false, hostname: hostname, **opts }
|
13
|
+
end
|
14
|
+
|
15
|
+
if opts.key?(:timestamp) && !item.values[:updated].nil? && item.values[:updated] > Time.parse(opts[:timestamp])
|
16
|
+
return { success: false, reason: 'entry already updated', hostname: hostname, db_updated: item.values[:updated], **opts }
|
17
|
+
end
|
18
|
+
|
19
|
+
item.update(active: 1, status: opts[:status], name: hostname)
|
20
|
+
{ success: true, hostname: hostname, **opts }
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.insert(hostname:, status: 'unknown', **opts)
|
24
|
+
insert = { active: 1, status: status, name: hostname }
|
25
|
+
insert[:datacenter_id] = opts[:datacenter_id] if opts.key? :datacenter_id
|
26
|
+
insert[:environment_id] = opts[:environment_id] if opts.key? :environment_id
|
27
|
+
insert[:active] = opts[:active] if opts.key? :active
|
28
|
+
|
29
|
+
{ success: true, hostname: hostname, node_id: Legion::Data::Model::Node.insert(insert), **insert }
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.delete(node_id:, **_opts)
|
33
|
+
# Legion::Data::Model::Node.where(payload[:key].to_sym == payload[:value]).delete
|
34
|
+
Legion::Data::Model::Node[node_id].delete
|
35
|
+
{ success: true, node_id: node_id }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'legion/transport/messages/node_health'
|
2
|
+
|
3
|
+
module Legion::Extensions::Health
|
4
|
+
module Runners
|
5
|
+
module Watchdog
|
6
|
+
include Legion::Extensions::Helpers::Lex
|
7
|
+
|
8
|
+
def expire(**_opts)
|
9
|
+
nodes = []
|
10
|
+
Legion::Data::Model::Node
|
11
|
+
.where(status: 'healthy')
|
12
|
+
.where(Sequel.lit('updated <= DATE_SUB(SYSDATE(), INTERVAL 60 SECOND)'))
|
13
|
+
.where(active: true)
|
14
|
+
.each do |node|
|
15
|
+
Legion::Transport::Messages::NodeHealth.new(status: 'unknown',
|
16
|
+
node_id: node.values[:id],
|
17
|
+
hostname: node.values[:name],
|
18
|
+
timestamp: node.values[:updated]).publish
|
19
|
+
nodes.push(node.values[:id])
|
20
|
+
end
|
21
|
+
log.debug("count: #{nodes.count}")
|
22
|
+
{ success: true, count: nodes.count, nodes: nodes }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Legion::Extensions::Health::Transport::Messages
|
2
|
+
class Watchdog < Legion::Transport::Message
|
3
|
+
def routing_key
|
4
|
+
'health'
|
5
|
+
end
|
6
|
+
|
7
|
+
def expiration
|
8
|
+
5000
|
9
|
+
end
|
10
|
+
|
11
|
+
# def message
|
12
|
+
# hash = { hostname: Socket.gethostname, pid: Process.pid, timestamp: Time.now }
|
13
|
+
# hash[:status] = @options[:status].nil? ? 'healthy' : @options[:status]
|
14
|
+
# hash
|
15
|
+
# end
|
16
|
+
|
17
|
+
def validate
|
18
|
+
raise 'status should be a string' unless @options[:status].is_a?(String) || @options[:status].nil?
|
19
|
+
|
20
|
+
@valid = true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Legion::Extensions::Health
|
2
|
+
module Transport
|
3
|
+
module Queues
|
4
|
+
class Health < Legion::Transport::Queue
|
5
|
+
def queue_name
|
6
|
+
'node.health'
|
7
|
+
end
|
8
|
+
|
9
|
+
def queue_options
|
10
|
+
{ arguments: { 'x-single-active-consumer': true, 'x-dead-letter-exchange': 'node.dlx' }, auto_delete: false }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lex-health
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Miverson
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: codecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-md
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-performance
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Used to read heartbeats and update the db
|
126
|
+
email:
|
127
|
+
- matthewdiverson@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".circleci/config.yml"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".idea/.rakeTasks"
|
135
|
+
- ".idea/lex-health.iml"
|
136
|
+
- ".idea/misc.xml"
|
137
|
+
- ".idea/modules.xml"
|
138
|
+
- ".idea/vagrant.xml"
|
139
|
+
- ".idea/workspace.xml"
|
140
|
+
- ".rspec"
|
141
|
+
- ".rubocop.yml"
|
142
|
+
- Gemfile
|
143
|
+
- Gemfile.lock
|
144
|
+
- LICENSE.txt
|
145
|
+
- README.md
|
146
|
+
- Rakefile
|
147
|
+
- bin/console
|
148
|
+
- bin/setup
|
149
|
+
- legion-extensions-health.gemspec
|
150
|
+
- lib/legion/extensions/health.rb
|
151
|
+
- lib/legion/extensions/health/actors/health.rb
|
152
|
+
- lib/legion/extensions/health/actors/watchdog.rb
|
153
|
+
- lib/legion/extensions/health/runners/health.rb
|
154
|
+
- lib/legion/extensions/health/runners/watchdog.rb
|
155
|
+
- lib/legion/extensions/health/transport/exchanges/node.rb
|
156
|
+
- lib/legion/extensions/health/transport/messages/watchdog.rb
|
157
|
+
- lib/legion/extensions/health/transport/queues/health.rb
|
158
|
+
- lib/legion/extensions/health/version.rb
|
159
|
+
homepage: https://bitbucket.org/legion-io/lex-health
|
160
|
+
licenses:
|
161
|
+
- MIT
|
162
|
+
metadata:
|
163
|
+
homepage_uri: https://bitbucket.org/legion-io/lex-health
|
164
|
+
source_code_uri: https://bitbucket.org/legion-io/lex-heartbeat
|
165
|
+
changelog_uri: https://bitbucket.org/legion-io/lex-heartbeat/CHANGELOG.md
|
166
|
+
post_install_message:
|
167
|
+
rdoc_options: []
|
168
|
+
require_paths:
|
169
|
+
- lib
|
170
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
requirements: []
|
181
|
+
rubygems_version: 3.0.8
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: Legion::Extensions::Health
|
185
|
+
test_files: []
|