Skip to content

Commit

Permalink
Follow client configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed Feb 28, 2021
1 parent ea78ac9 commit 60edb69
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 34 deletions.
3 changes: 1 addition & 2 deletions lib/influxdb-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def client
read_timeout: cfg.read_timeout,
use_ssl: cfg.use_ssl,
logger: logger,
async: cfg.async,
retries: cfg.retries
async: cfg.async
)
end
end
Expand Down
25 changes: 12 additions & 13 deletions lib/influxdb/rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,17 @@ class ClientConfig
private_constant :WRITE_TYPE

set_defaults(
url: "http://localhost:8086".freeze,
token: nil,
org: nil,
bucket: nil,
use_ssl: true,
open_timeout: 5,
write_timeout: 5,
read_timeout: 60,
precision: ::InfluxDB2::WritePrecision::MILLISECOND,
retries: 0,
async: true,
max_retry_delay_ms: 10 * 1000
url: "http://localhost:8086".freeze,
token: nil,
org: nil,
bucket: nil,
use_ssl: true,
open_timeout: 5,
write_timeout: 5,
read_timeout: 60,
precision: ::InfluxDB2::WritePrecision::MILLISECOND,
max_retries: 0,
async: true
)

def initialize
Expand All @@ -56,7 +55,7 @@ def initialize
def write_options
InfluxDB2::WriteOptions.new(
write_type: WRITE_TYPE[async],
max_retries: retries
max_retries: max_retries
)
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/rails/generators/influxdb/templates/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
# config.client.write_timeout = 5.seconds
# config.client.read_timeout = 60.seconds
# config.client.time_precisions = InfluxDB2::WritePrecision::MILLISECOND
# config.client.retries = 0
# config.client.max_retry_delay_ms = 10_000
# config.client.max_retries = 0
# config.client.async = true

## Disable rails framework hooks.
Expand Down
21 changes: 4 additions & 17 deletions spec/unit/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
describe "client configuration" do
subject { InfluxDB::Rails.configuration.client }

describe "#retries" do
describe "#max_retries" do
it "defaults to 0" do
expect(subject.retries).to eq(0)
expect(subject.max_retries).to eq(0)
end

it "can be updated" do
InfluxDB::Rails.configure do |config|
config.client.retries = 5
config.client.max_retries = 5
end
expect(subject.retries).to eql(5)
expect(subject.max_retries).to eql(5)
expect(subject.write_options.max_retries).to eql(5)
end
end
Expand Down Expand Up @@ -61,19 +61,6 @@
end
end

describe "#max_retry_delay_ms" do
it "defaults to 10 seconds in milliseconds" do
expect(subject.max_retry_delay_ms).to eql(10_000)
end

it "can be updated" do
InfluxDB::Rails.configure do |config|
config.client.max_retry_delay_ms = 5
end
expect(subject.max_retry_delay_ms).to eql(5)
end
end

describe "#precision" do
it "defaults to milli seconds" do
expect(subject.precision).to eql(::InfluxDB2::WritePrecision::MILLISECOND)
Expand Down

0 comments on commit 60edb69

Please sign in to comment.