influxdb 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/lib/influxdb/client.rb +10 -5
- data/lib/influxdb/version.rb +1 -1
- data/lib/influxdb/worker.rb +6 -1
- data/spec/influxdb/client_spec.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWYyOTdjYTlkOGM4ZTk0Y2Q1MmQ5YmMwMDM0ODlmNTQ0YmI5MDQzNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
NmFhMjg0MmU3M2Q2NzVjNWMyYzg4ZGVkNzQ3NmI4NzBlNTdjMTA3Nw==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWVhZjdhN2NmOGU5ZTVhMjMyNjc0N2RlZThmNWJiNDU1ODRmN2Q2ZWI0N2Ex
|
10
|
+
N2MyMmU4YmNjYTM0YmY3ZWUwNTNjOTE3ZDBiMzNlOGZjZjZlYzk0Yjc5MWE5
|
11
|
+
N2M0MGI2NDE4Mzg3OGU4ZDQwYzU3ODVjZmIyNzNhMjcxNzU4ZjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGUxYmU5YWE0ZjQ5OWVlODcxMDEyM2M4ZDdlN2FlMmI2NjcyZjhmMTg2Mjdl
|
14
|
+
OTlhYWFhZmMxMjExNDMwYTgwZGIxMDFiOTRmNzU4ZDNlNTcxZmFlMDFkNjdi
|
15
|
+
ZWQ0MzNkMzYyNjNjMWYwOTQzMjRlNTk3YTRlZTZmYTA4MjE2NjY=
|
data/lib/influxdb/client.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'net/http'
|
3
|
+
require 'net/https'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
module InfluxDB
|
6
7
|
class Client
|
7
8
|
attr_accessor :host, :port, :username, :password, :database
|
8
|
-
attr_accessor :queue
|
9
|
+
attr_accessor :queue, :worker
|
9
10
|
|
10
11
|
include InfluxDB::Logger
|
11
|
-
include InfluxDB::Worker
|
12
12
|
|
13
13
|
# Initializes a new Influxdb client
|
14
14
|
#
|
@@ -30,6 +30,7 @@ module InfluxDB
|
|
30
30
|
# +:port+:: the port to connect to
|
31
31
|
# +:username+:: the username to use when executing commands
|
32
32
|
# +:password+:: the password associated with the username
|
33
|
+
# +:use_ssl+:: use ssl to connect
|
33
34
|
def initialize *args
|
34
35
|
@database = args.first if args.first.is_a? String
|
35
36
|
opts = args.last.is_a?(Hash) ? args.last : {}
|
@@ -38,8 +39,7 @@ module InfluxDB
|
|
38
39
|
@username = opts[:username] || "root"
|
39
40
|
@password = opts[:password] || "root"
|
40
41
|
@http = Net::HTTP.new(@host, @port)
|
41
|
-
@
|
42
|
-
spawn_threads!
|
42
|
+
@http.use_ssl = opts[:use_ssl]
|
43
43
|
end
|
44
44
|
|
45
45
|
def create_database(name)
|
@@ -136,7 +136,12 @@ module InfluxDB
|
|
136
136
|
payload[:points].push point
|
137
137
|
end
|
138
138
|
|
139
|
-
async
|
139
|
+
if async
|
140
|
+
@worker = InfluxDB::Worker.new if @worker.nil?
|
141
|
+
@worker.queue.push(payload)
|
142
|
+
else
|
143
|
+
_write([payload])
|
144
|
+
end
|
140
145
|
end
|
141
146
|
|
142
147
|
def _write(payload)
|
data/lib/influxdb/version.rb
CHANGED
data/lib/influxdb/worker.rb
CHANGED
@@ -3,7 +3,7 @@ require "net/http"
|
|
3
3
|
require "uri"
|
4
4
|
|
5
5
|
module InfluxDB
|
6
|
-
|
6
|
+
class Worker
|
7
7
|
attr_accessor :queue
|
8
8
|
|
9
9
|
include InfluxDB::Logger
|
@@ -12,6 +12,11 @@ module InfluxDB
|
|
12
12
|
NUM_WORKER_THREADS = 3
|
13
13
|
SLEEP_INTERVAL = 500
|
14
14
|
|
15
|
+
def initialize
|
16
|
+
@queue = InfluxDB::MaxQueue.new
|
17
|
+
spawn_threads!
|
18
|
+
end
|
19
|
+
|
15
20
|
def current_threads
|
16
21
|
Thread.list.select {|t| t[:influxdb] == self.object_id}
|
17
22
|
end
|
@@ -18,6 +18,7 @@ describe InfluxDB::Client do
|
|
18
18
|
@influxdb.port.should == 8086
|
19
19
|
@influxdb.username.should == "root"
|
20
20
|
@influxdb.password.should == "root"
|
21
|
+
@influxdb.instance_variable_get(:@http).use_ssl?.should == false
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -65,6 +66,20 @@ describe InfluxDB::Client do
|
|
65
66
|
@influxdb.password.should == "password"
|
66
67
|
end
|
67
68
|
end
|
69
|
+
|
70
|
+
describe "with ssl option specified" do
|
71
|
+
it "should be initialized with ssl enabled" do
|
72
|
+
@influxdb = InfluxDB::Client.new nil, :use_ssl => true
|
73
|
+
|
74
|
+
@influxdb.should be_a InfluxDB::Client
|
75
|
+
@influxdb.database.should be_nil
|
76
|
+
@influxdb.host.should == "localhost"
|
77
|
+
@influxdb.port.should == 8086
|
78
|
+
@influxdb.username.should == "root"
|
79
|
+
@influxdb.password.should == "root"
|
80
|
+
@influxdb.instance_variable_get(:@http).use_ssl?.should == true
|
81
|
+
end
|
82
|
+
end
|
68
83
|
end
|
69
84
|
|
70
85
|
describe "#create_database" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Persen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.1.11
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Ruby library for InfluxDB.
|