Skip to content

Commit

Permalink
Implement batch write (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolincova committed Feb 13, 2020
1 parent 893e5bd commit 365c0ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/influxdb2/client/point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def initialize(name:, tags: nil, fields: nil, time: nil, precision: DEFAULT_WRIT
@time = time
@precision = precision
end
attr_writer :precision
attr_reader :precision

# Create DataPoint instance from specified data.
#
Expand Down
5 changes: 3 additions & 2 deletions lib/influxdb2/client/write_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def initialize(key, data)

# Key for batch item
class BatchItemKey
def initialize(bucket, org, precision = DEFAULT_WRITE_PRECISION)
def initialize(bucket, org, precision: DEFAULT_WRITE_PRECISION)
@bucket = bucket
@org = org
@precision = precision
Expand Down Expand Up @@ -197,7 +197,8 @@ def _generate_payload(data, precision: nil, bucket: nil, org: nil)
if data.nil?
nil
elsif data.is_a?(Point)
_generate_payload(data.to_line_protocol, bucket: bucket, org: org, precision: data.precision)
_generate_payload(data.to_line_protocol, bucket: bucket, org: org, precision: data.precision ||
DEFAULT_WRITE_PRECISION)
elsif data.is_a?(String)
if data.empty?
nil
Expand Down

0 comments on commit 365c0ea

Please sign in to comment.