File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
lib/elasticsearch/transport
spec/elasticsearch/transport Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -41,15 +41,31 @@ def set_meta_header
41
41
end
42
42
43
43
def meta_header_service_version
44
- if defined? ( Elastic ::META_HEADER_SERVICE_VERSION )
45
- Elastic ::META_HEADER_SERVICE_VERSION
44
+ if enterprise_search?
45
+ Elastic ::ENTERPRISE_SERVICE_VERSION
46
+ elsif elasticsearch?
47
+ Elastic ::ELASTICSEARCH_SERVICE_VERSION
46
48
elsif defined? ( Elasticsearch ::VERSION )
47
49
[ :es , client_meta_version ( Elasticsearch ::VERSION ) ]
48
50
else
49
51
[ :es , client_meta_version ( Elasticsearch ::Transport ::VERSION ) ]
50
52
end
51
53
end
52
54
55
+ def enterprise_search?
56
+ defined? ( Elastic ::ENTERPRISE_SERVICE_VERSION ) &&
57
+ called_from? ( 'enterprise-search-ruby' )
58
+ end
59
+
60
+ def elasticsearch?
61
+ defined? ( Elastic ::ELASTICSEARCH_SERVICE_VERSION ) &&
62
+ called_from? ( 'elasticsearch' )
63
+ end
64
+
65
+ def called_from? ( service )
66
+ !caller . select { |c | c . match? ( service ) } . empty?
67
+ end
68
+
53
69
# We return the current version if it's a release, but if it's a pre/alpha/beta release we
54
70
# return <VERSION_NUMBER>p
55
71
#
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ def initialize(args); end
251
251
252
252
context 'when using a different service version' do
253
253
before do
254
- stub_const ( " Elastic::META_HEADER_SERVICE_VERSION" , [ :ent , '8.0.0' ] )
254
+ stub_const ( ' Elastic::ELASTICSEARCH_SERVICE_VERSION' , [ :ent , '8.0.0' ] )
255
255
end
256
256
257
257
let ( :client ) { Elasticsearch ::Client . new }
Original file line number Diff line number Diff line change @@ -38,5 +38,5 @@ def self.client_meta_version
38
38
end
39
39
40
40
# Constant for elasticsearch-transport meta-header
41
- META_HEADER_SERVICE_VERSION = [ :es , client_meta_version ] . freeze
41
+ ELASTICSEARCH_SERVICE_VERSION = [ :es , client_meta_version ] . freeze
42
42
end
You can’t perform that action at this time.
0 commit comments