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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWViNjMyNTE1YzkxZTI1ODAyZjQ3YzdlNmRlYTcwNTY3OWRiNjUwMA==
4
+ ZWYyOTdjYTlkOGM4ZTk0Y2Q1MmQ5YmMwMDM0ODlmNTQ0YmI5MDQzNw==
5
5
  data.tar.gz: !binary |-
6
- ZjFiODMzNzA1MDU5YzQzNTk3Nzc3MDU5YzY3MmE3ZDVlYmI0OWE4ZQ==
7
- !binary "U0hBNTEy":
6
+ NmFhMjg0MmU3M2Q2NzVjNWMyYzg4ZGVkNzQ3NmI4NzBlNTdjMTA3Nw==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- OTU4MmI5N2E0MTViYzc3MmIyYjM3MDc0YTE5NGExMWFkZWU4MjZiMTgyZTAz
10
- YTJkNDIxM2MwNDJmYjcwMTRkYWU3YTRhMjQ3MTY5Y2UyNTk1ZWEzNjhmMThk
11
- NWY0MjM4Y2VkMDgzN2MzMDAzNGI2ZmU5OWRmMDA0ZDMwN2NlZWE=
9
+ YWVhZjdhN2NmOGU5ZTVhMjMyNjc0N2RlZThmNWJiNDU1ODRmN2Q2ZWI0N2Ex
10
+ N2MyMmU4YmNjYTM0YmY3ZWUwNTNjOTE3ZDBiMzNlOGZjZjZlYzk0Yjc5MWE5
11
+ N2M0MGI2NDE4Mzg3OGU4ZDQwYzU3ODVjZmIyNzNhMjcxNzU4ZjM=
12
12
  data.tar.gz: !binary |-
13
- MTQxYzc2ZjFmNmYxNDI3MzI0MTZmNGVmNjZkZmEyYTk0Y2JhNmEyMTBhOWVl
14
- NDc5NTQ5ZjhiYTIxMmMyOWRjMjc4MmUwYmM5NDZmOWJiM2Y3OWUyNmJjMTA2
15
- MWEwMTRkMWZkNTAwZDgzN2JjZmM2MTUwYjY4MmM0ZjY2NGM0NTI=
13
+ ZGUxYmU5YWE0ZjQ5OWVlODcxMDEyM2M4ZDdlN2FlMmI2NjcyZjhmMTg2Mjdl
14
+ OTlhYWFhZmMxMjExNDMwYTgwZGIxMDFiOTRmNzU4ZDNlNTcxZmFlMDFkNjdi
15
+ ZWQ0MzNkMzYyNjNjMWYwOTQzMjRlNTk3YTRlZTZmYTA4MjE2NjY=
@@ -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
- @queue = InfluxDB::MaxQueue.new
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 ? @queue.push(payload) : _write([payload])
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)
@@ -1,3 +1,3 @@
1
1
  module InfluxDB
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -3,7 +3,7 @@ require "net/http"
3
3
  require "uri"
4
4
 
5
5
  module InfluxDB
6
- module Worker
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.11
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-12 00:00:00.000000000 Z
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.0.7
128
+ rubygems_version: 2.1.11
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Ruby library for InfluxDB.