Skip to content

Commit efc1c06

Browse files
refactor namespace, une PluginMixins for Common and NoopLicenseChecker
1 parent 39a270d commit efc1c06

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

lib/logstash/outputs/elasticsearch.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@
8686
class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
8787
declare_threadsafe!
8888

89-
require "logstash/outputs/elasticsearch/license_check"
89+
require "logstash/outputs/elasticsearch/license_checker"
9090
require "logstash/outputs/elasticsearch/http_client"
9191
require "logstash/outputs/elasticsearch/http_client_builder"
9292
require "logstash/plugin_mixins/elasticsearch/api_configs"
93-
require "logstash/outputs/elasticsearch/common"
93+
require "logstash/plugin_mixins/elasticsearch/common"
9494
require "logstash/outputs/elasticsearch/ilm"
9595
require 'logstash/plugin_mixins/ecs_compatibility_support'
9696

9797
# Protocol agnostic methods
98-
include(LogStash::Outputs::ElasticSearch::Common)
98+
include(LogStash::PluginMixins::ElasticSearch::Common)
9999

100100
# Methods for ILM support
101101
include(LogStash::Outputs::ElasticSearch::Ilm)
@@ -265,7 +265,7 @@ def register
265265
# the license_checking behaviour in the Pool class is externalized in the LogStash::ElasticSearchOutputLicenseChecker
266266
# class defined in license_check.rb. This license checking is specific to the elasticsearch output here and passed
267267
# to build_client down to the Pool class.
268-
build_client(LogStash::ElasticSearchOutputLicenseChecker.new(@logger))
268+
build_client(LicenseChecker.new(@logger))
269269
setup_after_successful_connection
270270
check_action_validity
271271
@bulk_request_metrics = metric.namespace(:bulk_requests)

lib/logstash/outputs/elasticsearch/http_client/pool.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "logstash/outputs/elasticsearch/license_check"
1+
require "logstash/plugin_mixins/elasticsearch/noop_license_checker"
22

33
module LogStash; module Outputs; class ElasticSearch; class HttpClient;
44
class Pool
@@ -70,7 +70,7 @@ def initialize(logger, adapter, initial_urls=[], options={})
7070
@url_info = {}
7171
@stopping = false
7272

73-
@license_checker = options.fetch(:license_checker) { LogStash::NoopLicenseChecker::INSTANCE }
73+
@license_checker = options.fetch(:license_checker) { LogStash::PluginMixins::ElasticSearch::NoopLicenseChecker::INSTANCE }
7474
end
7575

7676
def start

lib/logstash/outputs/elasticsearch/license_check.rb renamed to lib/logstash/outputs/elasticsearch/license_checker.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
module LogStash
2-
class NoopLicenseChecker
3-
INSTANCE = self.new
4-
5-
def appropriate_license?(pool, url)
6-
true
7-
end
8-
end
9-
10-
class ElasticSearchOutputLicenseChecker
1+
module LogStash; module Outputs; class ElasticSearch
2+
class LicenseChecker
113

124
def initialize(logger)
135
@logger = logger
@@ -52,4 +44,4 @@ def log_license_deprecation_warn(url)
5244
@logger.warn("DEPRECATION WARNING: Connecting to an OSS distribution of Elasticsearch using the default distribution of Logstash will stop working in Logstash 8.0.0. Please upgrade to the default distribution of Elasticsearch, or use the OSS distribution of Logstash", :url => url.sanitized.to_s)
5345
end
5446
end
55-
end
47+
end; end; end

lib/logstash/outputs/elasticsearch/common.rb renamed to lib/logstash/plugin_mixins/elasticsearch/common.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "logstash/outputs/elasticsearch/template_manager"
22

3-
module LogStash; module Outputs; class ElasticSearch;
3+
module LogStash; module PluginMixins; module ElasticSearch
44
module Common
55

66
# This module defines common methods that can be reused by alternate elasticsearch output plugins such as the elasticsearch_data_streams output.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module LogStash; module PluginMixins; module ElasticSearch
2+
class NoopLicenseChecker
3+
INSTANCE = self.new
4+
5+
def appropriate_license?(pool, url)
6+
true
7+
end
8+
end
9+
end; end; end

spec/unit/outputs/elasticsearch/http_client/pool_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
# TODO: extract to ElasticSearchOutputLicenseChecker unit spec
273273
describe "license checking with ElasticSearchOutputLicenseChecker" do
274274
let(:options) do
275-
super().merge(:license_checker => LogStash::ElasticSearchOutputLicenseChecker.new(logger))
275+
super().merge(:license_checker => LogStash::Outputs::ElasticSearch::LicenseChecker.new(logger))
276276
end
277277

278278
before(:each) do

spec/unit/outputs/license_check_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require "logstash/devutils/rspec/spec_helper"
22
require "logstash/outputs/elasticsearch/http_client"
3-
require "logstash/outputs/elasticsearch/license_check"
3+
require "logstash/outputs/elasticsearch/license_checker"
44

5-
describe LogStash::ElasticSearchOutputLicenseChecker do
5+
describe LogStash::Outputs::ElasticSearch::LicenseChecker do
66

77
# Note that the actual license checking logic is spec'ed in pool_spec.rb
88

0 commit comments

Comments
 (0)