serf_handler 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -9
- data/build/.gitignore +14 -0
- data/build/Gemfile +4 -0
- data/build/LICENSE.txt +22 -0
- data/build/README.md +31 -0
- data/build/Rakefile +2 -0
- data/build/build.gemspec +23 -0
- data/build/lib/build/version.rb +3 -0
- data/build/lib/build.rb +5 -0
- data/lib/serf_handler.rb +10 -6
- data/serf_handler.gemspec +3 -3
- data/spec/serf_handler_spec.rb +1 -1
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4381f72083c0b8c045b85e2d394eb05768e7ea6
|
4
|
+
data.tar.gz: 57d31e2825da8617e2f6f8b94843a44d03269da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e898353f579b8bb641768ed3e12950dd5f31587fd5f464b4146ecd2b57aa6958f2db736f957c6d9ac734fd4a43ee918f9958b7f0fcb087a829a94445a95d4f20
|
7
|
+
data.tar.gz: d7f63cef8c8a35b124978a806afb8263d80da55f5aca6e31c852469f2f475747692bc6a4052270184c0e5bd0d47ddc03c4890b7802b55f9799807423e411f921
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ serf_handler
|
|
2
2
|
============
|
3
3
|
[![Build Status](https://travis-ci.org/konchan/serf_handler.svg?branch=master)](https://travis-ci.org/konchan/serf_handler)
|
4
4
|
|
5
|
-
[Serf](http://www.serfdom.io/) is a cluster orchestration framework which developed by [HashiCorp](http://www.hashicorp.com/). Serf allows you to execute your scripts when serf event
|
5
|
+
[Serf](http://www.serfdom.io/) is a cluster orchestration framework which developed by [HashiCorp](http://www.hashicorp.com/). Serf allows you to execute your scripts when serf event occurs.
|
6
6
|
You can simply extend SerfHandler and process serf events. Serf_handler is a very simple Ruby framework with no dependencies.
|
7
7
|
I have a lot in reference to [this code](https://github.com/garethr/serf-master).
|
8
8
|
|
@@ -14,14 +14,20 @@ gem install serf_handler
|
|
14
14
|
|
15
15
|
### how to use
|
16
16
|
|
17
|
-
```
|
17
|
+
```ruby
|
18
|
+
#!/usr/bin/env ruby
|
18
19
|
require 'serf_handler'
|
19
20
|
|
20
|
-
class MyEventHandler
|
21
|
-
# called by SerfHandler when member-join event
|
21
|
+
class MyEventHandler < SerfHandler
|
22
|
+
# called by SerfHandler when member-join event occurs
|
22
23
|
def member_join
|
23
24
|
# write your code
|
24
25
|
end
|
26
|
+
|
27
|
+
# called by SerfHandler when your custome event occurs
|
28
|
+
def your_custome_event
|
29
|
+
# write your code
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
if __FILE__ == $0
|
@@ -32,8 +38,8 @@ end
|
|
32
38
|
```
|
33
39
|
|
34
40
|
### Contributing
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (```git checkout -b my-new-feature```)
|
43
|
+
3. Commit your changes (```git commit -am 'Add some feature'```)
|
44
|
+
4. Push to the branch (```git push origin my-new-feature```)
|
45
|
+
5. Create new Pull Request
|
data/build/.gitignore
ADDED
data/build/Gemfile
ADDED
data/build/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 konchan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/build/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Build
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'build'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install build
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/build/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/build/Rakefile
ADDED
data/build/build.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'build/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "build"
|
8
|
+
spec.version = Build::VERSION
|
9
|
+
spec.authors = ["konchan"]
|
10
|
+
spec.email = ["konno.katsuyuki@nifty.com"]
|
11
|
+
spec.summary = %q{TODO: Write a short summary. Required.}
|
12
|
+
spec.description = %q{TODO: Write a longer description. Optional.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/build/lib/build.rb
ADDED
data/lib/serf_handler.rb
CHANGED
@@ -6,9 +6,13 @@ require "logger"
|
|
6
6
|
class SerfHandler
|
7
7
|
attr :name, :role, :event
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
if
|
11
|
-
|
9
|
+
def initialize(log=nil)
|
10
|
+
if log
|
11
|
+
if log.kind_of?(String)
|
12
|
+
@logger = Logger.new(log)
|
13
|
+
else
|
14
|
+
@logger = log
|
15
|
+
end
|
12
16
|
else
|
13
17
|
@logger = Logger.new(STDOUT)
|
14
18
|
@logger.level = Logger::INFO
|
@@ -24,8 +28,8 @@ class SerfHandler
|
|
24
28
|
end
|
25
29
|
|
26
30
|
class SerfHandlerProxy < SerfHandler
|
27
|
-
def initialize(
|
28
|
-
super(
|
31
|
+
def initialize(log_file=nil)
|
32
|
+
super(log_file)
|
29
33
|
@handlers = {}
|
30
34
|
end
|
31
35
|
|
@@ -50,7 +54,7 @@ class SerfHandlerProxy < SerfHandler
|
|
50
54
|
begin
|
51
55
|
klass.send @event
|
52
56
|
rescue NoMethodError => e
|
53
|
-
log "event not implemented by class"
|
57
|
+
log "#{@event} event not implemented by class"
|
54
58
|
end
|
55
59
|
end
|
56
60
|
end
|
data/serf_handler.gemspec
CHANGED
@@ -5,11 +5,11 @@ require 'serf_handler'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = 'serf_handler'
|
8
|
-
gem.version = '0.1'
|
8
|
+
gem.version = '0.1.1'
|
9
9
|
gem.authors = ['KONNO Katsuyuki']
|
10
10
|
gem.email = 'konno.katsuyuki@nifty.com'
|
11
|
-
gem.description = 'Serf event
|
12
|
-
gem.summary = 'Serf event
|
11
|
+
gem.description = 'Serf event handler for ruby'
|
12
|
+
gem.summary = 'Serf event handler for ruby'
|
13
13
|
gem.homepage = 'http://github.com/konchan/serf_handler'
|
14
14
|
gem.licenses = ['MIT']
|
15
15
|
|
data/spec/serf_handler_spec.rb
CHANGED
@@ -70,7 +70,7 @@ describe "SerfHandlerProxy" do
|
|
70
70
|
|
71
71
|
it "has no method implemented" do
|
72
72
|
logger = double('Logger')
|
73
|
-
expect(logger).to receive(:info).with("event not implemented by class").and_return(true)
|
73
|
+
expect(logger).to receive(:info).with("member_join event not implemented by class").and_return(true)
|
74
74
|
handler = SerfHandlerProxy.new(logger)
|
75
75
|
handler.register('default', SerfHandler.new)
|
76
76
|
handler.run
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serf_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KONNO Katsuyuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logger
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.2.8
|
27
|
-
description: Serf event
|
27
|
+
description: Serf event handler for ruby
|
28
28
|
email: konno.katsuyuki@nifty.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
@@ -38,6 +38,14 @@ files:
|
|
38
38
|
- LICENSE
|
39
39
|
- README.md
|
40
40
|
- Rakefile
|
41
|
+
- build/.gitignore
|
42
|
+
- build/Gemfile
|
43
|
+
- build/LICENSE.txt
|
44
|
+
- build/README.md
|
45
|
+
- build/Rakefile
|
46
|
+
- build/build.gemspec
|
47
|
+
- build/lib/build.rb
|
48
|
+
- build/lib/build/version.rb
|
41
49
|
- lib/serf_handler.rb
|
42
50
|
- serf_handler.gemspec
|
43
51
|
- spec/serf_handler_spec.rb
|
@@ -65,7 +73,7 @@ rubyforge_project:
|
|
65
73
|
rubygems_version: 2.0.14
|
66
74
|
signing_key:
|
67
75
|
specification_version: 4
|
68
|
-
summary: Serf event
|
76
|
+
summary: Serf event handler for ruby
|
69
77
|
test_files:
|
70
78
|
- spec/serf_handler_spec.rb
|
71
79
|
- spec/spec_helper.rb
|