elastic-transport 8.0.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.github/check_license_headers.rb +33 -0
  3. data/.github/license-header.txt +16 -0
  4. data/.github/workflows/license.yml +13 -0
  5. data/.github/workflows/tests.yml +45 -0
  6. data/.gitignore +19 -0
  7. data/CHANGELOG.md +224 -0
  8. data/Gemfile +38 -0
  9. data/LICENSE +202 -0
  10. data/README.md +552 -0
  11. data/Rakefile +87 -0
  12. data/elastic-transport.gemspec +74 -0
  13. data/lib/elastic/transport/client.rb +276 -0
  14. data/lib/elastic/transport/meta_header.rb +135 -0
  15. data/lib/elastic/transport/redacted.rb +73 -0
  16. data/lib/elastic/transport/transport/base.rb +450 -0
  17. data/lib/elastic/transport/transport/connections/collection.rb +126 -0
  18. data/lib/elastic/transport/transport/connections/connection.rb +160 -0
  19. data/lib/elastic/transport/transport/connections/selector.rb +91 -0
  20. data/lib/elastic/transport/transport/errors.rb +91 -0
  21. data/lib/elastic/transport/transport/http/curb.rb +120 -0
  22. data/lib/elastic/transport/transport/http/faraday.rb +95 -0
  23. data/lib/elastic/transport/transport/http/manticore.rb +179 -0
  24. data/lib/elastic/transport/transport/loggable.rb +83 -0
  25. data/lib/elastic/transport/transport/response.rb +36 -0
  26. data/lib/elastic/transport/transport/serializer/multi_json.rb +52 -0
  27. data/lib/elastic/transport/transport/sniffer.rb +101 -0
  28. data/lib/elastic/transport/version.rb +22 -0
  29. data/lib/elastic/transport.rb +37 -0
  30. data/lib/elastic-transport.rb +18 -0
  31. data/spec/elasticsearch/connections/collection_spec.rb +266 -0
  32. data/spec/elasticsearch/connections/selector_spec.rb +166 -0
  33. data/spec/elasticsearch/transport/base_spec.rb +264 -0
  34. data/spec/elasticsearch/transport/client_spec.rb +1651 -0
  35. data/spec/elasticsearch/transport/meta_header_spec.rb +274 -0
  36. data/spec/elasticsearch/transport/sniffer_spec.rb +275 -0
  37. data/spec/spec_helper.rb +90 -0
  38. data/test/integration/transport_test.rb +98 -0
  39. data/test/profile/client_benchmark_test.rb +132 -0
  40. data/test/test_helper.rb +83 -0
  41. data/test/unit/connection_test.rb +135 -0
  42. data/test/unit/response_test.rb +30 -0
  43. data/test/unit/serializer_test.rb +33 -0
  44. data/test/unit/transport_base_test.rb +664 -0
  45. data/test/unit/transport_curb_test.rb +135 -0
  46. data/test/unit/transport_faraday_test.rb +228 -0
  47. data/test/unit/transport_manticore_test.rb +251 -0
  48. metadata +412 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a5f7efa80056792b4d863e1011b652c677df5083db1d328a336e4951e5f66bbb
