Skip to content
This repository was archived by the owner on Mar 25, 2020. It is now read-only.

Commit c5e6e9e

Browse files
committed
Actually initialize the transport client as the correct impl class
1 parent 6b74b23 commit c5e6e9e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

lib/logstash/outputs/elasticsearch_java/protocol.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ def initialize(options={})
1414
@logger = Cabin::Channel.get
1515
end
1616

17-
def client
18-
return @client if @client
19-
@client = build_client(@options)
20-
return @client
21-
end
22-
2317
def template_install(name, template, force=false)
2418
if template_exists?(name) && !force
2519
@logger.debug("Found existing Elasticsearch template. Skipping template management", :name => name)
@@ -236,6 +230,13 @@ def template_put(name, template)
236230
end # class NodeClient
237231

238232
class TransportClient < NodeClient
233+
def client
234+
return @client if @client
235+
@client = build_client(@options)
236+
return @client
237+
end
238+
239+
239240
private
240241
def build_client(options)
241242
client = org.elasticsearch.client.transport.TransportClient.

spec/integration/outputs/transport_create_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ def get_es_output(action, id = nil)
2929
end
3030

3131
context "when action => create" do
32+
it "should instantiate a transport, not node, client" do
33+
subject = get_es_output("create", "id123")
34+
subject.register
35+
expect(subject.client.send(:client).class).to eql(Java::OrgElasticsearchClientTransport::TransportClient)
36+
end
37+
3238
it "should create new documents with or without id" do
3339
subject = get_es_output("create", "id123")
3440
subject.register

0 commit comments

Comments
 (0)