Skip to content

Commit 2ad97fd

Browse files
committed
Replace yajl-ruby with the json gem for JSON handling
Since the yajl-ruby gem depends on a deprecated Ruby C API, it cannot be installed with Ruby 4.1. Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent 64d170f commit 2ad97fd

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ compression_level best_compression
902902

903903
### prefer_oj_serializer
904904

905-
With default behavior, OpenSearch client uses `Yajl` as JSON encoder/decoder.
905+
With default behavior, OpenSearch client uses `JSON` as JSON encoder/decoder.
906906
`Oj` is the alternative high performance JSON encoder/decoder.
907907
When this parameter sets as `true`, OpenSearch client uses `Oj` as JSON encoder/decoder.
908908

lib/fluent/plugin/in_opensearch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def run
374374
def run_slice(slice_id=nil)
375375
slice_query = @base_query
376376
slice_query = slice_query.merge('slice' => { 'id' => slice_id, 'max' => @num_slices}) unless slice_id.nil?
377-
result = client.search(@options.merge(:body => Yajl.dump(slice_query) ))
377+
result = client.search(@options.merge(:body => JSON.generate(slice_query) ))
378378
es = Fluent::MultiEventStream.new
379379

380380
result["hits"]["hits"].each {|hit| process_events(hit, es)}

lib/fluent/plugin/out_opensearch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class << self
369369
OpenSearch::API.settings[:serializer] = Fluent::Plugin::Serializer::Oj
370370
end
371371
rescue LoadError
372-
@dump_proc = Yajl.method(:dump)
372+
@dump_proc = JSON.method(:generate)
373373
end
374374

375375
raise Fluent::ConfigError, "`password` must be present if `user` is present" if @user && @password.nil?
@@ -940,7 +940,7 @@ def get_affinity_target_indices(chunk)
940940
{"_index" => {"order" => "desc"}}
941941
]
942942
}
943-
result = client.search(options.merge(:body => Yajl.dump(query)))
943+
result = client.search(options.merge(:body => JSON.generate(query)))
944944
# There should be just one hit per _id, but in case there still is multiple, just the oldest index is stored to map
945945
result['hits']['hits'].each do |hit|
946946
indices[hit["_id"]] = hit["_index"]

0 commit comments

Comments
 (0)