4
+ data.tar.gz: ade02810dfcc55b6f48f769019851d51f30018c3dc9b7eb2f95d380e91d9a2aa
5
+ SHA512:
6
+ metadata.gz: 964cfda300084d06334b4876a0a8f9e50f1f2242e34abc9708b2c771c39ea86846e068d1d9b3fd730ea92ba405d1f2b01cc2856d0ce8c6af65e6b4beb55bd90c
7
+ data.tar.gz: c1f4b6b9f53bd72d272a041fb2578ff893cf6ddf91bcd3ec52a8c2b5ecdd4929f640fab783bce65ad4458f8914628bf8839476b9dfa846bd9e024125cd21d6a7
@@ -0,0 +1,33 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ LICENSE = File.read('./.github/license-header.txt')
19
+ files = `git ls-files | grep -E '\.rb|Rakefile|\.rake|\.erb|Gemfile|gemspec'`.split("\n")
20
+ errors = []
21
+
22
+ files.each do |file|
23
+ unless File.read(file).include?(LICENSE)
24
+ errors << file
25
+ puts "#{file} doesn't contain the correct license header"
26
+ end
27
+ end
28
+
29
+ if errors.empty?
30
+ puts 'All checked files have the correct license header'
31
+ else
32
+ exit 1
33
+ end
@@ -0,0 +1,16 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
@@ -0,0 +1,13 @@
1
+ name: License headers
2
+ on: [pull_request]
3
+ jobs:
4
+ build:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v2
8
+ - uses: ruby/setup-ruby@v1
9
+ with:
10
+ ruby-version: 3
11
+ - name: Check license headers
12
+ run: |
13
+ ruby ./.github/check_license_headers.rb
@@ -0,0 +1,45 @@
1
+ name: main tests
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ branches:
8
+ - main
9
+ jobs:
10
+ test-ruby:
11
+ env:
12
+ TEST_ES_SERVER: http://localhost:9250
13
+ PORT: 9250
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby: [ 2.5, 2.6, 2.7, 3.0, jruby-9.2 ]
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - name: Increase system limits
22
+ run: |
23
+ sudo swapoff -a
24
+ sudo sysctl -w vm.swappiness=1
25
+ sudo sysctl -w fs.file-max=262144
26
+ sudo sysctl -w vm.max_map_count=262144
27
+ - uses: elastic/elastic-github-actions/elasticsearch@master
28
+ with:
29
+ stack-version: 8.0.0-SNAPSHOT
30
+ - uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby }}
33
+ - name: Build and test with Rake
34
+ run: |
35
+ sudo apt-get update
36
+ sudo apt-get install libcurl4-openssl-dev
37
+ ruby -v
38
+ bundle install
39
+ - name: unit tests
40
+ run: bundle exec rake test:unit
41
+ - name: specs
42
+ run: bundle exec rake test:spec
43
+ - name: integration tests
44
+ run: bundle exec rake test:integration
45
+
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ *.log
4
+ .byebug_history
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/CHANGELOG.md ADDED
@@ -0,0 +1,224 @@
1
+ ## 8.0.0
2
+
3
+ - Library renamed from [`elasticsearch-transport`](https://github.com/elastic/elasticsearch-ruby/tree/7.x/elasticsearch-transport) to `elastic-transport` and promoted to its own repository.
4
+
5
+ # Changes from elasticsearch-transport:
6
+
7
+ ## 7.14
8
+
9
+ - Fixes for Manticore Implementation: Addresses custom headers on initialization (https://github.com/elastic/elasticsearch-ruby/commit/3732dd4f6de75365460fa99c1cd89668b107ef1c) and fixes tracing (https://github.com/elastic/elasticsearch-ruby/commit/3c48ebd9a783988d1f71bfb9940459832ccd63e4). Related to #1426 and #1428.
10
+
11
+ ## 7.13
12
+
13
+ - Fixes thread safety issue in `get_connection` - [Pull Request](https://github.com/elastic/elasticsearch-ruby/pull/1325).
14
+
15
+ ## 7.12
16
+
17
+ - Ruby 3 is now tested, it was added to the entire test suite.
18
+
19
+ ## 7.11
20
+
21
+ - Fixes a bug with headers in our default Faraday class. [Commit](https://github.com/elastic/elasticsearch-ruby/commit/9c4afc452467cc6344359b54b98bbe5af1469219).
22
+
23
+ ## 7.10
24
+
25
+ - Use 443 for default cloud port, 9200 as the default port for http
26
+ - Fixes a bug when building the complete endpoint URL could end with duplicate slashes `//`.
27
+ - Fixes a bug when building the complete endpoint URL with cloud id could end with duplicate ports [#1081](https://github.com/elastic/elasticsearch-ruby/issues/1081).
28
+
29
+ ## 7.9
30
+ - Transport/Connection: Considers attributes values for equality - [Commit](https://github.com/elastic/elasticsearch-ruby/commit/06ffd03bf51f5f33a0d87e9914e66b39357d40af).
31
+ - When an API endpoint accepts both `GET` and `POST`, the client will always use `POST` when a request body is present.
32
+
33
+ ## 7.8
34
+ - Surface deprecation headers from Elasticsearch. When there's a `warning` response header in Elasticsearch's response, the client will emit a warning with `warn`.
35
+ - Typhoeus is supported again, version 1.4+ and has been added back to the docs.
36
+ - Adds documentation and example for integrating with Elastic APM.
37
+
38
+ ## 7.7
39
+
40
+ - Drops support for Ruby 2.4 since it's reached it's end of life.
41
+
42
+ ## 7.6
43
+
44
+ ### Faraday migrated to 1.0
45
+
46
+ We're now using version 1.0 of Faraday:
47
+ - The client initializer was modified but this should not disrupt final users at all, check [this commit](https://github.com/elastic/elasticsearch-ruby/commit/0fdc6533f4621a549a4cb99e778bbd827461a2d0) for more information.
48
+ - Migrated error checking to remove the deprecated `Faraday::Error` namespace.
49
+ - **This change is not compatible with [Typhoeus](https://github.com/typhoeus/typhoeus)**. The latest release is 1.3.1, but it's [still using the deprecated `Faraday::Error` namespace](https://github.com/typhoeus/typhoeus/blob/v1.3.1/lib/typhoeus/adapters/faraday.rb#L100). This has been fixed on master, but the last release was November 6, 2018. Version 1.4.0 should be ok once it's released.
50
+ - Note: Faraday 1.0 drops official support for JRuby. It installs fine on the tests we run with JRuby in this repo, but it's something we should pay attention to.
51
+
52
+ Reference: [Upgrading - Faraday 1.0](https://github.com/lostisland/faraday/blob/master/UPGRADING.md)
53
+
54
+ [Pull Request](https://github.com/elastic/elasticsearch-ruby/pull/808)
55
+
56
+ ## 7.4
57
+
58
+ - Accept options passed to #perform_request to avoid infinite retry loop
59
+
60
+ ## 7.3
61
+
62
+ - Add note to readme about the default port value
63
+ - Add note about exception to default port rule when connecting using Elastic Cloud ID
64
+ - Cluster name is variable in cloud id
65
+
66
+ ## 7.2
67
+
68
+ - Support User-Agent header client team specification
69
+ - Improve code handling headers
70
+ - Handle headers when using JRuby and Manticore
71
+ - Rename method for clarity
72
+ - Test selecting connections using multiple threads
73
+ - Synchronize access to the connections collection and mutation of @current instance variable
74
+ - Fix specs for selecting a connection
75
+ - Further fixes to specs for testing selecting connections in parallel
76
+ - Support providing a cloud id
77
+ - Allow a port to be set with a Cloud id and use default if no port is provided
78
+ - Remove unnecessary check for cloud_id when setting default port
79
+ - Add documentation for creating client with cloud_id
80
+ - Allow compression with Faraday and supported http adapters
81
+ - Put development gem dependencies in gemspec
82
+ - No reason to use ! for decompress method name
83
+ - Check for the existence of headers before checking headers
84
+ - Apply compression headers manually based on general :compression option
85
+ - Use GZIP constant
86
+ - Group tests into their transport adapters
87
+ - Support compression when using Curb adapter
88
+ - Support compression when using Manticore adapter with JRuby
89
+ - Fix Curb unit test, expecting headers to be merged and not set
90
+ - Update test descriptions for compression settings
91
+ - Add documentation of 'compression' option on client
92
+ - Improve client documentation for compression option
93
+ - Centralize header handling into one method
94
+ - Only add Accept-Encoding header if compression option is true
95
+
96
+ ## 7.1
97
+
98
+ - Use default port when host and protocol are specified but no port
99
+ - Verify that we have a response object before checking its status
100
+ - Make code more succinct for supporting host with path and no port
101
+ - Support options specified with String keys
102
+ - Update elasticsearch-transport/lib/elasticsearch/transport/client.rb
103
+ - Add tests showing IPv6 host specified when creating client
104
+
105
+ ## 7.0
106
+
107
+ - Fixed failing integration test
108
+ - Updated the Manticore development dependency
109
+ - Fixed a failing Manticore unit test
110
+ - Removed "turn" and switched the tests to Minitest
111
+ - Fixed integration tests for Patron
112
+ - Allow passing request headers in `perform_request`
113
+ - Added integration test for passing request headers in `perform_request`
114
+ - Added, that request headers are printed in trace output, if set
115
+ - Fix typos in elasticsearch-transport/README.md
116
+ - Assert that connection count is at least previous count when reloaded
117
+ - Adjust test for change in default number of shards on ES 7
118
+ - Abstract logging functionality into a Loggable Module (#556)
119
+ - Convert client integration tests to rspec
120
+ - Add flexible configuration in spec helper
121
+ - Use helper methods in spec_helper
122
+ - Remove minitest client integration tests in favor of rspec test
123
+ - Convert tests to rspec and refactor client
124
+ - minor changes to the client specs
125
+ - Use pry-nav in development for JRuby
126
+ - Keep arguments variable name for now
127
+ - Skip round-robin test for now
128
+ - Mark test as pending until there is a better way to detect rotating nodes
129
+ - Remove client unit test in favor of rspec test
130
+ - Comment-out round-robin test as it occasionally passes and pending is ineffective
131
+ - Document the default host and port constant
132
+ - Add documentation to spec_helper methods
133
+ - Redacted password if host info is printed in error message
134
+ - Adds tests for not including password in logged error message
135
+ - The redacted string change will be in 6.1.1
136
+ - Add more tests for different ways to specify client host argument
137
+ - Do not duplicate connections in connection pool after rebuild (#591)
138
+ - Ensure that the spec rake task is run as part of integration tests
139
+ - Use constant to define Elasticsearch hosts and avoid yellow status when number of nodes is 1
140
+ - Update handling of publish_address in _nodes/http response
141
+ - Add another test for hostname/ipv6:port format
142
+
143
+ ## 6.x
144
+
145
+ * Added default value 'application/json' for the 'Content-Type' header
146
+ * Added escaping of username and password in URL
147
+ * Added proper handling of headers in client options to the Manticore adapter
148
+ * Don't block waiting for body on HEAD requests
149
+ * Fixed double logging of failed responses
150
+ * Fixed incorrect test behaviour when the `QUIET` environment variable is set
151
+ * Fixed the bug with `nil` value of `retry_on_status`
152
+ * Fixed the incorrect paths and Typhoeus configuration in the benchmark tests
153
+ * Fixed the integration tests for client
154
+ * Fixed typo in default port handling during `__build_connections`
155
+ * Swallow logging of exceptions when the `ignore` is specified
156
+
157
+ ## 5.x
158
+
159
+ * Added escaping of username and password in URL
160
+ * Don't block waiting for body on HEAD requests
161
+ * Fixed incorrect test behaviour when the `QUIET` environment variable is set
162
+ * Fixed double logging of failed responses
163
+ * Swallow logging of exceptions when the `ignore` is specified
164
+ * Fixed the bug with `nil` value of `retry_on_status`
165
+ * Added proper handling of headers in client options to the Manticore adapter
166
+ * Added default value 'application/json' for the 'Content-Type' header
167
+
168
+ ## 2.x
169
+ * Fixed the bug with `nil` value of `retry_on_status`
170
+
171
+ ## 1.x
172
+
173
+ * Fixed MRI 2.4 compatibility for 1.x
174
+ * Fixed failing integration test for keeping existing collections
175
+ * Fixed, that the clients tries to deserialize an empty body
176
+ * Fixed, that dead connections have not been removed during reloading, leading to leaks
177
+ * Fixed, that existing connections are not re-initialized during reloading ("sniffing")
178
+ * Added, that username and password is automatically escaped in the URL
179
+ * Changed, that the password is replaced with `*` characters in the log
180
+ * Bumped the "manticore" gem dependency to 0.5
181
+ * Improved the thread-safety of reloading connections
182
+ * Improved the Manticore HTTP client
183
+ * Fixed, that connections are reloaded _before_ getting a connection
184
+ * Added a better interface for configuring global HTTP settings such as protocol or authentication
185
+ * Added the option to configure the Faraday adapter using a block and the relevant documentation
186
+ * Added information about configuring the client for the Amazon Elasticsearch Service
187
+ * Added the `retry_on_status` option to retry on specific HTTP response statuses
188
+ * Changed, that transports can close connections during `__rebuild_connections`
189
+ * Added, that the Manticore adapter closes connections during reload ("sniffing")
190
+ * Added an argument to control clearing out the testing cluster
191
+ * Fixed, that reloading connections works with SSL, authentication and proxy/Shield
192
+ * Highlight the need to set `retry_on_failure` option with multiple hosts in documentation
193
+ * Added, that connection reloading supports Elasticsearch 2.0 output
194
+ * Improved thread safety in parts of connection handling code
195
+ * Cleaned up handling the `reload_connections` option for transport
196
+ * Be more defensive when logging exception
197
+ * Added, that the Manticore transport respects the `transport_options` argument
198
+ * Added a top level `request_timeout` argument
199
+ * Changed the argument compatibility check in `__extract_hosts()` from `respond_to?` to `is_a?`
200
+ * Document the DEFAULT_MAX_RETRIES value for `retry_on_failure`
201
+ * Leave only Typhoeus as the primary example of automatically detected & used HTTP library in README
202
+ * Make sure the `connections` object is an instance of Collection
203
+ * Prevent mutating the parameter passed to __extract_hosts() method
204
+ * Removed the `ipv4` resolve mode setting in the Curb adapter
205
+ * Update Manticore to utilize new SSL settings
206
+ * Updated the Curb integration test to not fail on older Elasticsearch versions
207
+ * Fixed, that the Curb transport passes the `selector_class` option
208
+ * Added handling the `::Curl::Err::TimeoutError` exception for Curb transport
209
+ * Reworded information about authentication and added example for using SSL certificates
210
+ * Added information about the `ELASTICSEARCH_URL` environment variable to the README
211
+ * Allow passing multiple URLs separated by a comma to the client
212
+ * Fixed an error where passing `host: { ... }` resulted in error in Client#__extract_hosts
213
+ * Added Manticore transport for JRuby platforms
214
+ * Fixed, that `ServerError` inherits from `Transport::Error`
215
+ * Fix problems with gems on JRuby
216
+ * Added the `send_get_body_as` setting
217
+ * Added support for automatically connecting to cluster set in the ELASTICSEARCH_URL environment variable
218
+ * Improved documentation
219
+ * Updated the parameters list for APIs (percolate, put index)
220
+ * Updated the "Indices Stats" API
221
+ * Improved the `__extract_parts` utility method
222
+ * Added, that error requests are properly logged and traced
223
+ * Fixed an error where exception was raised too late for error responses
224
+ * Added auto-detection for Faraday adapter from loaded Rubygems
data/Gemfile ADDED
@@ -0,0 +1,38 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ source 'https://rubygems.org'
19
+
20
+ # Specify your gem's dependencies in elasticsearch-transport.gemspec
21
+ gemspec
22
+
23
+ if File.exist? File.expand_path('../elasticsearch-api/elasticsearch-api.gemspec', __dir__)
24
+ gem 'elasticsearch-api', path: File.expand_path('../elasticsearch-api', __dir__), require: false
25
+ end
26
+
27
+ if File.exist? File.expand_path('../elasticsearch/elasticsearch.gemspec', __dir__)
28
+ gem 'elasticsearch', path: File.expand_path('../elasticsearch', __dir__), require: false
29
+ end
30
+
31
+ group :development, :test do
32
+ gem 'rspec'
33
+ if defined?(JRUBY_VERSION)
34
+ gem 'pry-nav'
35
+ else
36
+ gem 'pry-byebug'
37
+ end
38
+ end
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.