ringflux 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2ef9bb7819906332ec3ad88ba08791c2812ca31f
4
+ data.tar.gz: 44f8e923e95aca3c7ca8385a2bedbc3cb8bda233
5
+ SHA512:
6
+ metadata.gz: 7d8391aab4fb9c8b8ed45ef95a5abb243ae1e0576c0a212e29ef620c7e5d8b62142c515eff3fd1a4353c65bb0ec883bccd313026d82c981a2a4fa462320dcd9c
7
+ data.tar.gz: 18bdf6ebbb473fbfcf697f6154abdd015b6413e14ca45a832b7c598983aa5b3d6d0fb85d4056dfe317aa600ef5a2efea21fc2ad36108a66163a4c22f6e1a17ba
@@ -0,0 +1,3 @@
1
+ .*.sw*
2
+ .DS_Store
3
+ /Gemfile.lock
@@ -0,0 +1,2 @@
1
+ # [0.0.1](https://github.com/powerhome/ringflux/tree/v0.0.1)
2
+ * Initial plugin for connection Adhearsion to InfluxDB
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in plugin-template.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Power Home Remodeling Group LLC
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.
@@ -0,0 +1,24 @@
1
+ Ringflux
2
+ =========
3
+
4
+ An Adhearsion plugin providing integration with InfluxDB
5
+
6
+ Configuration
7
+ -------------
8
+
9
+ As with all Adhearsion plugins, type `rake config:show` to see the list of configuration options.
10
+
11
+ Usage
12
+ -----
13
+
14
+ ```Ruby
15
+ data = {
16
+ values: { active_calls: Adhearsion.active_calls.count },
17
+ tags: { environment: Adhearsion.environment, host: Adhearsion::Process.fqdn }
18
+ # tags are optional
19
+ }
20
+
21
+ Ringflux.write_point "active_calls", data
22
+ ```
23
+
24
+ See [InfluxDB Ruby gem](https://github.com/influxdata/influxdb-ruby) for more information.
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ require "bundler/gem_tasks"
3
+
4
+ require "rspec/core"
5
+ require "rspec/core/rake_task"
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = 'spec/**/*_spec.rb'
8
+ spec.rspec_opts = '--color'
9
+ end
10
+
11
+ task :default => :spec
@@ -0,0 +1,8 @@
1
+ module Ringflux
2
+ def self.write_point(*args)
3
+ Plugin.write_point(*args)
4
+ end
5
+ end
6
+
7
+ require "ringflux/version"
8
+ require "ringflux/plugin"
@@ -0,0 +1,36 @@
1
+ require 'influxdb'
2
+ require 'countdownlatch'
3
+
4
+ class Ringflux::Plugin < Adhearsion::Plugin
5
+ mattr_reader :connection
6
+
7
+ # Configure the connection information to your InfluxDB instance.
8
+ config :ringflux do
9
+ host nil , desc: 'Hostname/IP to the InfluxDB server'
10
+ username nil , desc: 'InfluxDB username'
11
+ password nil , desc: 'InfluxDB password'
12
+ database 'adhearsion', desc: 'host where the message queue is running'
13
+ async true , desc: 'Write metrics asynchronously'
14
+ end
15
+
16
+ run :ringflux, after: :punchblock do
17
+ InfluxDB::Logging.logger = logger
18
+ new.start
19
+ end
20
+
21
+ def start
22
+ logger.info "Connecting to InfluxDB #{config.username}@#{config.host} with database #{config.database}"
23
+ @@connection = InfluxDB::Client.new config.database, host: config.host, username: config.username, password: config.password, async: config.async
24
+ end
25
+
26
+ def self.write_point(*args)
27
+ logger.debug "Sending data to InfluxDB: #{args.inspect}"
28
+ @@connection.write_point(*args)
29
+ end
30
+
31
+ private
32
+
33
+ def config
34
+ self.class.config
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module Ringflux
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ringflux/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ringflux"
7
+ s.version = Ringflux::VERSION
8
+ s.authors = ["Ben Klang"]
9
+ s.email = ["bklang@powerhrg.com"]
10
+ s.homepage = "https://github.com/powerhome/ringflux"
11
+ s.summary = %q{InfluxDB plugin for Adhearsion}
12
+ s.description = %q{This gem provides a plugin for Adhearsion, allowing you to publish metrics to InfluxDB}
13
+
14
+ s.license = 'MIT'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_runtime_dependency %q<adhearsion>, ["~> 2.1"]
21
+ s.add_runtime_dependency %q<influxdb>, ["~> 0.3"]
22
+
23
+ s.add_development_dependency %q<bundler>, ["~> 1.0"]
24
+ s.add_development_dependency %q<rspec>, ["~> 2.5"]
25
+ s.add_development_dependency %q<rake>, [">= 0"]
26
+ s.add_development_dependency %q<guard-rspec>
27
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Amequp::Plugin do
4
+ subject { Amequp::Plugin.new }
5
+
6
+ describe '#start' do
7
+ it 'should allow specifying a URI for the connection information' do
8
+ config = {uri: 'amqp://amqpuser:amqppass@foo.bar.com:9530/'}
9
+ expected_params = {
10
+ username: 'amqpuser',
11
+ password: 'amqppass',
12
+ hostname: 'foo.bar.com',
13
+ port: 9530,
14
+ uri: 'amqp://amqpuser:amqppass@foo.bar.com:9530/'
15
+ }
16
+ subject.should_receive(:establish_connection).once.with(expected_params)
17
+ subject.start config
18
+ end
19
+
20
+ it 'should default to the correct port if the URI does not specify one' do
21
+ config = {uri: 'amqp://amqpuser:amqppass@foo.bar.com/', port: 6379}
22
+ expected_params = {
23
+ username: 'amqpuser',
24
+ password: 'amqppass',
25
+ hostname: 'foo.bar.com',
26
+ port: 6379,
27
+ uri: 'amqp://amqpuser:amqppass@foo.bar.com/'
28
+ }
29
+ subject.should_receive(:establish_connection).once.with(expected_params)
30
+ subject.start config
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Amequp do
4
+ subject { Amequp }
5
+
6
+ describe 'Amequp.do_something' do
7
+ let(:connection) { double 'Amequp::Plugin.connection' }
8
+
9
+ it 'gets sent to Redis' do
10
+ Amequp::Plugin.stub(:connection).and_return connection
11
+ connection.should_receive(:set).with "foo", "bar"
12
+
13
+ Amequp.set "foo", "bar"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ require 'adhearsion'
2
+ require 'amequp'
3
+
4
+ RSpec.configure do |config|
5
+ config.color_enabled = true
6
+ config.tty = true
7
+
8
+ config.filter_run :focus => true
9
+ config.run_all_when_everything_filtered = true
10
+ end
11
+
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ringflux
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ben Klang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: adhearsion
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: influxdb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.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: '2.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
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: guard-rspec
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
+ description: This gem provides a plugin for Adhearsion, allowing you to publish metrics
98
+ to InfluxDB
99
+ email:
100
+ - bklang@powerhrg.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - CHANGELOG.md
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - lib/ringflux.rb
112
+ - lib/ringflux/plugin.rb
113
+ - lib/ringflux/version.rb
114
+ - ringflux.gemspec
115
+ - spec/amequp/plugin_spec.rb
116
+ - spec/amequp/send_connection_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/powerhome/ringflux
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.8
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: InfluxDB plugin for Adhearsion
142
+ test_files:
143
+ - spec/amequp/plugin_spec.rb
144
+ - spec/amequp/send_connection_spec.rb
145
+ - spec/spec_helper.rb