diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 7b6906c0..00000000 --- a/.editorconfig +++ /dev/null @@ -1,18 +0,0 @@ -# EditorConfig is awesome: https://EditorConfig.org - -# top-most EditorConfig file -root = true - -[*] -indent_style = tab -indent_size = 4 -end_of_line = lf -insert_final_newline = true - -[*.yml] -indent_style = space -indent_size = 2 - -[*.yaml] -indent_style = space -indent_size = 2 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index eb9a16ae..00000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,45 +0,0 @@ - -# Contributing - -Spring Cloud is released under the non-restrictive Apache 2.0 license, -and follows a very standard Github development process, using Github -tracker for issues and merging pull requests into master. If you want -to contribute even something trivial please do not hesitate, but -follow the guidelines below. - -## Sign the Contributor License Agreement -Before we accept a non-trivial patch or pull request we will need you to sign the -[Contributor License Agreement](https://cla.pivotal.io/sign/spring). -Signing the contributor's agreement does not grant anyone commit rights to the main -repository, but it does mean that we can accept your contributions, and you will get an -author credit if we do. Active contributors might be asked to join the core team, and -given the ability to merge pull requests. - -## Code of Conduct -This project adheres to the Contributor Covenant [code of -conduct](https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc). By participating, you are expected to uphold this code. Please report -unacceptable behavior to spring-code-of-conduct@pivotal.io. - -## Code Conventions and Housekeeping -None of these is essential for a pull request, but they will all help. They can also be -added after the original pull request but before a merge. - -* Use the Spring Framework code format conventions. If you use Eclipse - you can import formatter settings using the - `eclipse-code-formatter.xml` file from the - [Spring Cloud Build](https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml) project. If using IntelliJ, you can use the - [Eclipse Code Formatter Plugin](https://plugins.jetbrains.com/plugin/6546) to import the same file. -* Make sure all new `.java` files to have a simple Javadoc class comment with at least an - `@author` tag identifying you, and preferably at least a paragraph on what the class is - for. -* Add the ASF license header comment to all new `.java` files (copy from existing files - in the project) -* Add yourself as an `@author` to the .java files that you modify substantially (more - than cosmetic changes). -* Add some Javadocs and, if you change the namespace, some XSD doc elements. -* A few unit tests would help a lot as well -- someone has to do it. -* If no-one else is using your branch, please rebase it against the current master (or - other target branch in the main project). -* When writing a commit message please follow [these conventions](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), - if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit - message (where XXXX is the issue number). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 0bc5ef4f..00000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index aeafef9d..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -Please provide details of the problem, including the version of Spring Cloud that you -are using. - -**Sample** -If possible, please provide a test case or sample application that reproduces -the problem. This makes it much easier for us to diagnose the problem and to verify that -we have fixed it. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7d..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 00000000..c54f6cea --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,53 @@ +name: Deploy Docs +run-name: ${{ format('{0} ({1})', github.workflow, github.event.inputs.build-refname || 'all') }} +on: + workflow_dispatch: + inputs: + build-refname: + description: Enter git refname to build (e.g., 5.7.x). + required: false + push: + branches: docs-build +env: + GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} +permissions: + contents: write +jobs: + build: + if: github.repository_owner == 'spring-cloud' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 5 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Set up refname build + if: github.event.inputs.build-refname + run: | + git fetch --depth 1 https://github.com/$GITHUB_REPOSITORY ${{ github.event.inputs.build-refname }} + export BUILD_REFNAME=${{ github.event.inputs.build-refname }} + echo "BUILD_REFNAME=$BUILD_REFNAME" >> $GITHUB_ENV + export BUILD_VERSION=$(git cat-file --textconv FETCH_HEAD:pom.xml | python3 -c "import xml.etree.ElementTree as xml; from sys import stdin; print(xml.parse(stdin).getroot().find('{http://maven.apache.org/POM/4.0.0}version').text)") + echo BUILD_VERSION=$BUILD_VERSION >> $GITHUB_ENV + - name: Run Antora + run: | + ./mvnw --no-transfer-progress -B antora + - name: Publish Docs + uses: spring-io/spring-doc-actions/rsync-antora-reference@v0.0.11 + with: + docs-username: ${{ secrets.DOCS_USERNAME }} + docs-host: ${{ secrets.DOCS_HOST }} + docs-ssh-key: ${{ secrets.DOCS_SSH_KEY }} + docs-ssh-host-key: ${{ secrets.DOCS_SSH_HOST_KEY }} + site-path: target/antora/site + - name: Bust Cloudflare Cache + uses: spring-io/spring-doc-actions/bust-cloudflare-antora-cache@v0.0.11 + with: + context-root: spring-cloud-consul + cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }} + cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index 98bf13c3..00000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This workflow will build a Java project with Maven -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: Build - -on: - push: - branches: [ main, 3.1.x ] - pull_request: - branches: [ main, 3.1.x ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - java-version: '17' - - name: Cache local Maven repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Build with Maven - run: ./mvnw clean install -B -U -Pspring -Dmaven.test.redirectTestOutputToFile=true - - name: Publish Test Report - uses: mikepenz/action-junit-report@v2 - if: always() # always run even if the previous step fails - with: - report_paths: '**/surefire-reports/TEST-*.xml' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7acf4f8a..6be8a4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,22 @@ -*~ -#* -*# -.#* -.classpath -.project -.settings/ -.springBeans target/ -_site/ -.idea +.settings/ +.project +.classpath +*.orig +.springBeans +.factorypath +.sts4-cache +.ant-targets-build.xml +src/ant/.ant-targets-upload-dist.xml +*.sonar4clipse* +.DS_Store *.iml *.ipr -.factorypath -*.swp -/consul -consul_*.zip -consul_*.zip.* -.vscode/ -.flattened-pom.xml +*.iws +/.idea/ +*.graphml +node +node_modules +build +package.json +package-lock.json diff --git a/.mvn/maven.config b/.mvn/maven.config deleted file mode 100644 index 3b8cf46e..00000000 --- a/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java old mode 100755 new mode 100644 index 1f38b9c8..b901097f --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -1,117 +1,117 @@ - /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; import java.util.Properties; public class MavenWrapperDownloader { - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is - * provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl - * property to use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar"; + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; - /** - * Name of the property which should be used to override the default download url for - * the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - // If the maven-wrapper.properties exists, read it and check if it contains a - // custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, - MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if (mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream( - mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } - catch (IOException e) { - System.out.println( - "- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } - finally { - try { - if (mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } - catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: : " + url); + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); - File outputFile = new File(baseDirectory.getAbsolutePath(), - MAVEN_WRAPPER_JAR_PATH); - if (!outputFile.getParentFile().exists()) { - if (!outputFile.getParentFile().mkdirs()) { - System.out.println("- ERROR creating output direcrory '" - + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } - catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } - private static void downloadFileFromURL(String urlString, File destination) - throws Exception { - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } } diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar old mode 100755 new mode 100644 index 01e67997..2cc7d4a5 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties old mode 100755 new mode 100644 index 00d32aab..642d572c --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,2 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip \ No newline at end of file +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/.sdkmanrc b/.sdkmanrc deleted file mode 100644 index 415f9083..00000000 --- a/.sdkmanrc +++ /dev/null @@ -1,3 +0,0 @@ -# Enable auto-env through the sdkman_auto_env config -# Add key=value pairs of SDKs to use below -java=17.0.1-tem diff --git a/.settings.xml b/.settings.xml deleted file mode 100644 index 171351c0..00000000 --- a/.settings.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - spring - - true - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - diff --git a/.springformat b/.springformat deleted file mode 100644 index e69de29b..00000000 diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 62589edd..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.adoc b/README.adoc index 2b22b5f3..9de81ff4 100644 --- a/README.adoc +++ b/README.adoc @@ -1,596 +1,23 @@ -//// -DO NOT EDIT THIS FILE. IT WAS GENERATED. -Manual changes to this file will be lost when it is generated again. -Edit the files in the src/main/asciidoc/ directory instead. -//// += Spring Cloud Consul Docs Build +You're currently viewing the Antora playbook branch. +The playbook branch hosts the docs build that is used to build and publish the production docs site. -image::https://circleci.com/gh/spring-cloud/spring-cloud-consul/tree/master.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-consul/tree/master"] -image::https://codecov.io/gh/spring-cloud/spring-cloud-consul/branch/master/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-consul/branch/master"] +The Spring Cloud Consul reference docs are built using https://antora.org[Antora]. +This README covers how to build the docs in a software branch as well as how to build the production docs site locally. -This project provides Consul integrations for Spring Boot apps through autoconfiguration -and binding to the Spring Environment and other Spring programming model idioms. With a few -simple annotations you can quickly enable and configure the common patterns inside your -application and build large distributed systems with Consul based components. The -patterns provided include Service Discovery, Control Bus and Configuration. -Intelligent Routing and Client Side Load Balancing, Circuit Breaker -are provided by integration with other Spring Cloud projects. +== Building the Site +You can build the entire site by invoking the following on the docs-build branch and then viewing the site at `target/site/index.html` -== Quick Start - -This quick start walks through using Spring Cloud Consul for Service Discovery and Distributed Configuration. - -First, run Consul Agent on your machine. Then you can access it and use it as a Service Registry and Configuration source with Spring Cloud Consul. - -=== Discovery Client Usage - -To use these features in an application, you can build it as a Spring Boot application that depends on `spring-cloud-consul-core`. -The most convenient way to add the dependency is with a Spring Boot starter: `org.springframework.cloud:spring-cloud-starter-consul-discovery`. -We recommend using dependency management and `spring-boot-starter-parent`. -The following example shows a typical Maven configuration: - -[source,xml,indent=0] -.pom.xml +[source,bash] ---- - - - org.springframework.boot - spring-boot-starter-parent - {spring-boot-version} - - - - - - org.springframework.cloud - spring-cloud-starter-consul-discovery - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - +./mvnw antora ---- -The following example shows a typical Gradle setup: +== Building a Specific Branch -[source,groovy,indent=0] -.build.gradle +[source,bash] ---- -plugins { - id 'org.springframework.boot' version ${spring-boot-version} - id 'io.spring.dependency-management' version ${spring-dependency-management-version} - id 'java' -} - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery' - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } -} +./mvnw antora ---- - -Now you can create a standard Spring Boot application, such as the following HTTP server: - ----- -@SpringBootApplication -@RestController -public class Application { - - @GetMapping("/") - public String home() { - return "Hello World!"; - } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} ----- - -When this HTTP server runs, it connects to Consul Agent running at the default local 8500 port. -To modify the startup behavior, you can change the location of Consul Agent by using `application.properties`, as shown in the following example: - ----- -spring: - cloud: - consul: - host: localhost - port: 8500 ----- - -You can now use `DiscoveryClient`, `@LoadBalanced RestTemplate`, or `@LoadBalanced WebClient.Builder` to retrieve services and instances data from Consul, as shown in the following example: - -[source,java,indent=0] ----- -@Autowired -private DiscoveryClient discoveryClient; - -public String serviceUrl() { - List list = discoveryClient.getInstances("STORES"); - if (list != null && list.size() > 0 ) { - return list.get(0).getUri().toString(); - } - return null; -} ----- - -=== Distributed Configuration Usage - -To use these features in an application, you can build it as a Spring Boot application that depends on `spring-cloud-consul-core` and `spring-cloud-consul-config`. -The most convenient way to add the dependency is with a Spring Boot starter: `org.springframework.cloud:spring-cloud-starter-consul-config`. -We recommend using dependency management and `spring-boot-starter-parent`. -The following example shows a typical Maven configuration: - -[source,xml,indent=0] -.pom.xml ----- - - - org.springframework.boot - spring-boot-starter-parent - {spring-boot-version} - - - - - - org.springframework.cloud - spring-cloud-starter-consul-config - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - ----- - -The following example shows a typical Gradle setup: - -[source,groovy,indent=0] -.build.gradle ----- -plugins { - id 'org.springframework.boot' version ${spring-boot-version} - id 'io.spring.dependency-management' version ${spring-dependency-management-version} - id 'java' -} - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.springframework.cloud:spring-cloud-starter-consul-config' - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } -} ----- - -Now you can create a standard Spring Boot application, such as the following HTTP server: - ----- -@SpringBootApplication -@RestController -public class Application { - - @GetMapping("/") - public String home() { - return "Hello World!"; - } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} ----- - -The application retrieves configuration data from Consul. - -WARNING: If you use Spring Cloud Consul Config, you need to set the `spring.config.import` property in order to bind to Consul. -You can read more about it in the <>. - -== Consul overview - -Features of Consul - -* Distributed configuration -* Service registration and discovery -* Distributed events -* Distributed locking and sessions -* Supports multiple data centers -* Built in, user-friendly user interface - -See the https://consul.io/intro/index.html[intro] for more information. - -== Spring Cloud Consul Features - -* Spring Cloud `DiscoveryClient` implementation -** supports Spring Cloud Gateway -** supports Spring Cloud LoadBalancer -* Consul based `PropertySource` loaded during the 'bootstrap' phase. -* Spring Cloud Bus implementation based on Consul https://www.consul.io/docs/agent/http/event.html[events] - -== Running the sample - -1. Run `docker-compose up` -2. Verify consul is running by visiting http://localhost:8500 -3. Run `mvn package` this will bring in the required spring cloud maven repositories and build -4. Run `java -jar spring-cloud-consul-sample/target/spring-cloud-consul-sample-${VERSION}.jar` -5. visit http://localhost:8080, verify that `{"serviceId":":8080","host":"","port":8080}` results -6. run `java -jar spring-cloud-consul-sample/target/spring-cloud-consul-sample-${VERSION}.jar --server.port=8081` -7. visit http://localhost:8080 again, verify that `{"serviceId":":8081","host":"","port":8081}` eventually shows up in the results in a round robbin fashion (may take a minute or so). - -== Building - - -:jdkversion: 17 - -=== Basic Compile and Test - -To build the source you will need to install JDK {jdkversion}. - -Spring Cloud uses Maven for most build-related activities, and you -should be able to get off the ground quite quickly by cloning the -project you are interested in and typing - ----- -$ ./mvnw install ----- - -NOTE: You can also install Maven (>=3.3.3) yourself and run the `mvn` command -in place of `./mvnw` in the examples below. If you do that you also -might need to add `-P spring` if your local Maven settings do not -contain repository declarations for spring pre-release artifacts. - -NOTE: Be aware that you might need to increase the amount of memory -available to Maven by setting a `MAVEN_OPTS` environment variable with -a value like `-Xmx512m -XX:MaxPermSize=128m`. We try to cover this in -the `.mvn` configuration, so if you find you have to do it to make a -build succeed, please raise a ticket to get the settings added to -source control. - -The projects that require middleware (i.e. Redis) for testing generally -require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running. - - -=== Documentation - -The spring-cloud-build module has a "docs" profile, and if you switch -that on it will try to build asciidoc sources from -`src/main/asciidoc`. As part of that process it will look for a -`README.adoc` and process it by loading all the includes, but not -parsing or rendering it, just copying it to `${main.basedir}` -(defaults to `${basedir}`, i.e. the root of the project). If there are -any changes in the README it will then show up after a Maven build as -a modified file in the correct place. Just commit it and push the change. - -=== Working with the code -If you don't have an IDE preference we would recommend that you use -https://www.springsource.com/developer/sts[Spring Tools Suite] or -https://eclipse.org[Eclipse] when working with the code. We use the -https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools -should also work without issue as long as they use Maven 3.3.3 or better. - -==== Activate the Spring Maven profile -Spring Cloud projects require the 'spring' Maven profile to be activated to resolve -the spring milestone and snapshot repositories. Use your preferred IDE to set this -profile to be active, or you may experience build errors. - -==== Importing into eclipse with m2eclipse -We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with -eclipse. If you don't already have m2eclipse installed it is available from the "eclipse -marketplace". - -NOTE: Older versions of m2e do not support Maven 3.3, so once the -projects are imported into Eclipse you will also need to tell -m2eclipse to use the right profile for the projects. If you -see many different errors related to the POMs in the projects, check -that you have an up to date installation. If you can't upgrade m2e, -add the "spring" profile to your `settings.xml`. Alternatively you can -copy the repository settings from the "spring" profile of the parent -pom into your `settings.xml`. - -==== Importing into eclipse without m2eclipse -If you prefer not to use m2eclipse you can generate eclipse project metadata using the -following command: - -[indent=0] ----- - $ ./mvnw eclipse:eclipse ----- - -The generated eclipse projects can be imported by selecting `import existing projects` -from the `file` menu. - - - -== Contributing - -:spring-cloud-build-branch: master - -Spring Cloud is released under the non-restrictive Apache 2.0 license, -and follows a very standard Github development process, using Github -tracker for issues and merging pull requests into master. If you want -to contribute even something trivial please do not hesitate, but -follow the guidelines below. - -=== Sign the Contributor License Agreement -Before we accept a non-trivial patch or pull request we will need you to sign the -https://cla.pivotal.io/sign/spring[Contributor License Agreement]. -Signing the contributor's agreement does not grant anyone commit rights to the main -repository, but it does mean that we can accept your contributions, and you will get an -author credit if we do. Active contributors might be asked to join the core team, and -given the ability to merge pull requests. - -=== Code of Conduct -This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of -conduct]. By participating, you are expected to uphold this code. Please report -unacceptable behavior to spring-code-of-conduct@pivotal.io. - -=== Code Conventions and Housekeeping -None of these is essential for a pull request, but they will all help. They can also be -added after the original pull request but before a merge. - -* Use the Spring Framework code format conventions. If you use Eclipse - you can import formatter settings using the - `eclipse-code-formatter.xml` file from the - https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring - Cloud Build] project. If using IntelliJ, you can use the - https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter - Plugin] to import the same file. -* Make sure all new `.java` files to have a simple Javadoc class comment with at least an - `@author` tag identifying you, and preferably at least a paragraph on what the class is - for. -* Add the ASF license header comment to all new `.java` files (copy from existing files - in the project) -* Add yourself as an `@author` to the .java files that you modify substantially (more - than cosmetic changes). -* Add some Javadocs and, if you change the namespace, some XSD doc elements. -* A few unit tests would help a lot as well -- someone has to do it. -* If no-one else is using your branch, please rebase it against the current master (or - other target branch in the main project). -* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions], - if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit - message (where XXXX is the issue number). - -=== Checkstyle - -Spring Cloud Build comes with a set of checkstyle rules. You can find them in the `spring-cloud-build-tools` module. The most notable files under the module are: - -.spring-cloud-build-tools/ ----- -└── src -    ├── checkstyle -    │   └── checkstyle-suppressions.xml <3> -    └── main -    └── resources -    ├── checkstyle-header.txt <2> -    └── checkstyle.xml <1> ----- -<1> Default Checkstyle rules -<2> File header setup -<3> Default suppression rules - -==== Checkstyle configuration - -Checkstyle rules are *disabled by default*. To add checkstyle to your project just define the following properties and plugins. - -.pom.xml ----- - -true <1> - true - <2> - true - <3> - - - - - <4> - io.spring.javaformat - spring-javaformat-maven-plugin - - <5> - org.apache.maven.plugins - maven-checkstyle-plugin - - - - - - <5> - org.apache.maven.plugins - maven-checkstyle-plugin - - - - ----- -<1> Fails the build upon Checkstyle errors -<2> Fails the build upon Checkstyle violations -<3> Checkstyle analyzes also the test sources -<4> Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules -<5> Add checkstyle plugin to your build and reporting phases - -If you need to suppress some rules (e.g. line length needs to be longer), then it's enough for you to define a file under `${project.root}/src/checkstyle/checkstyle-suppressions.xml` with your suppressions. Example: - -.projectRoot/src/checkstyle/checkstyle-suppresions.xml ----- - - - - - - ----- - -It's advisable to copy the `${spring-cloud-build.rootFolder}/.editorconfig` and `${spring-cloud-build.rootFolder}/.springformat` to your project. That way, some default formatting rules will be applied. You can do so by running this script: - -```bash -$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig -$ touch .springformat -``` - -=== IDE setup - -==== Intellij IDEA - -In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin. -The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project. - -.spring-cloud-build-tools/ ----- -└── src -    ├── checkstyle -    │   └── checkstyle-suppressions.xml <3> -    └── main -    └── resources -    ├── checkstyle-header.txt <2> -    ├── checkstyle.xml <1> -    └── intellij -       ├── Intellij_Project_Defaults.xml <4> -       └── Intellij_Spring_Boot_Java_Conventions.xml <5> ----- -<1> Default Checkstyle rules -<2> File header setup -<3> Default suppression rules -<4> Project defaults for Intellij that apply most of Checkstyle rules -<5> Project style conventions for Intellij that apply most of Checkstyle rules - -.Code style - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style] - -Go to `File` -> `Settings` -> `Editor` -> `Code style`. There click on the icon next to the `Scheme` section. There, click on the `Import Scheme` value and pick the `Intellij IDEA code style XML` option. Import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml` file. - -.Inspection profiles - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style] - -Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon next to the `Profile` section. There, click on the `Import Profile` and import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml` file. - -.Checkstyle - -To have Intellij work with Checkstyle, you have to install the `Checkstyle` plugin. It's advisable to also install the `Assertions2Assertj` to automatically convert the JUnit assertions - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle] - -Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables: - -- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL. -- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL. -- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`. - -IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. - -=== Duplicate Finder - -Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath. - -==== Duplicate Finder configuration - -Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`. - -.pom.xml -[source,xml] ----- - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - ----- - -For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation]. - -You can easily override them but setting the value of the selected property prefixed with `duplicate-finder-maven-plugin`. For example, set `duplicate-finder-maven-plugin.skip` to `true` in order to skip duplicates check in your build. - -If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project: - -[source,xml] ----- - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - org.joda.time.base.BaseDateTime - .*module-info - - - changelog.txt - - - - - - - ----- - diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 04685956..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security Policy - -## Reporting a Vulnerability - -To report security vulnerabilities, please go to https://pivotal.io/security. diff --git a/docs/antora-playbook.yml b/antora-playbook.yml similarity index 61% rename from docs/antora-playbook.yml rename to antora-playbook.yml index 9a70e676..d02ddbe0 100644 --- a/docs/antora-playbook.yml +++ b/antora-playbook.yml @@ -6,38 +6,39 @@ antora: - '@antora/collector-extension' - '@antora/atlas-extension' - require: '@springio/antora-extensions/root-component-extension' - root_component_name: 'PROJECT_WITHOUT_SPRING' - # FIXME: Run antora once using this extension to migrate to the Asciidoc Tabs syntax - # and then remove this extension - - require: '@springio/antora-extensions/tabs-migration-extension' - unwrap_example_block: always - save_result: true + root_component_name: 'cloud-consul' site: - title: PROJECT_FULL_NAME - url: https://docs.spring.io/PROJECT_NAME/reference/ + title: Spring Cloud Consul + url: https://docs.spring.io/spring-cloud-consul/reference + robots: allow +git: + ensure_git_suffix: false content: sources: - - url: ./.. - branches: HEAD + - url: https://github.com/spring-cloud/spring-cloud-consul + # Refname matching: + # https://docs.antora.org/antora/latest/playbook/content-refname-matching/ + branches: [ main ] + tags: [ '({4..9}).+({1..9}).+({0..9})?(-{RC,M}+({0..9}))', '!4.1.0-M1' ] start_path: docs - worktrees: true asciidoc: attributes: page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud page-pagination: '' hide-uri-scheme: '@' tabs-sync-option: '@' - chomp: 'all' extensions: - '@asciidoctor/tabs' - '@springio/asciidoctor-extensions' - sourcemap: true urls: + latest_version_segment_strategy: redirect:to latest_version_segment: '' + redirect_facility: httpd +ui: + bundle: + url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip + snapshot: true runtime: log: failure_level: warn format: pretty -ui: - bundle: - url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip diff --git a/asciidoctor.css b/asciidoctor.css deleted file mode 100644 index f592f50a..00000000 --- a/asciidoctor.css +++ /dev/null @@ -1,2011 +0,0 @@ -/* Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */ -/* Remove the comments around the @import statement below when using this as a custom stylesheet */ -/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic|Noto+Serif:400,400italic,700,700italic|Droid+Sans+Mono:400";*/ -article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { - display: block -} - -audio, canvas, video { - display: inline-block -} - -audio:not([controls]) { - display: none; - height: 0 -} - -[hidden], template { - display: none -} - -script { - display: none !important -} - -html { - font-family: sans-serif; - -ms-text-size-adjust: 100%; - -webkit-text-size-adjust: 100% -} - -body { - margin: 0 -} - -a { - background: transparent -} - -a:focus { - outline: thin dotted -} - -a:active, a:hover { - outline: 0 -} - -h1 { - font-size: 2em; - margin: .67em 0 -} - -abbr[title] { - border-bottom: 1px dotted -} - -b, strong { - font-weight: bold -} - -dfn { - font-style: italic -} - -hr { - -moz-box-sizing: content-box; - box-sizing: content-box; - height: 0 -} - -mark { - background: #ff0; - color: #000 -} - -code, kbd, pre, samp { - font-family: monospace; - font-size: 1em -} - -pre { - white-space: pre-wrap -} - -q { - quotes: "\201C" "\201D" "\2018" "\2019" -} - -small { - font-size: 80% -} - -sub, sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline -} - -sup { - top: -.5em -} - -sub { - bottom: -.25em -} - -img { - border: 0 -} - -svg:not(:root) { - overflow: hidden -} - -figure { - margin: 0 -} - -fieldset { - border: 1px solid silver; - margin: 0 2px; - padding: .35em .625em .75em -} - -legend { - border: 0; - padding: 0 -} - -button, input, select, textarea { - font-family: inherit; - font-size: 100%; - margin: 0 -} - -button, input { - line-height: normal -} - -button, select { - text-transform: none -} - -button, html input[type="button"], input[type="reset"], input[type="submit"] { - -webkit-appearance: button; - cursor: pointer -} - -button[disabled], html input[disabled] { - cursor: default -} - -input[type="checkbox"], input[type="radio"] { - box-sizing: border-box; - padding: 0 -} - -input[type="search"] { - -webkit-appearance: textfield; - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box -} - -input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none -} - -button::-moz-focus-inner, input::-moz-focus-inner { - border: 0; - padding: 0 -} - -textarea { - overflow: auto; - vertical-align: top -} - -table { - border-collapse: collapse; - border-spacing: 0 -} - -*, *:before, *:after { - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box -} - -html, body { - font-size: 100% -} - -body { - background: #fff; - color: rgba(0, 0, 0, .8); - padding: 0; - margin: 0; - font-family: "Noto Serif", "DejaVu Serif", serif; - font-weight: 400; - font-style: normal; - line-height: 1; - position: relative; - cursor: auto -} - -a:hover { - cursor: pointer -} - -img, object, embed { - max-width: 100%; - height: auto -} - -object, embed { - height: 100% -} - -img { - -ms-interpolation-mode: bicubic -} - -#map_canvas img, #map_canvas embed, #map_canvas object, .map_canvas img, .map_canvas embed, .map_canvas object { - max-width: none !important -} - -.left { - float: left !important -} - -.right { - float: right !important -} - -.text-left { - text-align: left !important -} - -.text-right { - text-align: right !important -} - -.text-center { - text-align: center !important -} - -.text-justify { - text-align: justify !important -} - -.hide { - display: none -} - -.antialiased, body { - -webkit-font-smoothing: antialiased -} - -img { - display: inline-block; - vertical-align: middle -} - -textarea { - height: auto; - min-height: 50px -} - -select { - width: 100% -} - -p.lead, .paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { - font-size: 1.21875em; - line-height: 1.6 -} - -.subheader, .admonitionblock td.content > .title, .audioblock > .title, .exampleblock > .title, .imageblock > .title, .listingblock > .title, .literalblock > .title, .stemblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, table.tableblock > .title, .verseblock > .title, .videoblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { - line-height: 1.45; - color: #7a2518; - font-weight: 400; - margin-top: 0; - margin-bottom: .25em -} - -div, dl, dt, dd, ul, ol, li, h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6, pre, form, p, blockquote, th, td { - margin: 0; - padding: 0; - direction: ltr -} - -a { - color: #2156a5; - text-decoration: underline; - line-height: inherit -} - -a:hover, a:focus { - color: #1d4b8f -} - -a img { - border: none -} - -p { - font-family: inherit; - font-weight: 400; - font-size: 1em; - line-height: 1.6; - margin-bottom: 1.25em; - text-rendering: optimizeLegibility -} - -p aside { - font-size: .875em; - line-height: 1.35; - font-style: italic -} - -h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { - font-family: "Open Sans", "DejaVu Sans", sans-serif; - font-weight: 300; - font-style: normal; - color: #ba3925; - text-rendering: optimizeLegibility; - margin-top: 1em; - margin-bottom: .5em; - line-height: 1.0125em -} - -h1 small, h2 small, h3 small, #toctitle small, .sidebarblock > .content > .title small, h4 small, h5 small, h6 small { - font-size: 60%; - color: #e99b8f; - line-height: 0 -} - -h1 { - font-size: 2.125em -} - -h2 { - font-size: 1.6875em -} - -h3, #toctitle, .sidebarblock > .content > .title { - font-size: 1.375em -} - -h4, h5 { - font-size: 1.125em -} - -h6 { - font-size: 1em -} - -hr { - border: solid #ddddd8; - border-width: 1px 0 0; - clear: both; - margin: 1.25em 0 1.1875em; - height: 0 -} - -em, i { - font-style: italic; - line-height: inherit -} - -strong, b { - font-weight: bold; - line-height: inherit -} - -small { - font-size: 60%; - line-height: inherit -} - -code { - font-family: "Droid Sans Mono", "DejaVu Sans Mono", monospace; - font-weight: 400; - color: rgba(0, 0, 0, .9) -} - -ul, ol, dl { - font-size: 1em; - line-height: 1.6; - margin-bottom: 1.25em; - list-style-position: outside; - font-family: inherit -} - -ul, ol, ul.no-bullet, ol.no-bullet { - margin-left: 1.5em -} - -ul li ul, ul li ol { - margin-left: 1.25em; - margin-bottom: 0; - font-size: 1em -} - -ul.square li ul, ul.circle li ul, ul.disc li ul { - list-style: inherit -} - -ul.square { - list-style-type: square -} - -ul.circle { - list-style-type: circle -} - -ul.disc { - list-style-type: disc -} - -ul.no-bullet { - list-style: none -} - -ol li ul, ol li ol { - margin-left: 1.25em; - margin-bottom: 0 -} - -dl dt { - margin-bottom: .3125em; - font-weight: bold -} - -dl dd { - margin-bottom: 1.25em -} - -abbr, acronym { - text-transform: uppercase; - font-size: 90%; - color: rgba(0, 0, 0, .8); - border-bottom: 1px dotted #ddd; - cursor: help -} - -abbr { - text-transform: none -} - -blockquote { - margin: 0 0 1.25em; - padding: .5625em 1.25em 0 1.1875em; - border-left: 1px solid #ddd -} - -blockquote cite { - display: block; - font-size: .9375em; - color: rgba(0, 0, 0, .6) -} - -blockquote cite:before { - content: "\2014 \0020" -} - -blockquote cite a, blockquote cite a:visited { - color: rgba(0, 0, 0, .6) -} - -blockquote, blockquote p { - line-height: 1.6; - color: rgba(0, 0, 0, .85) -} - -@media only screen and (min-width: 768px) { - h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { - line-height: 1.2 - } - - h1 { - font-size: 2.75em - } - - h2 { - font-size: 2.3125em - } - - h3, #toctitle, .sidebarblock > .content > .title { - font-size: 1.6875em - } - - h4 { - font-size: 1.4375em - } -} - -table { - background: #fff; - margin-bottom: 1.25em; - border: solid 1px #dedede -} - -table thead, table tfoot { - background: #f7f8f7; - font-weight: bold -} - -table thead tr th, table thead tr td, table tfoot tr th, table tfoot tr td { - padding: .5em .625em .625em; - font-size: inherit; - color: rgba(0, 0, 0, .8); - text-align: left -} - -table tr th, table tr td { - padding: .5625em .625em; - font-size: inherit; - color: rgba(0, 0, 0, .8) -} - -table tr.even, table tr.alt, table tr:nth-of-type(even) { - background: #f8f8f7 -} - -table thead tr th, table tfoot tr th, table tbody tr td, table tr td, table tfoot tr td { - display: table-cell; - line-height: 1.6 -} - -h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { - line-height: 1.2; - word-spacing: -.05em -} - -h1 strong, h2 strong, h3 strong, #toctitle strong, .sidebarblock > .content > .title strong, h4 strong, h5 strong, h6 strong { - font-weight: 400 -} - -.clearfix:before, .clearfix:after, .float-group:before, .float-group:after { - content: " "; - display: table -} - -.clearfix:after, .float-group:after { - clear: both -} - -*:not(pre) > code { - font-size: .9375em; - font-style: normal !important; - letter-spacing: 0; - padding: .1em .5ex; - word-spacing: -.15em; - background-color: #f7f7f8; - -webkit-border-radius: 4px; - border-radius: 4px; - line-height: 1.45; - text-rendering: optimizeSpeed -} - -pre, pre > code { - line-height: 1.45; - color: rgba(0, 0, 0, .9); - font-family: "Droid Sans Mono", "DejaVu Sans Mono", monospace; - font-weight: 400; - text-rendering: optimizeSpeed -} - -.keyseq { - color: rgba(51, 51, 51, .8) -} - -kbd { - display: inline-block; - color: rgba(0, 0, 0, .8); - font-size: .75em; - line-height: 1.4; - background-color: #f7f7f7; - border: 1px solid #ccc; - -webkit-border-radius: 3px; - border-radius: 3px; - -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 0 0 .1em white inset; - box-shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 0 0 .1em #fff inset; - margin: -.15em .15em 0 .15em; - padding: .2em .6em .2em .5em; - vertical-align: middle; - white-space: nowrap -} - -.keyseq kbd:first-child { - margin-left: 0 -} - -.keyseq kbd:last-child { - margin-right: 0 -} - -.menuseq, .menu { - color: rgba(0, 0, 0, .8) -} - -b.button:before, b.button:after { - position: relative; - top: -1px; - font-weight: 400 -} - -b.button:before { - content: "["; - padding: 0 3px 0 2px -} - -b.button:after { - content: "]"; - padding: 0 2px 0 3px -} - -p a > code:hover { - color: rgba(0, 0, 0, .9) -} - -#header, #content, #footnotes, #footer { - width: 100%; - margin-left: auto; - margin-right: auto; - margin-top: 0; - margin-bottom: 0; - max-width: 62.5em; - *zoom: 1; - position: relative; - padding-left: .9375em; - padding-right: .9375em -} - -#header:before, #header:after, #content:before, #content:after, #footnotes:before, #footnotes:after, #footer:before, #footer:after { - content: " "; - display: table -} - -#header:after, #content:after, #footnotes:after, #footer:after { - clear: both -} - -#content { - margin-top: 1.25em -} - -#content:before { - content: none -} - -#header > h1:first-child { - color: rgba(0, 0, 0, .85); - margin-top: 2.25rem; - margin-bottom: 0 -} - -#header > h1:first-child + #toc { - margin-top: 8px; - border-top: 1px solid #ddddd8 -} - -#header > h1:only-child, body.toc2 #header > h1:nth-last-child(2) { - border-bottom: 1px solid #ddddd8; - padding-bottom: 8px -} - -#header .details { - border-bottom: 1px solid #ddddd8; - line-height: 1.45; - padding-top: .25em; - padding-bottom: .25em; - padding-left: .25em; - color: rgba(0, 0, 0, .6); - display: -ms-flexbox; - display: -webkit-flex; - display: flex; - -ms-flex-flow: row wrap; - -webkit-flex-flow: row wrap; - flex-flow: row wrap -} - -#header .details span:first-child { - margin-left: -.125em -} - -#header .details span.email a { - color: rgba(0, 0, 0, .85) -} - -#header .details br { - display: none -} - -#header .details br + span:before { - content: "\00a0\2013\00a0" -} - -#header .details br + span.author:before { - content: "\00a0\22c5\00a0"; - color: rgba(0, 0, 0, .85) -} - -#header .details br + span#revremark:before { - content: "\00a0|\00a0" -} - -#header #revnumber { - text-transform: capitalize -} - -#header #revnumber:after { - content: "\00a0" -} - -#content > h1:first-child:not([class]) { - color: rgba(0, 0, 0, .85); - border-bottom: 1px solid #ddddd8; - padding-bottom: 8px; - margin-top: 0; - padding-top: 1rem; - margin-bottom: 1.25rem -} - -#toc { - border-bottom: 1px solid #efefed; - padding-bottom: .5em -} - -#toc > ul { - margin-left: .125em -} - -#toc ul.sectlevel0 > li > a { - font-style: italic -} - -#toc ul.sectlevel0 ul.sectlevel1 { - margin: .5em 0 -} - -#toc ul { - font-family: "Open Sans", "DejaVu Sans", sans-serif; - list-style-type: none -} - -#toc a { - text-decoration: none -} - -#toc a:active { - text-decoration: underline -} - -#toctitle { - color: #7a2518; - font-size: 1.2em -} - -@media only screen and (min-width: 768px) { - #toctitle { - font-size: 1.375em - } - - body.toc2 { - padding-left: 15em; - padding-right: 0 - } - - #toc.toc2 { - margin-top: 0 !important; - background-color: #f8f8f7; - position: fixed; - width: 15em; - left: 0; - top: 0; - border-right: 1px solid #efefed; - border-top-width: 0 !important; - border-bottom-width: 0 !important; - z-index: 1000; - padding: 1.25em 1em; - height: 100%; - overflow: auto - } - - #toc.toc2 #toctitle { - margin-top: 0; - font-size: 1.2em - } - - #toc.toc2 > ul { - font-size: .9em; - margin-bottom: 0 - } - - #toc.toc2 ul ul { - margin-left: 0; - padding-left: 1em - } - - #toc.toc2 ul.sectlevel0 ul.sectlevel1 { - padding-left: 0; - margin-top: .5em; - margin-bottom: .5em - } - - body.toc2.toc-right { - padding-left: 0; - padding-right: 15em - } - - body.toc2.toc-right #toc.toc2 { - border-right-width: 0; - border-left: 1px solid #efefed; - left: auto; - right: 0 - } -} - -@media only screen and (min-width: 1280px) { - body.toc2 { - padding-left: 20em; - padding-right: 0 - } - - #toc.toc2 { - width: 20em - } - - #toc.toc2 #toctitle { - font-size: 1.375em - } - - #toc.toc2 > ul { - font-size: .95em - } - - #toc.toc2 ul ul { - padding-left: 1.25em - } - - body.toc2.toc-right { - padding-left: 0; - padding-right: 20em - } -} - -#content #toc { - border-style: solid; - border-width: 1px; - border-color: #e0e0dc; - margin-bottom: 1.25em; - padding: 1.25em; - background: #f8f8f7; - -webkit-border-radius: 4px; - border-radius: 4px -} - -#content #toc > :first-child { - margin-top: 0 -} - -#content #toc > :last-child { - margin-bottom: 0 -} - -#footer { - max-width: 100%; - background-color: rgba(0, 0, 0, .8); - padding: 1.25em -} - -#footer-text { - color: rgba(255, 255, 255, .8); - line-height: 1.44 -} - -.sect1 { - padding-bottom: .625em -} - -@media only screen and (min-width: 768px) { - .sect1 { - padding-bottom: 1.25em - } -} - -.sect1 + .sect1 { - border-top: 1px solid #efefed -} - -#content h1 > a.anchor, h2 > a.anchor, h3 > a.anchor, #toctitle > a.anchor, .sidebarblock > .content > .title > a.anchor, h4 > a.anchor, h5 > a.anchor, h6 > a.anchor { - position: absolute; - z-index: 1001; - width: 1.5ex; - margin-left: -1.5ex; - display: block; - text-decoration: none !important; - visibility: hidden; - text-align: center; - font-weight: 400 -} - -#content h1 > a.anchor:before, h2 > a.anchor:before, h3 > a.anchor:before, #toctitle > a.anchor:before, .sidebarblock > .content > .title > a.anchor:before, h4 > a.anchor:before, h5 > a.anchor:before, h6 > a.anchor:before { - content: "\00A7"; - font-size: .85em; - display: block; - padding-top: .1em -} - -#content h1:hover > a.anchor, #content h1 > a.anchor:hover, h2:hover > a.anchor, h2 > a.anchor:hover, h3:hover > a.anchor, #toctitle:hover > a.anchor, .sidebarblock > .content > .title:hover > a.anchor, h3 > a.anchor:hover, #toctitle > a.anchor:hover, .sidebarblock > .content > .title > a.anchor:hover, h4:hover > a.anchor, h4 > a.anchor:hover, h5:hover > a.anchor, h5 > a.anchor:hover, h6:hover > a.anchor, h6 > a.anchor:hover { - visibility: visible -} - -#content h1 > a.link, h2 > a.link, h3 > a.link, #toctitle > a.link, .sidebarblock > .content > .title > a.link, h4 > a.link, h5 > a.link, h6 > a.link { - color: #ba3925; - text-decoration: none -} - -#content h1 > a.link:hover, h2 > a.link:hover, h3 > a.link:hover, #toctitle > a.link:hover, .sidebarblock > .content > .title > a.link:hover, h4 > a.link:hover, h5 > a.link:hover, h6 > a.link:hover { - color: #a53221 -} - -.audioblock, .imageblock, .literalblock, .listingblock, .stemblock, .videoblock { - margin-bottom: 1.25em -} - -.admonitionblock td.content > .title, .audioblock > .title, .exampleblock > .title, .imageblock > .title, .listingblock > .title, .literalblock > .title, .stemblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, table.tableblock > .title, .verseblock > .title, .videoblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { - text-rendering: optimizeLegibility; - text-align: left; - font-family: "Noto Serif", "DejaVu Serif", serif; - font-size: 1rem; - font-style: italic -} - -table.tableblock > caption.title { - white-space: nowrap; - overflow: visible; - max-width: 0 -} - -.paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { - color: rgba(0, 0, 0, .85) -} - -table.tableblock #preamble > .sectionbody > .paragraph:first-of-type p { - font-size: inherit -} - -.admonitionblock > table { - border-collapse: separate; - border: 0; - background: none; - width: 100% -} - -.admonitionblock > table td.icon { - text-align: center; - width: 80px -} - -.admonitionblock > table td.icon img { - max-width: none -} - -.admonitionblock > table td.icon .title { - font-weight: bold; - font-family: "Open Sans", "DejaVu Sans", sans-serif; - text-transform: uppercase -} - -.admonitionblock > table td.content { - padding-left: 1.125em; - padding-right: 1.25em; - border-left: 1px solid #ddddd8; - color: rgba(0, 0, 0, .6) -} - -.admonitionblock > table td.content > :last-child > :last-child { - margin-bottom: 0 -} - -.exampleblock > .content { - border-style: solid; - border-width: 1px; - border-color: #e6e6e6; - margin-bottom: 1.25em; - padding: 1.25em; - background: #fff; - -webkit-border-radius: 4px; - border-radius: 4px -} - -.exampleblock > .content > :first-child { - margin-top: 0 -} - -.exampleblock > .content > :last-child { - margin-bottom: 0 -} - -.sidebarblock { - border-style: solid; - border-width: 1px; - border-color: #e0e0dc; - margin-bottom: 1.25em; - padding: 1.25em; - background: #f8f8f7; - -webkit-border-radius: 4px; - border-radius: 4px -} - -.sidebarblock > :first-child { - margin-top: 0 -} - -.sidebarblock > :last-child { - margin-bottom: 0 -} - -.sidebarblock > .content > .title { - color: #7a2518; - margin-top: 0; - text-align: center -} - -.exampleblock > .content > :last-child > :last-child, .exampleblock > .content .olist > ol > li:last-child > :last-child, .exampleblock > .content .ulist > ul > li:last-child > :last-child, .exampleblock > .content .qlist > ol > li:last-child > :last-child, .sidebarblock > .content > :last-child > :last-child, .sidebarblock > .content .olist > ol > li:last-child > :last-child, .sidebarblock > .content .ulist > ul > li:last-child > :last-child, .sidebarblock > .content .qlist > ol > li:last-child > :last-child { - margin-bottom: 0 -} - -.literalblock pre, .listingblock pre:not(.highlight), .listingblock pre[class="highlight"], .listingblock pre[class^="highlight "], .listingblock pre.CodeRay, .listingblock pre.prettyprint { - background: #f7f7f8 -} - -.sidebarblock .literalblock pre, .sidebarblock .listingblock pre:not(.highlight), .sidebarblock .listingblock pre[class="highlight"], .sidebarblock .listingblock pre[class^="highlight "], .sidebarblock .listingblock pre.CodeRay, .sidebarblock .listingblock pre.prettyprint { - background: #f2f1f1 -} - -.literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { - -webkit-border-radius: 4px; - border-radius: 4px; - word-wrap: break-word; - padding: 1em; - font-size: .8125em -} - -.literalblock pre.nowrap, .literalblock pre[class].nowrap, .listingblock pre.nowrap, .listingblock pre[class].nowrap { - overflow-x: auto; - white-space: pre; - word-wrap: normal -} - -@media only screen and (min-width: 768px) { - .literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { - font-size: .90625em - } -} - -@media only screen and (min-width: 1280px) { - .literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { - font-size: 1em - } -} - -.literalblock.output pre { - color: #f7f7f8; - background-color: rgba(0, 0, 0, .9) -} - -.listingblock pre.highlightjs { - padding: 0 -} - -.listingblock pre.highlightjs > code { - padding: 1em; - -webkit-border-radius: 4px; - border-radius: 4px -} - -.listingblock pre.prettyprint { - border-width: 0 -} - -.listingblock > .content { - position: relative -} - -.listingblock code[data-lang]:before { - display: none; - content: attr(data-lang); - position: absolute; - font-size: .75em; - top: .425rem; - right: .5rem; - line-height: 1; - text-transform: uppercase; - color: #999 -} - -.listingblock:hover code[data-lang]:before { - display: block -} - -.listingblock.terminal pre .command:before { - content: attr(data-prompt); - padding-right: .5em; - color: #999 -} - -.listingblock.terminal pre .command:not([data-prompt]):before { - content: "$" -} - -table.pyhltable { - border-collapse: separate; - border: 0; - margin-bottom: 0; - background: none -} - -table.pyhltable td { - vertical-align: top; - padding-top: 0; - padding-bottom: 0 -} - -table.pyhltable td.code { - padding-left: .75em; - padding-right: 0 -} - -pre.pygments .lineno, table.pyhltable td:not(.code) { - color: #999; - padding-left: 0; - padding-right: .5em; - border-right: 1px solid #ddddd8 -} - -pre.pygments .lineno { - display: inline-block; - margin-right: .25em -} - -table.pyhltable .linenodiv { - background: none !important; - padding-right: 0 !important -} - -.quoteblock { - margin: 0 1em 1.25em 1.5em; - display: table -} - -.quoteblock > .title { - margin-left: -1.5em; - margin-bottom: .75em -} - -.quoteblock blockquote, .quoteblock blockquote p { - color: rgba(0, 0, 0, .85); - font-size: 1.15rem; - line-height: 1.75; - word-spacing: .1em; - letter-spacing: 0; - font-style: italic; - text-align: justify -} - -.quoteblock blockquote { - margin: 0; - padding: 0; - border: 0 -} - -.quoteblock blockquote:before { - content: "\201c"; - float: left; - font-size: 2.75em; - font-weight: bold; - line-height: .6em; - margin-left: -.6em; - color: #7a2518; - text-shadow: 0 1px 2px rgba(0, 0, 0, .1) -} - -.quoteblock blockquote > .paragraph:last-child p { - margin-bottom: 0 -} - -.quoteblock .attribution { - margin-top: .5em; - margin-right: .5ex; - text-align: right -} - -.quoteblock .quoteblock { - margin-left: 0; - margin-right: 0; - padding: .5em 0; - border-left: 3px solid rgba(0, 0, 0, .6) -} - -.quoteblock .quoteblock blockquote { - padding: 0 0 0 .75em -} - -.quoteblock .quoteblock blockquote:before { - display: none -} - -.verseblock { - margin: 0 1em 1.25em 1em -} - -.verseblock pre { - font-family: "Open Sans", "DejaVu Sans", sans; - font-size: 1.15rem; - color: rgba(0, 0, 0, .85); - font-weight: 300; - text-rendering: optimizeLegibility -} - -.verseblock pre strong { - font-weight: 400 -} - -.verseblock .attribution { - margin-top: 1.25rem; - margin-left: .5ex -} - -.quoteblock .attribution, .verseblock .attribution { - font-size: .9375em; - line-height: 1.45; - font-style: italic -} - -.quoteblock .attribution br, .verseblock .attribution br { - display: none -} - -.quoteblock .attribution cite, .verseblock .attribution cite { - display: block; - letter-spacing: -.05em; - color: rgba(0, 0, 0, .6) -} - -.quoteblock.abstract { - margin: 0 0 1.25em 0; - display: block -} - -.quoteblock.abstract blockquote, .quoteblock.abstract blockquote p { - text-align: left; - word-spacing: 0 -} - -.quoteblock.abstract blockquote:before, .quoteblock.abstract blockquote p:first-of-type:before { - display: none -} - -table.tableblock { - max-width: 100%; - border-collapse: separate -} - -table.tableblock td > .paragraph:last-child p > p:last-child, table.tableblock th > p:last-child, table.tableblock td > p:last-child { - margin-bottom: 0 -} - -table.spread { - width: 100% -} - -table.tableblock, th.tableblock, td.tableblock { - border: 0 solid #dedede -} - -table.grid-all th.tableblock, table.grid-all td.tableblock { - border-width: 0 1px 1px 0 -} - -table.grid-all tfoot > tr > th.tableblock, table.grid-all tfoot > tr > td.tableblock { - border-width: 1px 1px 0 0 -} - -table.grid-cols th.tableblock, table.grid-cols td.tableblock { - border-width: 0 1px 0 0 -} - -table.grid-all * > tr > .tableblock:last-child, table.grid-cols * > tr > .tableblock:last-child { - border-right-width: 0 -} - -table.grid-rows th.tableblock, table.grid-rows td.tableblock { - border-width: 0 0 1px 0 -} - -table.grid-all tbody > tr:last-child > th.tableblock, table.grid-all tbody > tr:last-child > td.tableblock, table.grid-all thead:last-child > tr > th.tableblock, table.grid-rows tbody > tr:last-child > th.tableblock, table.grid-rows tbody > tr:last-child > td.tableblock, table.grid-rows thead:last-child > tr > th.tableblock { - border-bottom-width: 0 -} - -table.grid-rows tfoot > tr > th.tableblock, table.grid-rows tfoot > tr > td.tableblock { - border-width: 1px 0 0 0 -} - -table.frame-all { - border-width: 1px -} - -table.frame-sides { - border-width: 0 1px -} - -table.frame-topbot { - border-width: 1px 0 -} - -th.halign-left, td.halign-left { - text-align: left -} - -th.halign-right, td.halign-right { - text-align: right -} - -th.halign-center, td.halign-center { - text-align: center -} - -th.valign-top, td.valign-top { - vertical-align: top -} - -th.valign-bottom, td.valign-bottom { - vertical-align: bottom -} - -th.valign-middle, td.valign-middle { - vertical-align: middle -} - -table thead th, table tfoot th { - font-weight: bold -} - -tbody tr th { - display: table-cell; - line-height: 1.6; - background: #f7f8f7 -} - -tbody tr th, tbody tr th p, tfoot tr th, tfoot tr th p { - color: rgba(0, 0, 0, .8); - font-weight: bold -} - -p.tableblock > code:only-child { - background: none; - padding: 0 -} - -p.tableblock { - font-size: 1em -} - -td > div.verse { - white-space: pre -} - -ol { - margin-left: 1.75em -} - -ul li ol { - margin-left: 1.5em -} - -dl dd { - margin-left: 1.125em -} - -dl dd:last-child, dl dd:last-child > :last-child { - margin-bottom: 0 -} - -ol > li p, ul > li p, ul dd, ol dd, .olist .olist, .ulist .ulist, .ulist .olist, .olist .ulist { - margin-bottom: .625em -} - -ul.unstyled, ol.unnumbered, ul.checklist, ul.none { - list-style-type: none -} - -ul.unstyled, ol.unnumbered, ul.checklist { - margin-left: .625em -} - -ul.checklist li > p:first-child > .fa-check-square-o:first-child, ul.checklist li > p:first-child > input[type="checkbox"]:first-child { - margin-right: .25em -} - -ul.checklist li > p:first-child > input[type="checkbox"]:first-child { - position: relative; - top: 1px -} - -ul.inline { - margin: 0 auto .625em auto; - margin-left: -1.375em; - margin-right: 0; - padding: 0; - list-style: none; - overflow: hidden -} - -ul.inline > li { - list-style: none; - float: left; - margin-left: 1.375em; - display: block -} - -ul.inline > li > * { - display: block -} - -.unstyled dl dt { - font-weight: 400; - font-style: normal -} - -ol.arabic { - list-style-type: decimal -} - -ol.decimal { - list-style-type: decimal-leading-zero -} - -ol.loweralpha { - list-style-type: lower-alpha -} - -ol.upperalpha { - list-style-type: upper-alpha -} - -ol.lowerroman { - list-style-type: lower-roman -} - -ol.upperroman { - list-style-type: upper-roman -} - -ol.lowergreek { - list-style-type: lower-greek -} - -.hdlist > table, .colist > table { - border: 0; - background: none -} - -.hdlist > table > tbody > tr, .colist > table > tbody > tr { - background: none -} - -td.hdlist1 { - padding-right: .75em; - font-weight: bold -} - -td.hdlist1, td.hdlist2 { - vertical-align: top -} - -.literalblock + .colist, .listingblock + .colist { - margin-top: -.5em -} - -.colist > table tr > td:first-of-type { - padding: 0 .75em; - line-height: 1 -} - -.colist > table tr > td:last-of-type { - padding: .25em 0 -} - -.thumb, .th { - line-height: 0; - display: inline-block; - border: solid 4px #fff; - -webkit-box-shadow: 0 0 0 1px #ddd; - box-shadow: 0 0 0 1px #ddd -} - -.imageblock.left, .imageblock[style*="float: left"] { - margin: .25em .625em 1.25em 0 -} - -.imageblock.right, .imageblock[style*="float: right"] { - margin: .25em 0 1.25em .625em -} - -.imageblock > .title { - margin-bottom: 0 -} - -.imageblock.thumb, .imageblock.th { - border-width: 6px -} - -.imageblock.thumb > .title, .imageblock.th > .title { - padding: 0 .125em -} - -.image.left, .image.right { - margin-top: .25em; - margin-bottom: .25em; - display: inline-block; - line-height: 0 -} - -.image.left { - margin-right: .625em -} - -.image.right { - margin-left: .625em -} - -a.image { - text-decoration: none -} - -span.footnote, span.footnoteref { - vertical-align: super; - font-size: .875em -} - -span.footnote a, span.footnoteref a { - text-decoration: none -} - -span.footnote a:active, span.footnoteref a:active { - text-decoration: underline -} - -#footnotes { - padding-top: .75em; - padding-bottom: .75em; - margin-bottom: .625em -} - -#footnotes hr { - width: 20%; - min-width: 6.25em; - margin: -.25em 0 .75em 0; - border-width: 1px 0 0 0 -} - -#footnotes .footnote { - padding: 0 .375em; - line-height: 1.3; - font-size: .875em; - margin-left: 1.2em; - text-indent: -1.2em; - margin-bottom: .2em -} - -#footnotes .footnote a:first-of-type { - font-weight: bold; - text-decoration: none -} - -#footnotes .footnote:last-of-type { - margin-bottom: 0 -} - -#content #footnotes { - margin-top: -.625em; - margin-bottom: 0; - padding: .75em 0 -} - -.gist .file-data > table { - border: 0; - background: #fff; - width: 100%; - margin-bottom: 0 -} - -.gist .file-data > table td.line-data { - width: 99% -} - -div.unbreakable { - page-break-inside: avoid -} - -.big { - font-size: larger -} - -.small { - font-size: smaller -} - -.underline { - text-decoration: underline -} - -.overline { - text-decoration: overline -} - -.line-through { - text-decoration: line-through -} - -.aqua { - color: #00bfbf -} - -.aqua-background { - background-color: #00fafa -} - -.black { - color: #000 -} - -.black-background { - background-color: #000 -} - -.blue { - color: #0000bf -} - -.blue-background { - background-color: #0000fa -} - -.fuchsia { - color: #bf00bf -} - -.fuchsia-background { - background-color: #fa00fa -} - -.gray { - color: #606060 -} - -.gray-background { - background-color: #7d7d7d -} - -.green { - color: #006000 -} - -.green-background { - background-color: #007d00 -} - -.lime { - color: #00bf00 -} - -.lime-background { - background-color: #00fa00 -} - -.maroon { - color: #600000 -} - -.maroon-background { - background-color: #7d0000 -} - -.navy { - color: #000060 -} - -.navy-background { - background-color: #00007d -} - -.olive { - color: #606000 -} - -.olive-background { - background-color: #7d7d00 -} - -.purple { - color: #600060 -} - -.purple-background { - background-color: #7d007d -} - -.red { - color: #bf0000 -} - -.red-background { - background-color: #fa0000 -} - -.silver { - color: #909090 -} - -.silver-background { - background-color: #bcbcbc -} - -.teal { - color: #006060 -} - -.teal-background { - background-color: #007d7d -} - -.white { - color: #bfbfbf -} - -.white-background { - background-color: #fafafa -} - -.yellow { - color: #bfbf00 -} - -.yellow-background { - background-color: #fafa00 -} - -span.icon > .fa { - cursor: default -} - -.admonitionblock td.icon [class^="fa icon-"] { - font-size: 2.5em; - text-shadow: 1px 1px 2px rgba(0, 0, 0, .5); - cursor: default -} - -.admonitionblock td.icon .icon-note:before { - content: "\f05a"; - color: #19407c -} - -.admonitionblock td.icon .icon-tip:before { - content: "\f0eb"; - text-shadow: 1px 1px 2px rgba(155, 155, 0, .8); - color: #111 -} - -.admonitionblock td.icon .icon-warning:before { - content: "\f071"; - color: #bf6900 -} - -.admonitionblock td.icon .icon-caution:before { - content: "\f06d"; - color: #bf3400 -} - -.admonitionblock td.icon .icon-important:before { - content: "\f06a"; - color: #bf0000 -} - -.conum[data-value] { - display: inline-block; - color: #fff !important; - background-color: rgba(0, 0, 0, .8); - -webkit-border-radius: 100px; - border-radius: 100px; - text-align: center; - font-size: .75em; - width: 1.67em; - height: 1.67em; - line-height: 1.67em; - font-family: "Open Sans", "DejaVu Sans", sans-serif; - font-style: normal; - font-weight: bold -} - -.conum[data-value] * { - color: #fff !important -} - -.conum[data-value] + b { - display: none -} - -.conum[data-value]:after { - content: attr(data-value) -} - -pre .conum[data-value] { - position: relative; - top: -.125em -} - -b.conum * { - color: inherit !important -} - -.conum:not([data-value]):empty { - display: none -} - -h1, h2 { - letter-spacing: -.01em -} - -dt, th.tableblock, td.content { - text-rendering: optimizeLegibility -} - -p, td.content { - letter-spacing: -.01em -} - -p strong, td.content strong { - letter-spacing: -.005em -} - -p, blockquote, dt, td.content { - font-size: 1.0625rem -} - -p { - margin-bottom: 1.25rem -} - -.sidebarblock p, .sidebarblock dt, .sidebarblock td.content, p.tableblock { - font-size: 1em -} - -.exampleblock > .content { - background-color: #fffef7; - border-color: #e0e0dc; - -webkit-box-shadow: 0 1px 4px #e0e0dc; - box-shadow: 0 1px 4px #e0e0dc -} - -.print-only { - display: none !important -} - -@media print { - @page { - margin: 1.25cm .75cm - } - - * { - -webkit-box-shadow: none !important; - box-shadow: none !important; - text-shadow: none !important - } - - a { - color: inherit !important; - text-decoration: underline !important - } - - a.bare, a[href^="#"], a[href^="mailto:"] { - text-decoration: none !important - } - - a[href^="http:"]:not(.bare):after, a[href^="https:"]:not(.bare):after { - content: "(" attr(href) ")"; - display: inline-block; - font-size: .875em; - padding-left: .25em - } - - abbr[title]:after { - content: " (" attr(title) ")" - } - - pre, blockquote, tr, img { - page-break-inside: avoid - } - - thead { - display: table-header-group - } - - img { - max-width: 100% !important - } - - p, blockquote, dt, td.content { - font-size: 1em; - orphans: 3; - widows: 3 - } - - h2, h3, #toctitle, .sidebarblock > .content > .title { - page-break-after: avoid - } - - #toc, .sidebarblock, .exampleblock > .content { - background: none !important - } - - #toc { - border-bottom: 1px solid #ddddd8 !important; - padding-bottom: 0 !important - } - - .sect1 { - padding-bottom: 0 !important - } - - .sect1 + .sect1 { - border: 0 !important - } - - #header > h1:first-child { - margin-top: 1.25rem - } - - body.book #header { - text-align: center - } - - body.book #header > h1:first-child { - border: 0 !important; - margin: 2.5em 0 1em 0 - } - - body.book #header .details { - border: 0 !important; - display: block; - padding: 0 !important - } - - body.book #header .details span:first-child { - margin-left: 0 !important - } - - body.book #header .details br { - display: block - } - - body.book #header .details br + span:before { - content: none !important - } - - body.book #toc { - border: 0 !important; - text-align: left !important; - padding: 0 !important; - margin: 0 !important - } - - body.book #toc, body.book #preamble, body.book h1.sect0, body.book .sect1 > h2 { - page-break-before: always - } - - .listingblock code[data-lang]:before { - display: block - } - - #footer { - background: none !important; - padding: 0 .9375em - } - - #footer-text { - color: rgba(0, 0, 0, .6) !important; - font-size: .9em - } - - .hide-on-print { - display: none !important - } - - .print-only { - display: block !important - } - - .hide-for-print { - display: none !important - } - - .show-for-print { - display: inherit !important - } -} diff --git a/config/releaser.yml b/config/releaser.yml deleted file mode 100644 index e3594e2c..00000000 --- a/config/releaser.yml +++ /dev/null @@ -1,3 +0,0 @@ -releaser: - maven: - buildCommand: ./scripts/build.sh {{systemProps}} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index d464815d..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -# Work in Progress -consul: - image: library/consul - ports: - - "8300:8300" - - "8400:8400" - - "8500:8500" - - "8600:8600" diff --git a/docs/.github/workflows/deploy-docs.yml b/docs/.github/workflows/deploy-docs.yml deleted file mode 100644 index be4b92df..00000000 --- a/docs/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Deploy Docs -on: - push: - branches-ignore: [ gh-pages ] - tags: '**' - repository_dispatch: - types: request-build-reference # legacy - #schedule: - #- cron: '0 10 * * *' # Once per day at 10am UTC - workflow_dispatch: -permissions: - actions: write -jobs: - build: - runs-on: ubuntu-latest - # if: github.repository_owner == 'spring-cloud' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: docs-build - fetch-depth: 1 - - name: Dispatch (partial build) - if: github.ref_type == 'branch' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }} - - name: Dispatch (full build) - if: github.ref_type == 'tag' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) diff --git a/docs/antora.yml b/docs/antora.yml deleted file mode 100644 index 15b346da..00000000 --- a/docs/antora.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: PROJECT_WITHOUT_SPRING -version: true -title: PROJECT_NAME -nav: - - modules/ROOT/nav.adoc -ext: - collector: - run: - command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests - local: true - scan: - dir: ./target/classes/antora-resources/ diff --git a/docs/modules/ROOT/assets/images/.gitkeep b/docs/modules/ROOT/assets/images/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc deleted file mode 100644 index bf8091f1..00000000 --- a/docs/modules/ROOT/nav.adoc +++ /dev/null @@ -1,20 +0,0 @@ -* xref:index.adoc[] -* xref:spring-cloud-consul.adoc[] -** xref:spring-cloud-consul/quick-start.adoc[] -** xref:spring-cloud-consul/install.adoc[] -** xref:spring-cloud-consul/agent.adoc[] -** xref:spring-cloud-consul/discovery.adoc[] -** xref:spring-cloud-consul/config.adoc[] -** xref:spring-cloud-consul/retry.adoc[] -** xref:spring-cloud-consul/bus.adoc[] -** xref:spring-cloud-consul/hystrix.adoc[] -** xref:spring-cloud-consul/turbine.adoc[] -** xref:spring-cloud-consul/configuration-properties.adoc[] -* xref:_attributes.adoc[] -* xref:intro.adoc[] -* xref:quickstart.adoc[] -* xref:README.adoc[] -* xref:_configprops.adoc[] -* xref:appendix.adoc[] -* xref:sagan-boot.adoc[] -* xref:sagan-index.adoc[] diff --git a/docs/modules/ROOT/pages/README.adoc b/docs/modules/ROOT/pages/README.adoc deleted file mode 100644 index df51815c..00000000 --- a/docs/modules/ROOT/pages/README.adoc +++ /dev/null @@ -1,51 +0,0 @@ -image::https://circleci.com/gh/spring-cloud/spring-cloud-consul/tree/master.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-consul/tree/master"] -image::https://codecov.io/gh/spring-cloud/spring-cloud-consul/branch/master/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-consul/branch/master"] - - -[[quick-start]] -= Quick Start - - -[[consul-overview]] -= Consul overview - -Features of Consul - -* Distributed configuration -* Service registration and discovery -* Distributed events -* Distributed locking and sessions -* Supports multiple data centers -* Built in, user-friendly user interface - -See the https://consul.io/intro/index.html[intro] for more information. - -[[spring-cloud-consul-features]] -= Spring Cloud Consul Features - -* Spring Cloud `DiscoveryClient` implementation -** supports Spring Cloud Gateway -** supports Spring Cloud LoadBalancer -* Consul based `PropertySource` loaded during the 'bootstrap' phase. -* Spring Cloud Bus implementation based on Consul https://www.consul.io/docs/agent/http/event.html[events] - -[[running-the-sample]] -= Running the sample - -1. Run `docker-compose up` -2. Verify consul is running by visiting http://localhost:8500 -3. Run `mvn package` this will bring in the required spring cloud maven repositories and build -4. Run `java -jar spring-cloud-consul-sample/target/spring-cloud-consul-sample-${VERSION}.jar` -5. visit http://localhost:8080, verify that `{"serviceId":":8080","host":"","port":8080}` results -6. run `java -jar spring-cloud-consul-sample/target/spring-cloud-consul-sample-${VERSION}.jar --server.port=8081` -7. visit http://localhost:8080 again, verify that `{"serviceId":":8081","host":"","port":8081}` eventually shows up in the results in a round robbin fashion (may take a minute or so). - -[[building]] -= Building - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/building-jdk8.adoc[] - -[[contributing]] -= Contributing - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing.adoc[] diff --git a/docs/modules/ROOT/pages/_attributes.adoc b/docs/modules/ROOT/pages/_attributes.adoc deleted file mode 100644 index 85c02ce3..00000000 --- a/docs/modules/ROOT/pages/_attributes.adoc +++ /dev/null @@ -1,14 +0,0 @@ -:doctype: book -:idprefix: -:idseparator: - -:tabsize: 4 -:numbered: -:sectanchors: -:sectnums: -:icons: font -:hide-uri-scheme: -:docinfo: shared,private - -:sc-ext: java -:project-full-name: Spring Cloud Consul -:all: {asterisk}{asterisk} diff --git a/docs/modules/ROOT/pages/_configprops.adoc b/docs/modules/ROOT/pages/_configprops.adoc deleted file mode 100644 index f38fe13c..00000000 --- a/docs/modules/ROOT/pages/_configprops.adoc +++ /dev/null @@ -1,84 +0,0 @@ -|=== -|Name | Default | Description - -|spring.cloud.consul.config.acl-token | | -|spring.cloud.consul.config.data-key | `+++data+++` | If format is Format.PROPERTIES or Format.YAML then the following field is used as key to look up consul for configuration. -|spring.cloud.consul.config.default-context | `+++application+++` | -|spring.cloud.consul.config.enabled | `+++true+++` | -|spring.cloud.consul.config.fail-fast | `+++true+++` | Throw exceptions during config lookup if true, otherwise, log warnings. -|spring.cloud.consul.config.format | | -|spring.cloud.consul.config.name | | Alternative to spring.application.name to use in looking up values in consul KV. -|spring.cloud.consul.config.prefix | | -|spring.cloud.consul.config.prefixes | | -|spring.cloud.consul.config.profile-separator | `+++,+++` | -|spring.cloud.consul.config.watch.delay | `+++1000+++` | The value of the fixed delay for the watch in millis. Defaults to 1000. -|spring.cloud.consul.config.watch.enabled | `+++true+++` | If the watch is enabled. Defaults to true. -|spring.cloud.consul.config.watch.wait-time | `+++55+++` | The number of seconds to wait (or block) for watch query, defaults to 55. Needs to be less than default ConsulClient (defaults to 60). To increase ConsulClient timeout create a ConsulClient bean with a custom ConsulRawClient with a custom HttpClient. -|spring.cloud.consul.discovery.acl-token | | -|spring.cloud.consul.discovery.catalog-services-watch-delay | `+++1000+++` | The delay between calls to watch consul catalog in millis, default is 1000. -|spring.cloud.consul.discovery.catalog-services-watch-timeout | `+++2+++` | The number of seconds to block while watching consul catalog, default is 2. -|spring.cloud.consul.discovery.consistency-mode | | Consistency mode for health service request. -|spring.cloud.consul.discovery.datacenters | | Map of serviceId's -> datacenter to query for in server list. This allows looking up services in another datacenters. -|spring.cloud.consul.discovery.default-query-tag | | Tag to query for in service list if one is not listed in serverListQueryTags. Multiple tags can be specified with a comma separated value. -|spring.cloud.consul.discovery.default-zone-metadata-name | `+++zone+++` | Service instance zone comes from metadata. This allows changing the metadata tag name. -|spring.cloud.consul.discovery.deregister | `+++true+++` | Disable automatic de-registration of service in consul. -|spring.cloud.consul.discovery.enable-tag-override | | Enable tag override for the registered service. -|spring.cloud.consul.discovery.enabled | `+++true+++` | Is service discovery enabled? -|spring.cloud.consul.discovery.fail-fast | `+++true+++` | Throw exceptions during service registration if true, otherwise, log warnings (defaults to true). -|spring.cloud.consul.discovery.health-check-critical-timeout | | Timeout to deregister services critical for longer than timeout (e.g. 30m). Requires consul version 7.x or higher. -|spring.cloud.consul.discovery.health-check-headers | | Headers to be applied to the Health Check calls. -|spring.cloud.consul.discovery.health-check-interval | `+++10s+++` | How often to perform the health check (e.g. 10s), defaults to 10s. -|spring.cloud.consul.discovery.health-check-path | `+++/actuator/health+++` | Alternate server path to invoke for health checking. -|spring.cloud.consul.discovery.health-check-timeout | | Timeout for health check (e.g. 10s). -|spring.cloud.consul.discovery.health-check-tls-skip-verify | | Skips certificate verification during service checks if true, otherwise runs certificate verification. -|spring.cloud.consul.discovery.health-check-url | | Custom health check url to override default. -|spring.cloud.consul.discovery.heartbeat.actuator-health-group | | The actuator health group to use (null for the root group) when determining system health via Actuator. -|spring.cloud.consul.discovery.heartbeat.enabled | `+++false+++` | -|spring.cloud.consul.discovery.heartbeat.interval-ratio | | -|spring.cloud.consul.discovery.heartbeat.reregister-service-on-failure | `+++false+++` | -|spring.cloud.consul.discovery.heartbeat.ttl | `+++30s+++` | -|spring.cloud.consul.discovery.heartbeat.use-actuator-health | `+++true+++` | Whether or not to take the current system health (as reported via the Actuator Health endpoint) into account when reporting the application status to the Consul TTL check. Actuator Health endpoint also has to be available to the application. -|spring.cloud.consul.discovery.hostname | | Hostname to use when accessing server. -|spring.cloud.consul.discovery.include-hostname-in-instance-id | `+++false+++` | Whether hostname is included into the default instance id when registering service. -|spring.cloud.consul.discovery.instance-group | | Service instance group. -|spring.cloud.consul.discovery.instance-id | | Unique service instance id. -|spring.cloud.consul.discovery.instance-zone | | Service instance zone. -|spring.cloud.consul.discovery.ip-address | | IP address to use when accessing service (must also set preferIpAddress to use). -|spring.cloud.consul.discovery.lifecycle.enabled | `+++true+++` | -|spring.cloud.consul.discovery.management-enable-tag-override | | Enable tag override for the registered management service. -|spring.cloud.consul.discovery.management-metadata | | Metadata to use when registering management service. -|spring.cloud.consul.discovery.management-port | | Port to register the management service under (defaults to management port). -|spring.cloud.consul.discovery.management-suffix | `+++management+++` | Suffix to use when registering management service. -|spring.cloud.consul.discovery.management-tags | | Tags to use when registering management service. -|spring.cloud.consul.discovery.metadata | | Metadata to use when registering service. -|spring.cloud.consul.discovery.order | `+++0+++` | Order of the discovery client used by `CompositeDiscoveryClient` for sorting available clients. -|spring.cloud.consul.discovery.port | | Port to register the service under (defaults to listening port). -|spring.cloud.consul.discovery.prefer-agent-address | `+++false+++` | Source of how we will determine the address to use. -|spring.cloud.consul.discovery.prefer-ip-address | `+++false+++` | Use ip address rather than hostname during registration. -|spring.cloud.consul.discovery.query-passing | `+++false+++` | Add the 'passing` parameter to /v1/health/service/serviceName. This pushes health check passing to the server. -|spring.cloud.consul.discovery.register | `+++true+++` | Register as a service in consul. -|spring.cloud.consul.discovery.register-health-check | `+++true+++` | Register health check in consul. Useful during development of a service. -|spring.cloud.consul.discovery.scheme | `+++http+++` | Whether to register an http or https service. -|spring.cloud.consul.discovery.server-list-query-tags | | Map of serviceId's -> tag to query for in server list. This allows filtering services by one more tags. Multiple tags can be specified with a comma separated value. -|spring.cloud.consul.discovery.service-name | | Service name. -|spring.cloud.consul.discovery.tags | | Tags to use when registering service. -|spring.cloud.consul.enabled | `+++true+++` | Is spring cloud consul enabled. -|spring.cloud.consul.host | `+++localhost+++` | Consul agent hostname. Defaults to 'localhost'. -|spring.cloud.consul.path | | Custom path if consul is under non-root. -|spring.cloud.consul.port | `+++8500+++` | Consul agent port. Defaults to '8500'. -|spring.cloud.consul.retry.enabled | `+++true+++` | If consul retry is enabled. -|spring.cloud.consul.retry.initial-interval | `+++1000+++` | Initial retry interval in milliseconds. -|spring.cloud.consul.retry.max-attempts | `+++6+++` | Maximum number of attempts. -|spring.cloud.consul.retry.max-interval | `+++2000+++` | Maximum interval for backoff. -|spring.cloud.consul.retry.multiplier | `+++1.1+++` | Multiplier for next interval. -|spring.cloud.consul.ribbon.enabled | `+++true+++` | Enables Consul and Ribbon integration. -|spring.cloud.consul.scheme | | Consul agent scheme (HTTP/HTTPS). If there is no scheme in address - client will use HTTP. -|spring.cloud.consul.service-registry.auto-registration.enabled | `+++true+++` | Enables Consul Service Registry Auto-registration. -|spring.cloud.consul.service-registry.enabled | `+++true+++` | Enables Consul Service Registry functionality. -|spring.cloud.consul.tls.certificate-password | | Password to open the certificate. -|spring.cloud.consul.tls.certificate-path | | File path to the certificate. -|spring.cloud.consul.tls.key-store-instance-type | | Type of key framework to use. -|spring.cloud.consul.tls.key-store-password | | Password to an external keystore. -|spring.cloud.consul.tls.key-store-path | | Path to an external keystore. - -|=== diff --git a/docs/modules/ROOT/pages/appendix.adoc b/docs/modules/ROOT/pages/appendix.adoc deleted file mode 100644 index eef1c905..00000000 --- a/docs/modules/ROOT/pages/appendix.adoc +++ /dev/null @@ -1,13 +0,0 @@ -:numbered!: -[appendix] -[[common-application-properties]] -= Common application properties -:page-section-summary-toc: 1 - - -Various properties can be specified inside your `application.properties` file, inside your `application.yml` file, or as command line switches. -This appendix provides a list of common {project-full-name} properties and references to the underlying classes that consume them. - -NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list. -Also, you can define your own properties. - diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc deleted file mode 100755 index e69de29b..00000000 diff --git a/docs/modules/ROOT/pages/intro.adoc b/docs/modules/ROOT/pages/intro.adoc deleted file mode 100644 index da721758..00000000 --- a/docs/modules/ROOT/pages/intro.adoc +++ /dev/null @@ -1,8 +0,0 @@ -This project provides Consul integrations for Spring Boot apps through autoconfiguration -and binding to the Spring Environment and other Spring programming model idioms. With a few -simple annotations you can quickly enable and configure the common patterns inside your -application and build large distributed systems with Consul based components. The -patterns provided include Service Discovery, Control Bus and Configuration. -Intelligent Routing and Client Side Load Balancing, Circuit Breaker -are provided by integration with other Spring Cloud projects. - diff --git a/docs/modules/ROOT/pages/quickstart.adoc b/docs/modules/ROOT/pages/quickstart.adoc deleted file mode 100644 index 3cee3161..00000000 --- a/docs/modules/ROOT/pages/quickstart.adoc +++ /dev/null @@ -1,229 +0,0 @@ -This quick start walks through using Spring Cloud Consul for Service Discovery and Distributed Configuration. - -First, run Consul Agent on your machine. Then you can access it and use it as a Service Registry and Configuration source with Spring Cloud Consul. - -[[discovery-client-usage]] -= Discovery Client Usage - -To use these features in an application, you can build it as a Spring Boot application that depends on `spring-cloud-consul-core`. -The most convenient way to add the dependency is with a Spring Boot starter: `org.springframework.cloud:spring-cloud-starter-consul-discovery`. -We recommend using dependency management and `spring-boot-starter-parent`. -The following example shows a typical Maven configuration: - -[source,xml,indent=0] -.pom.xml ----- - - - org.springframework.boot - spring-boot-starter-parent - {spring-boot-version} - - - - - - org.springframework.cloud - spring-cloud-starter-consul-discovery - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - ----- - -The following example shows a typical Gradle setup: - -[source,groovy,indent=0] -.build.gradle ----- -plugins { - id 'org.springframework.boot' version ${spring-boot-version} - id 'io.spring.dependency-management' version ${spring-dependency-management-version} - id 'java' -} - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery' - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } -} ----- - -Now you can create a standard Spring Boot application, such as the following HTTP server: - ----- -@SpringBootApplication -@RestController -public class Application { - - @GetMapping("/") - public String home() { - return "Hello World!"; - } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} ----- - -When this HTTP server runs, it connects to Consul Agent running at the default local 8500 port. -To modify the startup behavior, you can change the location of Consul Agent by using `application.properties`, as shown in the following example: - ----- -spring: - cloud: - consul: - host: localhost - port: 8500 ----- - -You can now use `DiscoveryClient`, `@LoadBalanced RestTemplate`, or `@LoadBalanced WebClient.Builder` to retrieve services and instances data from Consul, as shown in the following example: - -[source,java,indent=0] ----- -@Autowired -private DiscoveryClient discoveryClient; - -public String serviceUrl() { - List list = discoveryClient.getInstances("STORES"); - if (list != null && list.size() > 0 ) { - return list.get(0).getUri().toString(); - } - return null; -} ----- - -[[distributed-configuration-usage]] -= Distributed Configuration Usage - -To use these features in an application, you can build it as a Spring Boot application that depends on `spring-cloud-consul-core` and `spring-cloud-consul-config`. -The most convenient way to add the dependency is with a Spring Boot starter: `org.springframework.cloud:spring-cloud-starter-consul-config`. -We recommend using dependency management and `spring-boot-starter-parent`. -The following example shows a typical Maven configuration: - -[source,xml,indent=0] -.pom.xml ----- - - - org.springframework.boot - spring-boot-starter-parent - {spring-boot-version} - - - - - - org.springframework.cloud - spring-cloud-starter-consul-config - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - ----- - -The following example shows a typical Gradle setup: - -[source,groovy,indent=0] -.build.gradle ----- -plugins { - id 'org.springframework.boot' version ${spring-boot-version} - id 'io.spring.dependency-management' version ${spring-dependency-management-version} - id 'java' -} - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.springframework.cloud:spring-cloud-starter-consul-config' - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } -} ----- - -Now you can create a standard Spring Boot application, such as the following HTTP server: - ----- -@SpringBootApplication -@RestController -public class Application { - - @GetMapping("/") - public String home() { - return "Hello World!"; - } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} ----- - -The application retrieves configuration data from Consul. - -WARNING: If you use Spring Cloud Consul Config, you need to set the `spring.config.import` property in order to bind to Consul. -You can read more about it in the xref:spring-cloud-consul/config.adoc#config-data-import[Spring Boot Config Data Import section]. diff --git a/docs/modules/ROOT/pages/sagan-boot.adoc b/docs/modules/ROOT/pages/sagan-boot.adoc deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/modules/ROOT/pages/sagan-index.adoc b/docs/modules/ROOT/pages/sagan-index.adoc deleted file mode 100644 index b1203b9c..00000000 --- a/docs/modules/ROOT/pages/sagan-index.adoc +++ /dev/null @@ -1,39 +0,0 @@ -Spring Cloud Consul provides http://consul.io[Consul] integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. With a few simple annotations you can quickly enable and configure the common patterns inside your application and build large distributed systems with Hashicorp's Consul. The patterns provided include Service Discovery, Distributed Configuration and Control Bus. - -## Features - -Spring Cloud Consul features: - -* Service Discovery: instances can be registered with the Consul agent and clients can discover the instances using Spring-managed beans - * Supports Spring Cloud LoadBalancer - a client side load-balancer provided by the Spring Cloud project - * Supports Spring Cloud Gateway, a dynamic router and filter -* Distributed Configuration: using the Consul Key/Value store -* Control Bus: Distributed control events using Consul Events - -## Quick Start - -As long as Spring Cloud Consul and the Consul API are on the -classpath any Spring Boot application with `@EnableDiscoveryClient` will try to contact a Consul -agent on `localhost:8500` (the default values of -`spring.cloud.consul.host` and `spring.cloud.consul.port` respectively): - -```java -@Configuration -@EnableAutoConfiguration -@EnableDiscoveryClient -@RestController -public class Application { - - @RequestMapping("/") - public String home() { - return "Hello World"; - } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} -``` - -A local Consul agent must be running. See the https://consul.io/docs/agent/basics.html[Consul agent documentation] on how to run an agent. diff --git a/docs/modules/ROOT/pages/spring-cloud-consul.adoc b/docs/modules/ROOT/pages/spring-cloud-consul.adoc deleted file mode 100644 index 0f725839..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul.adoc +++ /dev/null @@ -1,7 +0,0 @@ -[[spring-cloud-consul]] -= Spring Cloud Consul -:page-section-summary-toc: 1 - -*{spring-cloud-version}* - - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/agent.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/agent.adoc deleted file mode 100644 index d7fec47c..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/agent.adoc +++ /dev/null @@ -1,12 +0,0 @@ -[[spring-cloud-consul-agent]] -= Consul Agent -:page-section-summary-toc: 1 - -A Consul Agent client must be available to all Spring Cloud Consul applications. By default, the Agent client is expected to be at `localhost:8500`. See the https://consul.io/docs/agent/basics.html[Agent documentation] for specifics on how to start an Agent client and how to connect to a cluster of Consul Agent Servers. For development, after you have installed consul, you may start a Consul Agent using the following command: - ----- -./src/main/bash/local_run_consul.sh ----- - -This will start an agent in server mode on port 8500, with the ui available at http://localhost:8500 - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/bus.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/bus.adoc deleted file mode 100644 index 964e3175..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/bus.adoc +++ /dev/null @@ -1,11 +0,0 @@ -[[spring-cloud-consul-bus]] -= Spring Cloud Bus with Consul -:page-section-summary-toc: 1 - -[[how-to-activate]] -== How to activate - -To get started with the Consul Bus use the starter with group `org.springframework.cloud` and artifact id `spring-cloud-starter-consul-bus`. See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train. - -See the https://cloud.spring.io/spring-cloud-bus/[Spring Cloud Bus] documentation for the available actuator endpoints and howto send custom messages. - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/config.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/config.adoc deleted file mode 100644 index c8774023..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/config.adoc +++ /dev/null @@ -1,156 +0,0 @@ -[[spring-cloud-consul-config]] -= Distributed Configuration with Consul - -Consul provides a https://consul.io/docs/agent/http/kv.html[Key/Value Store] for storing configuration and other metadata. Spring Cloud Consul Config is an alternative to the https://github.com/spring-cloud/spring-cloud-config[Config Server and Client]. Configuration is loaded into the Spring Environment during the special "bootstrap" phase. Configuration is stored in the `/config` folder by default. Multiple `PropertySource` instances are created based on the application's name and the active profiles that mimics the Spring Cloud Config order of resolving properties. For example, an application with the name "testApp" and with the "dev" profile will have the following property sources created: - ----- -config/testApp,dev/ -config/testApp/ -config/application,dev/ -config/application/ ----- - -The most specific property source is at the top, with the least specific at the bottom. Properties in the `config/application` folder are applicable to all applications using consul for configuration. Properties in the `config/testApp` folder are only available to the instances of the service named "testApp". - -Configuration is currently read on startup of the application. Sending a HTTP POST to `/refresh` will cause the configuration to be reloaded. xref:spring-cloud-consul/config.adoc#spring-cloud-consul-config-watch[Config Watch] will also automatically detect changes and reload the application context. - -[[how-to-activate]] -== How to activate - -To get started with Consul Configuration use the starter with group `org.springframework.cloud` and artifact id `spring-cloud-starter-consul-config`. See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train. - - -[[config-data-import]] -== Spring Boot Config Data Import - -Spring Boot 2.4 introduced a new way to import configuration data via the `spring.config.import` property. This is now the default way to get configuration from Consul. - -To optionally connect to Consul set the following in application.properties: - -.application.properties -[source,properties] ----- -spring.config.import=optional:consul: ----- - -This will connect to the Consul Agent at the default location of "http://localhost:8500". Removing the `optional:` prefix will cause Consul Config to fail if it is unable to connect to Consul. To change the connection properties of Consul Config either set `spring.cloud.consul.host` and `spring.cloud.consul.port` or add the host/port pair to the `spring.config.import` statement such as, `spring.config.import=optional:consul:myhost:8500`. The location in the import property has precedence over the host and port propertie. - -Consul Config will try to load values from four automatic contexts based on `spring.cloud.consul.config.name` (which defaults to the value of the `spring.application.name` property) and `spring.cloud.consul.config.default-context` (which defaults to `application`). If you want to specify the contexts rather than using the computed ones, you can add that information to the `spring.config.import` statement. - -.application.properties -[source,properties] ----- -spring.config.import=optional:consul:myhost:8500/contextone;/context/two ----- - -This will optionally load configuration only from `/contextone` and `/context/two`. - -NOTE: A `bootstrap` file (properties or yaml) is *not* needed for the Spring Boot Config Data method of import via `spring.config.import`. - -[[customizing]] -== Customizing - -Consul Config may be customized using the following properties: - -[source,yaml] ----- -spring: - cloud: - consul: - config: - enabled: true - prefix: configuration - defaultContext: apps - profileSeparator: '::' ----- - -CAUTION: If you have set `spring.cloud.bootstrap.enabled=true` or `spring.config.use-legacy-processing=true`, or included `spring-cloud-starter-bootstrap`, then the above values will need to be placed in `bootstrap.yml` instead of `application.yml`. - -* `enabled` setting this value to "false" disables Consul Config -* `prefix` sets the base folder for configuration values -* `defaultContext` sets the folder name used by all applications -* `profileSeparator` sets the value of the separator used to separate the profile name in property sources with profiles - -[[spring-cloud-consul-config-watch]] -== Config Watch - -The Consul Config Watch takes advantage of the ability of consul to https://www.consul.io/docs/agent/watches.html#keyprefix[watch a key prefix]. The Config Watch makes a blocking Consul HTTP API call to determine if any relevant configuration data has changed for the current application. If there is new configuration data a Refresh Event is published. This is equivalent to calling the `/refresh` actuator endpoint. - -To change the frequency of when the Config Watch is called change `spring.cloud.consul.config.watch.delay`. The default value is 1000, which is in milliseconds. The delay is the amount of time after the end of the previous invocation and the start of the next. - -To disable the Config Watch set `spring.cloud.consul.config.watch.enabled=false`. - -The watch uses a Spring `TaskScheduler` to schedule the call to consul. By default it is a `ThreadPoolTaskScheduler` with a `poolSize` of 1. To change the `TaskScheduler`, create a bean of type `TaskScheduler` named with the `ConsulConfigAutoConfiguration.CONFIG_WATCH_TASK_SCHEDULER_NAME` constant. - -[[spring-cloud-consul-config-format]] -== YAML or Properties with Config - -It may be more convenient to store a blob of properties in YAML or Properties format as opposed to individual key/value pairs. Set the `spring.cloud.consul.config.format` property to `YAML` or `PROPERTIES`. For example to use YAML: - -[source,yaml] ----- -spring: - cloud: - consul: - config: - format: YAML ----- - -CAUTION: If you have set `spring.cloud.bootstrap.enabled=true` or `spring.config.use-legacy-processing=true`, or included `spring-cloud-starter-bootstrap`, then the above values will need to be placed in `bootstrap.yml` instead of `application.yml`. - -YAML must be set in the appropriate `data` key in consul. Using the defaults above the keys would look like: - ----- -config/testApp,dev/data -config/testApp/data -config/application,dev/data -config/application/data ----- - -You could store a YAML document in any of the keys listed above. - -You can change the data key using `spring.cloud.consul.config.data-key`. - -[[spring-cloud-consul-config-git2consul]] -== git2consul with Config -git2consul is a Consul community project that loads files from a git repository to individual keys into Consul. By default the names of the keys are names of the files. YAML and Properties files are supported with file extensions of `.yml` and `.properties` respectively. Set the `spring.cloud.consul.config.format` property to `FILES`. For example: - -.bootstrap.yml ----- -spring: - cloud: - consul: - config: - format: FILES ----- - -Given the following keys in `/config`, the `development` profile and an application name of `foo`: - ----- -.gitignore -application.yml -bar.properties -foo-development.properties -foo-production.yml -foo.properties -master.ref ----- - -the following property sources would be created: - ----- -config/foo-development.properties -config/foo.properties -config/application.yml ----- - -The value of each key needs to be a properly formatted YAML or Properties file. - - -[[spring-cloud-consul-failfast]] -== Fail Fast - -It may be convenient in certain circumstances (like local development or certain test scenarios) to not fail if consul isn't available for configuration. Setting `spring.cloud.consul.config.fail-fast=false` will cause the configuration module to log a warning rather than throw an exception. This will allow the application to continue startup normally. - -CAUTION: If you have set `spring.cloud.bootstrap.enabled=true` or `spring.config.use-legacy-processing=true`, or included `spring-cloud-starter-bootstrap`, then the above values will need to be placed in `bootstrap.yml` instead of `application.yml`. - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/configuration-properties.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/configuration-properties.adoc deleted file mode 100644 index a3a01e7a..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/configuration-properties.adoc +++ /dev/null @@ -1,5 +0,0 @@ -[[configuration-properties]] -= Configuration Properties -:page-section-summary-toc: 1 - -To see the list of all Consul related configuration properties please check link:appendix.html[the Appendix page]. diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/discovery.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/discovery.adoc deleted file mode 100644 index 38558ebe..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/discovery.adoc +++ /dev/null @@ -1,402 +0,0 @@ -[[spring-cloud-consul-discovery]] -= Service Discovery with Consul - -Service Discovery is one of the key tenets of a microservice based architecture. Trying to hand configure each client or some form of convention can be very difficult to do and can be very brittle. Consul provides Service Discovery services via an https://www.consul.io/docs/agent/http.html[HTTP API] and https://www.consul.io/docs/agent/dns.html[DNS]. Spring Cloud Consul leverages the HTTP API for service registration and discovery. This does not prevent non-Spring Cloud applications from leveraging the DNS interface. Consul Agents servers are run in a https://www.consul.io/docs/internals/architecture.html[cluster] that communicates via a https://www.consul.io/docs/internals/gossip.html[gossip protocol] and uses the https://www.consul.io/docs/internals/consensus.html[Raft consensus protocol]. - -[[how-to-activate]] -== How to activate - -To activate Consul Service Discovery use the starter with group `org.springframework.cloud` and artifact id `spring-cloud-starter-consul-discovery`. See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train. - -[[registering-with-consul]] -== Registering with Consul - -When a client registers with Consul, it provides meta-data about itself such as host and port, id, name and tags. An https://www.consul.io/docs/discovery/checks#http-interval[HTTP Check] is created by default that Consul hits the `/actuator/health` endpoint every 10 seconds. If the health check fails, the service instance is marked as critical. - -Example Consul client: - -[source,java,indent=0] ----- -@SpringBootApplication -@RestController -public class Application { - - @RequestMapping("/") - public String home() { - return "Hello world"; - } - - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).web(true).run(args); - } - -} ----- - -(i.e. utterly normal Spring Boot app). If the Consul client is located somewhere other than `localhost:8500`, the configuration is required to locate the client. Example: - -.application.yml ----- -spring: - cloud: - consul: - host: localhost - port: 8500 ----- - -CAUTION: If you use xref:spring-cloud-consul/config.adoc[Spring Cloud Consul Config], and you have set `spring.cloud.bootstrap.enabled=true` or `spring.config.use-legacy-processing=true` or use `spring-cloud-starter-bootstrap`, then the above values will need to be placed in `bootstrap.yml` instead of `application.yml`. - -The default service name, instance id and port, taken from the `Environment`, are `${spring.application.name}`, the Spring Context ID and `${server.port}` respectively. - -To disable the Consul Discovery Client you can set `spring.cloud.consul.discovery.enabled` to `false`. Consul Discovery Client will also be disabled when `spring.cloud.discovery.enabled` is set to `false`. - -To disable the service registration you can set `spring.cloud.consul.discovery.register` to `false`. - -[[registering-management-as-a-separate-service]] -=== Registering Management as a Separate Service - -When management server port is set to something different than the application port, by setting `management.server.port` property, management service will be registered as a separate service than the application service. For example: - -.application.yml ----- -spring: - application: - name: myApp -management: - server: - port: 4452 ----- - -Above configuration will register following 2 services: - -* Application Service: - ----- -ID: myApp -Name: myApp ----- - -* Management Service: - ----- -ID: myApp-management -Name: myApp-management ----- - -Management service will inherit its `instanceId` and `serviceName` from the application service. For example: - -.application.yml ----- -spring: - application: - name: myApp -management: - server: - port: 4452 -spring: - cloud: - consul: - discovery: - instance-id: custom-service-id - serviceName: myprefix-${spring.application.name} ----- - -Above configuration will register following 2 services: - -* Application Service: - ----- -ID: custom-service-id -Name: myprefix-myApp ----- - -* Management Service: - ----- -ID: custom-service-id-management -Name: myprefix-myApp-management ----- - -Further customization is possible via following properties: - ----- -/** Port to register the management service under (defaults to management port) */ -spring.cloud.consul.discovery.management-port - -/** Suffix to use when registering management service (defaults to "management") */ -spring.cloud.consul.discovery.management-suffix - -/** Tags to use when registering management service (defaults to "management") */ -spring.cloud.consul.discovery.management-tags ----- - -[[http-health-check]] -=== HTTP Health Check - -The health check for a Consul instance defaults to "/actuator/health", which is the default location of the health endpoint in a Spring Boot Actuator application. You need to change this, even for an Actuator application, if you use a non-default context path or servlet path (e.g. `server.servletPath=/foo`) or management endpoint path (e.g. `management.server.servlet.context-path=/admin`). - -The interval that Consul uses to check the health endpoint may also be configured. "10s" and "1m" represent 10 seconds and 1 minute respectively. - -This example illustrates the above (see the `spring.cloud.consul.discovery.health-check-*` properties in link:appendix.html[the appendix page] for more options). - -.application.yml ----- -spring: - cloud: - consul: - discovery: - healthCheckPath: ${management.server.servlet.context-path}/actuator/health - healthCheckInterval: 15s ----- - -You can disable the HTTP health check entirely by setting `spring.cloud.consul.discovery.register-health-check=false`. - -[[applying-headers]] -==== Applying Headers -Headers can be applied to health check requests. For example, if you're trying to register a https://cloud.spring.io/spring-cloud-config/[Spring Cloud Config] server that uses https://github.com/spring-cloud/spring-cloud-config/blob/master/docs/src/main/asciidoc/spring-cloud-config.adoc#vault-backend[Vault Backend]: - -.application.yml ----- -spring: - cloud: - consul: - discovery: - health-check-headers: - X-Config-Token: 6442e58b-d1ea-182e-cfa5-cf9cddef0722 ----- - -According to the HTTP standard, each header can have more than one values, in which case, an array can be supplied: - -.application.yml ----- -spring: - cloud: - consul: - discovery: - health-check-headers: - X-Config-Token: - - "6442e58b-d1ea-182e-cfa5-cf9cddef0722" - - "Some other value" ----- - -[[ttl-health-check]] -=== TTL Health Check - -A Consul https://www.consul.io/docs/discovery/checks#ttl[TTL Check] can be used instead of the default configured HTTP check. -The main difference is that the application sends a heartbeat signal to the Consul agent rather than the Consul agent sending a request to the application. - -The interval the application uses to send the ping may also be configured. "10s" and "1m" represent 10 seconds and 1 minute respectively. -The default is 30 seconds. - -This example illustrates the above (see the `spring.cloud.consul.discovery.heartbeat.*` properties in link:appendix.html[the appendix page] for more options). - -.application.yml ----- -spring: - cloud: - consul: - discovery: - heartbeat: - enabled: true - ttl: 10s ----- - -[[ttl-application-status]] -==== TTL Application Status - -For a Spring Boot Actuator application the status is determined from its available health endpoint. -When the health endpoint is not available (either disabled or not a Spring Boot Actuator application) it assumes the application is in good health. - -When querying the health endpoint, the root https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-health-groups[health group] is used by default. -A different health group can be used by setting the following property: - -.application.yml ----- -spring: - cloud: - consul: - discovery: - heartbeat: - actuator-health-group: ----- - -You can disable the use of the health endpoint entirely by setting the following property: - -.application.yml ----- -spring: - cloud: - consul: - discovery: - heartbeat: - use-actuator-health: false ----- - -[[custom-ttl-application-status]] -===== Custom TTL Application Status - -If you want to configure your own application status mechanism, simply implement the `ApplicationStatusProvider` interface - -.MyCustomApplicationStatusProvider.java ----- -@Bean -public class MyCustomApplicationStatusProvider implements ApplicationStatusProvider { - public CheckStatus currentStatus() { - return yourMethodToDetermineAppStatusGoesHere(); - } -} ----- -and make it available to the application context: ----- -@Bean -public CustomApplicationStatusProvider customAppStatusProvider() { - return new MyCustomApplicationStatusProvider(); -} ----- - -[[actuator-health-indicators]] -=== Actuator Health Indicator(s) -If the service instance is a Spring Boot Actuator application, it may be provided the following Actuator health indicators. - -[[discoveryclienthealthindicator]] -==== DiscoveryClientHealthIndicator -When Consul Service Discovery is active, a https://cloud.spring.io/spring-cloud-commons/2.2.x/reference/html/#health-indicator[DiscoverClientHealthIndicator] is configured and made available to the Actuator health endpoint. -See https://cloud.spring.io/spring-cloud-commons/2.2.x/reference/html/#health-indicator[here] for configuration options. - -[[consulhealthindicator]] -==== ConsulHealthIndicator -An indicator is configured that verifies the health of the `ConsulClient`. - -By default, it retrieves the Consul leader node status and all registered services. -In deployments that have many registered services it may be costly to retrieve all services on every health check. -To skip the service retrieval and only check the leader node status set `spring.cloud.consul.health-indicator.include-services-query=false`. - -To disable the indicator set `management.health.consul.enabled=false`. - -WARNING: When the application runs in https://cloud.spring.io/spring-cloud-commons/2.2.x/reference/html/#the-bootstrap-application-context[bootstrap context mode] (the default), -this indicator is loaded into the bootstrap context and is not made available to the Actuator health endpoint. - -[[metadata]] -=== Metadata - -Consul supports metadata on services. Spring Cloud's `ServiceInstance` has a `Map metadata` field which is populated from a services `meta` field. To populate the `meta` field set values on `spring.cloud.consul.discovery.metadata` or `spring.cloud.consul.discovery.management-metadata` properties. - -.application.yml ----- -spring: - cloud: - consul: - discovery: - metadata: - myfield: myvalue - anotherfield: anothervalue ----- - -The above configuration will result in a service who's meta field contains `myfield->myvalue` and `anotherfield->anothervalue`. - -[[generated-metadata]] -==== Generated Metadata - -The Consul Auto Registration will generate a few entries automatically. - -.Auto Generated Metadata -|=== -| Key | Value - -| 'group' -| Property `spring.cloud.consul.discovery.instance-group`. This values is only generated if `instance-group` is not empty.' - -| 'secure' -| True if property `spring.cloud.consul.discovery.scheme` equals 'https', otherwise false. - -| Property `spring.cloud.consul.discovery.default-zone-metadata-name`, defaults to 'zone' -| Property `spring.cloud.consul.discovery.instance-zone`. This values is only generated if `instance-zone` is not empty.' - -|=== - -WARNING: Older versions of Spring Cloud Consul populated the `ServiceInstance.getMetadata()` method from Spring Cloud Commons by parsing the `spring.cloud.consul.discovery.tags` property. This is no longer supported, please migrate to using the `spring.cloud.consul.discovery.metadata` map. - -[[making-the-consul-instance-id-unique]] -=== Making the Consul Instance ID Unique - -By default a consul instance is registered with an ID that is equal to its Spring Application Context ID. By default, the Spring Application Context ID is `${spring.application.name}:comma,separated,profiles:${server.port}`. For most cases, this will allow multiple instances of one service to run on one machine. If further uniqueness is required, Using Spring Cloud you can override this by providing a unique identifier in `spring.cloud.consul.discovery.instanceId`. For example: - -.application.yml ----- -spring: - cloud: - consul: - discovery: - instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}} ----- - -With this metadata, and multiple service instances deployed on localhost, the random value will kick in there to make the instance unique. In Cloudfoundry the `vcap.application.instance_id` will be populated automatically in a Spring Boot application, so the random value will not be needed. - -[[looking-up-services]] -== Looking up services - -[[using-load-balancer]] -=== Using Load-balancer - -Spring Cloud has support for https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign[Feign] (a REST client builder) and also https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#rest-template-loadbalancer-client[Spring `RestTemplate`] -for looking up services using the logical service names/ids instead of physical URLs. Both Feign and the discovery-aware RestTemplate utilize https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#spring-cloud-loadbalancer[Spring Cloud LoadBalancer] for client-side load balancing. - -If you want to access service STORES using the RestTemplate simply declare: - ----- -@LoadBalanced -@Bean -public RestTemplate loadbalancedRestTemplate() { - return new RestTemplate(); -} ----- - -and use it like this (notice how we use the STORES service name/id from Consul instead of a fully qualified domainname): - ----- -@Autowired -RestTemplate restTemplate; - -public String getFirstProduct() { - return this.restTemplate.getForObject("https://STORES/products/1", String.class); -} ----- - -If you have Consul clusters in multiple datacenters and you want to access a service in another datacenter a service name/id alone is not enough. In that case -you use property `spring.cloud.consul.discovery.datacenters.STORES=dc-west` where `STORES` is the service name/id and `dc-west` is the datacenter -where the STORES service lives. - -TIP: Spring Cloud now also offers support for -https://cloud.spring.io/spring-cloud-commons/reference/html/#_spring_resttemplate_as_a_load_balancer_client[Spring Cloud LoadBalancer]. - - -[[using-the-discoveryclient]] -=== Using the DiscoveryClient - -You can also use the `org.springframework.cloud.client.discovery.DiscoveryClient` which provides a simple API for discovery clients that is not specific to Netflix, e.g. - ----- -@Autowired -private DiscoveryClient discoveryClient; - -public String serviceUrl() { - List list = discoveryClient.getInstances("STORES"); - if (list != null && list.size() > 0 ) { - return list.get(0).getUri(); - } - return null; -} ----- - -[[consul-catalog-watch]] -== Consul Catalog Watch - -The Consul Catalog Watch takes advantage of the ability of consul to https://www.consul.io/docs/agent/watches.html#services[watch services]. The Catalog Watch makes a blocking Consul HTTP API call to determine if any services have changed. If there is new service data a Heartbeat Event is published. - -To change the frequency of when the Config Watch is called change `spring.cloud.consul.config.discovery.catalog-services-watch-delay`. The default value is 1000, which is in milliseconds. The delay is the amount of time after the end of the previous invocation and the start of the next. - -To disable the Catalog Watch set `spring.cloud.consul.discovery.catalogServicesWatch.enabled=false`. - - -The watch uses a Spring `TaskScheduler` to schedule the call to consul. By default it is a `ThreadPoolTaskScheduler` with a `poolSize` of 1. To change the `TaskScheduler`, create a bean of type `TaskScheduler` named with the `ConsulDiscoveryClientConfiguration.CATALOG_WATCH_TASK_SCHEDULER_NAME` constant. - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/hystrix.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/hystrix.adoc deleted file mode 100644 index b7696493..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/hystrix.adoc +++ /dev/null @@ -1,7 +0,0 @@ -[[spring-cloud-consul-hystrix]] -= Circuit Breaker with Hystrix -:page-section-summary-toc: 1 - -Applications can use the Hystrix Circuit Breaker provided by the Spring Cloud Netflix project by including this starter in the projects pom.xml: `spring-cloud-starter-hystrix`. Hystrix doesn't depend on the Netflix Discovery Client. The `@EnableHystrix` annotation should be placed on a configuration class (usually the main class). Then methods can be annotated with `@HystrixCommand` to be protected by a circuit breaker. See https://projects.spring.io/spring-cloud/spring-cloud.html#_circuit_breaker_hystrix_clients[the documentation] for more details. - - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/install.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/install.adoc deleted file mode 100644 index 04978a07..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/install.adoc +++ /dev/null @@ -1,6 +0,0 @@ -[[spring-cloud-consul-install]] -= Install Consul -:page-section-summary-toc: 1 - -Please see the https://www.consul.io/intro/getting-started/install.html[installation documentation] for instructions on how to install Consul. - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/quick-start.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/quick-start.adoc deleted file mode 100644 index 59e05139..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/quick-start.adoc +++ /dev/null @@ -1,6 +0,0 @@ -[[quick-start]] -= Quick Start -:page-section-summary-toc: 1 - -include:../:quickstart.adoc[] - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/retry.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/retry.adoc deleted file mode 100644 index 8de49a4e..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/retry.adoc +++ /dev/null @@ -1,16 +0,0 @@ -[[spring-cloud-consul-retry]] -= Consul Retry -:page-section-summary-toc: 1 - -If you expect that the consul agent may occasionally be unavailable when -your app starts, you can ask it to keep trying after a failure. You need to add -`spring-retry` and `spring-boot-starter-aop` to your classpath. The default -behaviour is to retry 6 times with an initial backoff interval of 1000ms and an -exponential multiplier of 1.1 for subsequent backoffs. You can configure these -properties (and others) using `spring.cloud.consul.retry.*` configuration properties. -This works with both Spring Cloud Consul Config and Discovery registration. - -TIP: To take full control of the retry add a `@Bean` of type -`RetryOperationsInterceptor` with id "consulRetryInterceptor". Spring -Retry has a `RetryInterceptorBuilder` that makes it easy to create one. - diff --git a/docs/modules/ROOT/pages/spring-cloud-consul/turbine.adoc b/docs/modules/ROOT/pages/spring-cloud-consul/turbine.adoc deleted file mode 100644 index fe3168dd..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-consul/turbine.adoc +++ /dev/null @@ -1,42 +0,0 @@ -[[spring-cloud-consul-turbine]] -= Hystrix metrics aggregation with Turbine and Consul - -Turbine (provided by the Spring Cloud Netflix project), aggregates multiple instances Hystrix metrics streams, so the dashboard can display an aggregate view. Turbine uses the `DiscoveryClient` interface to lookup relevant instances. To use Turbine with Spring Cloud Consul, configure the Turbine application in a manner similar to the following examples: - -.pom.xml ----- - - org.springframework.cloud - spring-cloud-netflix-turbine - - - org.springframework.cloud - spring-cloud-starter-consul-discovery - ----- - -Notice that the Turbine dependency is not a starter. The turbine starter includes support for Netflix Eureka. - -.application.yml ----- -spring.application.name: turbine -applications: consulhystrixclient -turbine: - aggregator: - clusterConfig: ${applications} - appConfig: ${applications} ----- - -The `clusterConfig` and `appConfig` sections must match, so it's useful to put the comma-separated list of service ID's into a separate configuration property. - -.Turbine.java ----- -@EnableTurbine -@SpringBootApplication -public class Turbine { - public static void main(String[] args) { - SpringApplication.run(DemoturbinecommonsApplication.class, args); - } -} ----- - diff --git a/docs/pom.xml b/docs/pom.xml deleted file mode 100644 index 81de2496..00000000 --- a/docs/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-consul - 4.1.0-SNAPSHOT - - spring-cloud-consul-docs - jar - Spring Cloud Consul Docs - Spring Cloud Docs - - spring-cloud-consul - ${basedir}/.. - spring.cloud.consul.* - deploy - - none - - - - ${project.groupId} - spring-cloud-starter-consul - - - ${project.groupId} - spring-cloud-starter-consul-all - - - - src/main/asciidoc - - - - docs - - - - pl.project13.maven - git-commit-id-plugin - - - org.codehaus.mojo - exec-maven-plugin - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.maven.plugins - maven-resources-plugin - - - org.asciidoctor - asciidoctor-maven-plugin - - - org.apache.maven.plugins - maven-antrun-plugin - - - maven-deploy-plugin - - - - - - diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh deleted file mode 100755 index d18aa88d..00000000 --- a/docs/src/main/asciidoc/ghpages.sh +++ /dev/null @@ -1,330 +0,0 @@ -#!/bin/bash -x - -set -e - -# Set default props like MAVEN_PATH, ROOT_FOLDER etc. -function set_default_props() { - # The script should be run from the root folder - ROOT_FOLDER=`pwd` - echo "Current folder is ${ROOT_FOLDER}" - - if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - echo "You're not in the root folder of the project!" - exit 1 - fi - - # Prop that will let commit the changes - COMMIT_CHANGES="no" - MAVEN_PATH=${MAVEN_PATH:-} - echo "Path to Maven is [${MAVEN_PATH}]" - REPO_NAME=${PWD##*/} - echo "Repo name is [${REPO_NAME}]" - SPRING_CLOUD_STATIC_REPO=${SPRING_CLOUD_STATIC_REPO:-git@github.com:spring-cloud/spring-cloud-static.git} - echo "Spring Cloud Static repo is [${SPRING_CLOUD_STATIC_REPO}" -} - -# Check if gh-pages exists and docs have been built -function check_if_anything_to_sync() { - git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'` - - if ! (git remote set-branches --add origin gh-pages && git fetch -q); then - echo "No gh-pages, so not syncing" - exit 0 - fi - - if ! [ -d docs/target/generated-docs ] && ! [ "${BUILD}" == "yes" ]; then - echo "No gh-pages sources in docs/target/generated-docs, so not syncing" - exit 0 - fi -} - -function retrieve_current_branch() { - # Code getting the name of the current branch. For master we want to publish as we did until now - # https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch - # If there is a branch already passed will reuse it - otherwise will try to find it - CURRENT_BRANCH=${BRANCH} - if [[ -z "${CURRENT_BRANCH}" ]] ; then - CURRENT_BRANCH=$(git symbolic-ref -q HEAD) - CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} - CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} - fi - echo "Current branch is [${CURRENT_BRANCH}]" - git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" -} - -# Switches to the provided value of the release version. We always prefix it with `v` -function switch_to_tag() { - git checkout v${VERSION} -} - -# Build the docs if switch is on -function build_docs_if_applicable() { - if [[ "${BUILD}" == "yes" ]] ; then - ./mvnw clean install -P docs -pl docs -DskipTests - fi -} - -# Get the name of the `docs.main` property -# Get allowed branches - assumes that a `docs` module is available under `docs` profile -function retrieve_doc_properties() { - MAIN_ADOC_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args='${docs.main}' \ - --non-recursive \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec) - echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" - - - ALLOW_PROPERTY=${ALLOW_PROPERTY:-"docs.allowed.branches"} - ALLOWED_BRANCHES_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args="\${${ALLOW_PROPERTY}}" \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ - -P docs \ - -pl docs) - echo "Extracted '${ALLOW_PROPERTY}' from Maven build [${ALLOWED_BRANCHES_VALUE}]" -} - -# Stash any outstanding changes -function stash_changes() { - git diff-index --quiet HEAD && dirty=$? || (echo "Failed to check if the current repo is dirty. Assuming that it is." && dirty="1") - if [ "$dirty" != "0" ]; then git stash; fi -} - -# Switch to gh-pages branch to sync it with current branch -function add_docs_from_target() { - local DESTINATION_REPO_FOLDER - if [[ -z "${DESTINATION}" && -z "${CLONE}" ]] ; then - DESTINATION_REPO_FOLDER=${ROOT_FOLDER} - elif [[ "${CLONE}" == "yes" ]]; then - mkdir -p ${ROOT_FOLDER}/target - local clonedStatic=${ROOT_FOLDER}/target/spring-cloud-static - if [[ ! -e "${clonedStatic}/.git" ]]; then - echo "Cloning Spring Cloud Static to target" - git clone ${SPRING_CLOUD_STATIC_REPO} ${clonedStatic} && git checkout gh-pages - else - echo "Spring Cloud Static already cloned - will pull changes" - cd ${clonedStatic} && git checkout gh-pages && git pull origin gh-pages - fi - DESTINATION_REPO_FOLDER=${clonedStatic}/${REPO_NAME} - mkdir -p ${DESTINATION_REPO_FOLDER} - else - if [[ ! -e "${DESTINATION}/.git" ]]; then - echo "[${DESTINATION}] is not a git repository" - exit 1 - fi - DESTINATION_REPO_FOLDER=${DESTINATION}/${REPO_NAME} - mkdir -p ${DESTINATION_REPO_FOLDER} - echo "Destination was provided [${DESTINATION}]" - fi - cd ${DESTINATION_REPO_FOLDER} - git checkout gh-pages - git pull origin gh-pages - - # Add git branches - ################################################################### - if [[ -z "${VERSION}" ]] ; then - copy_docs_for_current_version - else - copy_docs_for_provided_version - fi - commit_changes_if_applicable -} - - -# Copies the docs by using the retrieved properties from Maven build -function copy_docs_for_current_version() { - if [[ "${CURRENT_BRANCH}" == "master" ]] ; then - echo -e "Current branch is master - will copy the current docs only to the root folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - cp -rf $f ${ROOT_FOLDER}/ - git add -A ${ROOT_FOLDER}/$file - fi - done - COMMIT_CHANGES="yes" - else - echo -e "Current branch is [${CURRENT_BRANCH}]" - # https://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin - if [[ ",${ALLOWED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then - mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} - echo -e "Branch [${CURRENT_BRANCH}] is allowed! Will copy the current docs to the [${CURRENT_BRANCH}] folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - else - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH} - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/$file - fi - fi - done - COMMIT_CHANGES="yes" - else - echo -e "Branch [${CURRENT_BRANCH}] is not on the allow list! Check out the Maven [${ALLOW_PROPERTY}] property in - [docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch." - fi - fi -} - -# Copies the docs by using the explicitly provided version -function copy_docs_for_provided_version() { - local FOLDER=${DESTINATION_REPO_FOLDER}/${VERSION} - mkdir -p ${FOLDER} - echo -e "Current tag is [v${VERSION}] Will copy the current docs to the [${FOLDER}] folder" - for f in ${ROOT_FOLDER}/docs/target/generated-docs/*; do - file=${f#${ROOT_FOLDER}/docs/target/generated-docs/*} - copy_docs_for_branch ${file} ${FOLDER} - done - COMMIT_CHANGES="yes" - CURRENT_BRANCH="v${VERSION}" -} - -# Copies the docs from target to the provided destination -# Params: -# $1 - file from target -# $2 - destination to which copy the files -function copy_docs_for_branch() { - local file=$1 - local destination=$2 - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^${file}$; then - # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ ("${file}" == "${MAIN_ADOC_VALUE}.html") || ("${file}" == "${REPO_NAME}.html") ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${destination}/index.html - git add -A ${destination}/index.html - else - cp -rf $f ${destination} - git add -A ${destination}/$file - fi - fi -} - -function commit_changes_if_applicable() { - if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then - COMMIT_SUCCESSFUL="no" - git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" && COMMIT_SUCCESSFUL="yes" || echo "Failed to commit changes" - - # Uncomment the following push if you want to auto push to - # the gh-pages branch whenever you commit to master locally. - # This is a little extreme. Use with care! - ################################################################### - if [[ "${COMMIT_SUCCESSFUL}" == "yes" ]] ; then - git push origin gh-pages - fi - fi -} - -# Switch back to the previous branch and exit block -function checkout_previous_branch() { - # If -version was provided we need to come back to root project - cd ${ROOT_FOLDER} - git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" - if [ "$dirty" != "0" ]; then git stash pop; fi - exit 0 -} - -# Assert if properties have been properly passed -function assert_properties() { -echo "VERSION [${VERSION}], DESTINATION [${DESTINATION}], CLONE [${CLONE}]" -if [[ "${VERSION}" != "" && (-z "${DESTINATION}" && -z "${CLONE}") ]] ; then echo "Version was set but destination / clone was not!"; exit 1;fi -if [[ ("${DESTINATION}" != "" && "${CLONE}" != "") && -z "${VERSION}" ]] ; then echo "Destination / clone was set but version was not!"; exit 1;fi -if [[ "${DESTINATION}" != "" && "${CLONE}" == "yes" ]] ; then echo "Destination and clone was set. Pick one!"; exit 1;fi -} - -# Prints the usage -function print_usage() { -cat </` -- if the destination switch is passed (-d) then the script will check if the provided dir is a git repo and then will - switch to gh-pages of that repo and copy the generated docs to `docs//` - -USAGE: - -You can use the following options: - --v|--version - the script will apply the whole procedure for a particular library version --d|--destination - the root of destination folder where the docs should be copied. You have to use the full path. - E.g. point to spring-cloud-static folder. Can't be used with (-c) --b|--build - will run the standard build process after checking out the branch --c|--clone - will automatically clone the spring-cloud-static repo instead of providing the destination. - Obviously can't be used with (-d) - -EOF -} - - -# ========================================== -# ____ ____ _____ _____ _____ _______ -# / ____|/ ____| __ \|_ _| __ \__ __| -# | (___ | | | |__) | | | | |__) | | | -# \___ \| | | _ / | | | ___/ | | -# ____) | |____| | \ \ _| |_| | | | -# |_____/ \_____|_| \_\_____|_| |_| -# -# ========================================== - -while [[ $# > 0 ]] -do -key="$1" -case ${key} in - -v|--version) - VERSION="$2" - shift # past argument - ;; - -d|--destination) - DESTINATION="$2" - shift # past argument - ;; - -b|--build) - BUILD="yes" - ;; - -c|--clone) - CLONE="yes" - ;; - -h|--help) - print_usage - exit 0 - ;; - *) - echo "Invalid option: [$1]" - print_usage - exit 1 - ;; -esac -shift # past argument or value -done - -assert_properties -set_default_props -check_if_anything_to_sync -if [[ -z "${VERSION}" ]] ; then - retrieve_current_branch -else - switch_to_tag -fi -build_docs_if_applicable -retrieve_doc_properties -stash_changes -add_docs_from_target -checkout_previous_branch diff --git a/docs/src/main/asciidoc/images/.gitkeep b/docs/src/main/asciidoc/images/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/mvnw b/mvnw index 8b9da3b8..41c0f0c2 100755 --- a/mvnw +++ b/mvnw @@ -8,7 +8,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -114,7 +114,6 @@ if $mingw ; then M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -212,7 +211,11 @@ else if [ "$MVNW_VERBOSE" = true ]; then echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." fi - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi while IFS="=" read key value; do case "$key" in (wrapperUrl) jarUrl="$value"; break ;; esac @@ -221,22 +224,38 @@ else echo "Downloading from: $jarUrl" fi wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi if command -v wget > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found wget ... using wget" fi - wget "$jarUrl" -O "$wrapperJarPath" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi elif command -v curl > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found curl ... using curl" fi - curl -o "$wrapperJarPath" "$jarUrl" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + else if [ "$MVNW_VERBOSE" = true ]; then echo "Falling back to using Java to download" fi javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi if [ -e "$javaClass" ]; then if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then if [ "$MVNW_VERBOSE" = true ]; then @@ -277,6 +296,11 @@ if $cygwin; then MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ diff --git a/mvnw.bat b/mvnw.bat deleted file mode 100644 index 9969c02d..00000000 --- a/mvnw.bat +++ /dev/null @@ -1,177 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:chkMHome -if not "%M2_HOME%"=="" goto valMHome - -SET "M2_HOME=%~dp0.." -if not "%M2_HOME%"=="" goto valMHome - -echo. -echo Error: M2_HOME not found in your environment. >&2 -echo Please set the M2_HOME variable in your environment to match the >&2 -echo location of the Maven installation. >&2 -echo. -goto error - -:valMHome - -:stripMHome -if not "_%M2_HOME:~-1%"=="_\" goto checkMCmd -set "M2_HOME=%M2_HOME:~0,-1%" -goto stripMHome - -:checkMCmd -if exist "%M2_HOME%\bin\mvn.cmd" goto init - -echo. -echo Error: M2_HOME is set to an invalid directory. >&2 -echo M2_HOME = "%M2_HOME%" >&2 -echo Please set the M2_HOME variable in your environment to match the >&2 -echo location of the Maven installation >&2 -echo. -goto error -@REM ==== END VALIDATION ==== - -:init - -set MAVEN_CMD_LINE_ARGS=%* - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -for %%i in ("%M2_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i" - -set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.home=%M2_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/mvnw.cmd b/mvnw.cmd old mode 100755 new mode 100644 index a5284c79..86115719 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,161 +1,182 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" -FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - echo Found %WRAPPER_JAR% -) else ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" - echo Finished downloading %WRAPPER_JAR% -) -@REM End of extension - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index 521515c7..19315fb7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,258 +1,70 @@ - - + + + 4.0.0 org.springframework.cloud - spring-cloud-consul - 4.1.0-SNAPSHOT - pom - Spring Cloud Consul - Spring Cloud Consul - - - org.springframework.cloud - spring-cloud-build - 4.1.0-SNAPSHOT - - - - - - 4.1.0-SNAPSHOT - 4.1.0-SNAPSHOT - 4.1.0-SNAPSHOT - 2.8.3 - 4.1.0-SNAPSHOT - 4.1.0-SNAPSHOT - 1.17.6 - 5.15.0 - + spring-cloud-consul-docs-build + 0.0.1-SNAPSHOT + Spring Cloud Consul Docs Build + Builds Spring Cloud Consul Docs. + https://spring.io/projects/spring-cloud-consul - https://github.com/spring-cloud/spring-cloud-consul - scm:git:git://github.com/spring-cloud/spring-cloud-consul.git + scm:git:https://github.com/spring-cloud/spring-cloud-consul.git - scm:git:ssh://git@github.com/spring-cloud/spring-cloud-consul.git + scm:git:git@github.com:spring-cloud/spring-cloud-consul.git - HEAD + https://github.com/spring-cloud/spring-cloud-consul + + https://github.com/spring-cloud/spring-cloud-consul/issues + + + + 0.0.3 + - - spring-cloud-consul-dependencies - spring-cloud-consul-core - spring-cloud-consul-config - spring-cloud-consul-discovery - spring-cloud-consul-binder - spring-cloud-consul-integration-tests - spring-cloud-starter-consul - spring-cloud-starter-consul-bus - spring-cloud-starter-consul-config - spring-cloud-starter-consul-discovery - spring-cloud-starter-consul-all - docs - - org.codehaus.mojo - flatten-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 + io.spring.maven.antora + antora-maven-plugin + ${io.spring.maven.antora-version} + true - 1.8 - 1.8 + + + + + + + 9d489079e5ec46dbb238909fee5c9c29 + WB1FQYI187 + springcloudconsul + - - io.spring.javaformat - spring-javaformat-maven-plugin - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - + + + spring-snapshot + https://repo.spring.io/snapshot + + true + + + false + + + + spring-milestone + https://repo.spring.io/milestone + + - - - - org.springframework.cloud - spring-cloud-consul-dependencies - ${project.version} - import - pom - - - org.springframework.cloud - spring-cloud-deployer-local - ${spring-cloud-deployer.version} - test - - - org.springframework.cloud - spring-cloud-stream-binder-test - ${spring-cloud-stream.version} - test - - - org.springframework.cloud - spring-cloud-stream-dependencies - ${spring-cloud-stream.version} - pom - import - - - org.springframework.cloud - spring-cloud-bus-dependencies - ${spring-cloud-bus.version} - pom - import - - - org.springframework.cloud - spring-cloud-commons-dependencies - ${spring-cloud-commons.version} - pom - import - - - org.springframework.cloud - spring-cloud-test-support - test - ${spring-cloud-commons.version} - - - org.springframework.cloud - spring-cloud-config-dependencies - ${spring-cloud-config.version} - pom - import - - - org.springframework.cloud - spring-cloud-openfeign-dependencies - ${spring-cloud-openfeign.version} - import - pom - - - org.testcontainers - consul - ${testcontainers.version} - - - org.testcontainers - mockserver - ${testcontainers.version} - - - org.testcontainers - junit-jupiter - ${testcontainers.version} - - - org.apache.httpcomponents - httpclient - 4.5.14 - - - org.apache.httpcomponents - httpcore - 4.4.16 - - - org.mock-server - mockserver-client-java - ${mockserverclient.version} - - - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - - spring - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - - diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index 1a38a5a1..00000000 --- a/scripts/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./mvnw clean install -B -Pdocs ${@} diff --git a/scripts/compileOnly.sh b/scripts/compileOnly.sh deleted file mode 100755 index 437c70ac..00000000 --- a/scripts/compileOnly.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./mvnw clean install -B -Pdocs -DskipTests -fae diff --git a/scripts/runAcceptanceTests.sh b/scripts/runAcceptanceTests.sh deleted file mode 100755 index 21096346..00000000 --- a/scripts/runAcceptanceTests.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -o errexit - -mkdir -p target - -SCRIPT_URL="https://raw.githubusercontent.com/spring-cloud-samples/brewery/2021.0.x/runAcceptanceTests.sh" -AT_WHAT_TO_TEST="CONSUL" - -cd target - -curl "${SCRIPT_URL}" --output runAcceptanceTests.sh - -chmod +x runAcceptanceTests.sh - -echo "Killing all running apps" -./runAcceptanceTests.sh -t "${AT_WHAT_TO_TEST}" -n - -./runAcceptanceTests.sh --whattotest "${AT_WHAT_TO_TEST}" --killattheend diff --git a/spring-cloud-consul-binder/pom.xml b/spring-cloud-consul-binder/pom.xml deleted file mode 100644 index 9a2777e7..00000000 --- a/spring-cloud-consul-binder/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - 4.0.0 - - spring-cloud-consul-binder - jar - Spring Cloud Consul Binder - Spring Cloud Consul Binder - - - org.springframework.cloud - spring-cloud-consul - 4.1.0-SNAPSHOT - .. - - - - - org.springframework.boot - spring-boot-starter-web - true - - - org.springframework.cloud - spring-cloud-consul-core - true - - - org.springframework.cloud - spring-cloud-stream - - - com.ecwid.consul - consul-api - true - - - org.projectlombok - lombok - test - - - org.springframework.cloud - spring-cloud-deployer-local - test - - - org.springframework.cloud - spring-cloud-test-support - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - test - - - com.github.tomakehurst - wiremock-jre8-standalone - 2.35.1 - test - - - org.awaitility - awaitility - 4.0.3 - test - - - org.testcontainers - consul - test - - - org.springframework.cloud - spring-cloud-consul-core - ${project.version} - test-jar - test - - - - diff --git a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulBinder.java b/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulBinder.java deleted file mode 100644 index 76a5962b..00000000 --- a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulBinder.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder; - -import org.springframework.cloud.stream.binder.AbstractBinder; -import org.springframework.cloud.stream.binder.Binding; -import org.springframework.cloud.stream.binder.ConsumerProperties; -import org.springframework.cloud.stream.binder.DefaultBinding; -import org.springframework.cloud.stream.binder.ProducerProperties; -import org.springframework.integration.endpoint.EventDrivenConsumer; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.SubscribableChannel; -import org.springframework.util.Assert; - -/** - * @author Spencer Gibb - */ -public class ConsulBinder extends AbstractBinder { - - private static final String BEAN_NAME_TEMPLATE = "outbound.%s"; - - private final EventService eventService; - - public ConsulBinder(EventService eventService) { - this.eventService = eventService; - } - - @Override - protected Binding doBindConsumer(String name, String group, MessageChannel inputChannel, - ConsumerProperties properties) { - ConsulInboundMessageProducer messageProducer = new ConsulInboundMessageProducer(this.eventService); - messageProducer.setOutputChannel(inputChannel); - messageProducer.setBeanFactory(this.getBeanFactory()); - messageProducer.afterPropertiesSet(); - messageProducer.start(); - - return new DefaultBinding<>(name, group, inputChannel, messageProducer); - } - - @Override - protected Binding doBindProducer(String name, MessageChannel channel, - ProducerProperties properties) { - Assert.isInstanceOf(SubscribableChannel.class, channel); - - this.logger.debug("Binding Consul client to eventName " + name); - ConsulSendingHandler sendingHandler = new ConsulSendingHandler(this.eventService.getConsulClient(), name); - - EventDrivenConsumer consumer = new EventDrivenConsumer((SubscribableChannel) channel, sendingHandler); - consumer.setBeanFactory(getBeanFactory()); - consumer.setBeanName(String.format(BEAN_NAME_TEMPLATE, name)); - consumer.afterPropertiesSet(); - consumer.start(); - - return new DefaultBinding<>(name, null, channel, consumer); - } - -} diff --git a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulInboundMessageProducer.java b/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulInboundMessageProducer.java deleted file mode 100644 index 74e234d7..00000000 --- a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulInboundMessageProducer.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder; - -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -import com.ecwid.consul.v1.OperationException; -import com.ecwid.consul.v1.event.model.Event; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.integration.endpoint.MessageProducerSupport; - -import static org.springframework.util.Base64Utils.decodeFromString; - -/** - * Adapter that receives Messages from Consul Events, converts them into Spring - * Integration Messages, and sends the results to a Message Channel. - * - * @author Spencer Gibb - */ -public class ConsulInboundMessageProducer extends MessageProducerSupport { - - protected static final Log logger = LogFactory.getLog(ConsulInboundMessageProducer.class); - - private final ScheduledExecutorService scheduler; - - private final Runnable eventsRunnable; - - private EventService eventService; - - private ScheduledFuture eventsHandle; - - public ConsulInboundMessageProducer(EventService eventService) { - this.eventService = eventService; - this.scheduler = Executors.newScheduledThreadPool(1); - this.eventsRunnable = new Runnable() { - - @Override - public void run() { - getEvents(); - } - }; - } - - // link eventService to sendMessage - /* - * Map headers = - * headerMapper.toHeadersFromRequest(message.getMessageProperties()); if - * (messageListenerContainer.getAcknowledgeMode() == AcknowledgeMode.MANUAL) { - * headers.put(AmqpHeaders.DELIVERY_TAG, - * message.getMessageProperties().getDeliveryTag()); headers.put(AmqpHeaders.CHANNEL, - * channel); } - * sendMessage(AmqpInboundChannelAdapter.this.getMessageBuilderFactory().withPayload - * (payload).copyHeaders(headers).build()); - */ - - // start thread - // make blocking calls - // foreach event -> send message - - @Override - protected void doStart() { - // TODO: make configurable - this.eventsHandle = this.scheduler.scheduleWithFixedDelay(this.eventsRunnable, 500, 500, TimeUnit.MILLISECONDS); - } - - @Override - protected void doStop() { - if (this.eventsHandle != null) { - this.eventsHandle.cancel(true); - } - this.scheduler.shutdown(); - } - - // @Scheduled(fixedDelayString = "${spring.cloud.consul.binder.eventDelay:30000}") - public void getEvents() { - try { - List events = this.eventService.watch(); - for (Event event : events) { - // Map headers = new HashMap<>(); - // headers.put(MessageHeaders.REPLY_CHANNEL, outputChannel.) - String decoded = new String(decodeFromString(event.getPayload())); - sendMessage(getMessageBuilderFactory().withPayload(decoded) - // TODO: support headers - .build()); - } - } - catch (OperationException e) { - if (logger.isErrorEnabled()) { - logger.error("Error getting consul events: " + e); - } - } - catch (Exception e) { - if (logger.isErrorEnabled()) { - logger.error("Error getting consul events: " + e.getMessage()); - } - if (logger.isDebugEnabled()) { - logger.debug("Error getting consul events", e); - } - } - } - -} diff --git a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulSendingHandler.java b/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulSendingHandler.java deleted file mode 100644 index 3ebd85a1..00000000 --- a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/ConsulSendingHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder; - -import java.util.Arrays; - -import com.ecwid.consul.v1.ConsulClient; -import com.ecwid.consul.v1.QueryParams; -import com.ecwid.consul.v1.Response; -import com.ecwid.consul.v1.event.model.Event; -import com.ecwid.consul.v1.event.model.EventParams; - -import org.springframework.integration.handler.AbstractMessageHandler; -import org.springframework.messaging.Message; - -/** - * Adapter that converts and sends Messages as Consul events. - * - * @author Spencer Gibb - */ -public class ConsulSendingHandler extends AbstractMessageHandler { - - private final ConsulClient consul; - - private final String eventName; - - public ConsulSendingHandler(ConsulClient consul, String eventName) { - this.consul = consul; - this.eventName = eventName; - } - - @Override - protected void handleMessageInternal(Message message) { - if (this.logger.isTraceEnabled()) { - this.logger.trace("Publishing message" + message); - } - - Object payload = message.getPayload(); - if (payload instanceof byte[]) { - payload = Arrays.toString((byte[]) payload); - } - - // TODO: support headers - // TODO: support consul event filters: NodeFilter, ServiceFilter, TagFilter - Response event = this.consul.eventFire(this.eventName, (String) payload, new EventParams(), - QueryParams.DEFAULT); - // TODO: return event? - } - -} diff --git a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/EventService.java b/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/EventService.java deleted file mode 100644 index 786724b3..00000000 --- a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/EventService.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder; - -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; - -import com.ecwid.consul.v1.ConsulClient; -import com.ecwid.consul.v1.QueryParams; -import com.ecwid.consul.v1.Response; -import com.ecwid.consul.v1.event.EventListRequest; -import com.ecwid.consul.v1.event.model.Event; -import com.ecwid.consul.v1.event.model.EventParams; -import com.fasterxml.jackson.databind.ObjectMapper; -import jakarta.annotation.PostConstruct; - -import org.springframework.cloud.consul.binder.config.ConsulBinderProperties; - -/** - * @author Spencer Gibb - */ -public class EventService { - - protected ConsulBinderProperties properties; - - protected ConsulClient consul; - - protected ObjectMapper objectMapper = new ObjectMapper(); - - private AtomicReference lastIndex = new AtomicReference<>(); - - public EventService(ConsulBinderProperties properties, ConsulClient consul, ObjectMapper objectMapper) { - this.properties = properties; - this.consul = consul; - this.objectMapper = objectMapper; - } - - public ConsulClient getConsulClient() { - return this.consul; - } - - @PostConstruct - public void init() { - setLastIndex(getEventsResponse()); - } - - public Long getLastIndex() { - return this.lastIndex.get(); - } - - private void setLastIndex(Response response) { - Long consulIndex = response.getConsulIndex(); - if (consulIndex != null) { - this.lastIndex.set(response.getConsulIndex()); - } - } - - public Event fire(String name, String payload) { - Response response = this.consul.eventFire(name, payload, new EventParams(), QueryParams.DEFAULT); - return response.getValue(); - } - - public Response> getEventsResponse() { - return this.consul.eventList(EventListRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build()); - } - - public List getEvents() { - return getEventsResponse().getValue(); - } - - public List getEvents(Long lastIndex) { - return filterEvents(readEvents(getEventsResponse()), lastIndex); - } - - public List watch() { - return watch(this.lastIndex.get()); - } - - public List watch(Long lastIndex) { - // TODO: parameterized or configurable watch time - long index = -1; - if (lastIndex != null) { - index = lastIndex; - } - int eventTimeout = 5; - if (this.properties != null) { - eventTimeout = this.properties.getEventTimeout(); - } - Response> watch = this.consul - .eventList(EventListRequest.newBuilder().setQueryParams(new QueryParams(eventTimeout, index)).build()); - return filterEvents(readEvents(watch), lastIndex); - } - - protected List readEvents(Response> response) { - setLastIndex(response); - return response.getValue(); - } - - /** - * from https://github.com/hashicorp/consul/blob/master/watch/funcs.go#L169-L194 . - * @param toFilter events to filter - * @param lastIndex last index to pick from the list of events - * @return filtered list of events - */ - protected List filterEvents(List toFilter, Long lastIndex) { - List events = toFilter; - if (lastIndex != null) { - for (int i = 0; i < events.size(); i++) { - Event event = events.get(i); - Long eventIndex = event.getWaitIndex(); - if (lastIndex.equals(eventIndex)) { - events = events.subList(i + 1, events.size()); - break; - } - } - } - return events; - } - -} diff --git a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/config/ConsulBinderConfiguration.java b/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/config/ConsulBinderConfiguration.java deleted file mode 100644 index e4e4c780..00000000 --- a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/config/ConsulBinderConfiguration.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder.config; - -import com.ecwid.consul.v1.ConsulClient; -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.cloud.consul.ConditionalOnConsulEnabled; -import org.springframework.cloud.consul.binder.ConsulBinder; -import org.springframework.cloud.consul.binder.EventService; -import org.springframework.cloud.stream.binder.Binder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -/** - * Configures the Consul binder. - * - * @author Spencer Gibb - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnMissingBean(Binder.class) -@Import({ PropertyPlaceholderAutoConfiguration.class }) -@ConditionalOnConsulEnabled -@ConditionalOnProperty(name = "spring.cloud.consul.binder.enabled", matchIfMissing = true) -// FIXME: boot 2.0.0 @EnableConfigurationProperties({ConsulBinderProperties.class}) -public class ConsulBinderConfiguration { - - // @Autowired - // private ConsulBinderProperties consulBinderProperties; - - @Autowired(required = false) - protected ObjectMapper objectMapper = new ObjectMapper(); - - @Bean - @ConditionalOnMissingBean - public EventService eventService(ConsulClient consulClient) { - return new EventService(null/* consulBinderProperties */, consulClient, this.objectMapper); - } - - @Bean - @ConditionalOnMissingBean - public ConsulBinder consulClientBinder(EventService eventService) { - return new ConsulBinder(eventService); - } - - // TODO: create consul client if needed - -} diff --git a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/config/ConsulBinderProperties.java b/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/config/ConsulBinderProperties.java deleted file mode 100644 index 2852b3ac..00000000 --- a/spring-cloud-consul-binder/src/main/java/org/springframework/cloud/consul/binder/config/ConsulBinderProperties.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.core.style.ToStringCreator; - -/** - * @author Spencer Gibb - */ -@ConfigurationProperties("spring.cloud.stream.consul.binder") -public class ConsulBinderProperties { - - private int eventTimeout = 5; - - public ConsulBinderProperties() { - } - - public int getEventTimeout() { - return this.eventTimeout; - } - - public void setEventTimeout(int eventTimeout) { - this.eventTimeout = eventTimeout; - } - - @Override - public String toString() { - return new ToStringCreator(this).append("eventTimeout", this.eventTimeout).toString(); - } - -} diff --git a/spring-cloud-consul-binder/src/main/resources/META-INF/spring-cloud-stream/consul-binder.properties b/spring-cloud-consul-binder/src/main/resources/META-INF/spring-cloud-stream/consul-binder.properties deleted file mode 100644 index 8e42c7a4..00000000 --- a/spring-cloud-consul-binder/src/main/resources/META-INF/spring-cloud-stream/consul-binder.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright 2013-2016 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -spring.cloud.stream.binder.consul.default.host=localhost -spring.cloud.stream.binder.consul.default.port=8500 diff --git a/spring-cloud-consul-binder/src/main/resources/META-INF/spring.binders b/spring-cloud-consul-binder/src/main/resources/META-INF/spring.binders deleted file mode 100644 index c3f435cd..00000000 --- a/spring-cloud-consul-binder/src/main/resources/META-INF/spring.binders +++ /dev/null @@ -1,2 +0,0 @@ -consul:\ -org.springframework.cloud.consul.binder.config.ConsulBinderConfiguration diff --git a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulBinderApplicationTests.java b/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulBinderApplicationTests.java deleted file mode 100644 index e6f9b721..00000000 --- a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulBinderApplicationTests.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder; - -import java.util.concurrent.TimeUnit; - -import com.ecwid.consul.v1.ConsulClient; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.consul.test.ConsulTestcontainers; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD; - -/** - * @author Spencer Gibb - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = ConsulBinderApplicationTests.Application.class) -@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD) -@ContextConfiguration(initializers = ConsulTestcontainers.class) -// FIXME: 4.0.0 https://github.com/spring-cloud/spring-cloud-consul/issues/763 -@Ignore("update to stream 4.0.0 testing") -public class ConsulBinderApplicationTests { - - @Rule - public final WireMockRule wireMock = new WireMockRule(18500); - - @Autowired - private Events events; - - @Before - public void setUp() throws Exception { - - this.wireMock.stubFor(put(urlPathMatching("/v1/event/fire/purchases")).willReturn(aResponse().withStatus(200))); - - /* - * wireMock.stubFor(get(urlPathMatching("/v1/event/list")) - * .willReturn(aResponse().withBody("[]") .withStatus(200) - * .withHeader("X-Consul-Index", "1"))); - */ - } - - @Test - public void shouldInitializeConsulSource() { - - assertThat(this.events).isNotNull(); - } - - @Test - public void shouldPublishTextConsulMessage() { - - // given - final Message message = MessageBuilder.withPayload("Hello Consul!").build(); - - // when - this.events.purchases().send(message); - - // then - await().atMost(1, TimeUnit.SECONDS); - verify(1, putRequestedFor(urlPathMatching("/v1/event/fire/purchases"))); - } - - interface Events { - - // @Output - MessageChannel purchases(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - // @EnableBinding(Events.class) - public static class Application { - - @Bean - public ConsulClient consulClient() { - return new ConsulClient("localhost", 18500); - } - - @Bean - public EventService eventService(ConsulClient consulClient) { - EventService eventService = mock(EventService.class); - when(eventService.getConsulClient()).thenReturn(consulClient); - return eventService; - } - - } - -} diff --git a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulBinderTests.java b/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulBinderTests.java deleted file mode 100644 index f0064635..00000000 --- a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulBinderTests.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.cloud.consul.binder.test.consumer.TestConsumer; -import org.springframework.cloud.consul.binder.test.producer.TestProducer; -import org.springframework.cloud.deployer.spi.app.AppDeployer; -import org.springframework.cloud.deployer.spi.core.AppDefinition; -import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; -import org.springframework.cloud.deployer.spi.local.LocalAppDeployer; -import org.springframework.cloud.deployer.spi.local.LocalDeployerProperties; -import org.springframework.cloud.test.TestSocketUtils; -import org.springframework.core.io.Resource; -import org.springframework.core.io.UrlResource; -import org.springframework.web.client.ResourceAccessException; -import org.springframework.web.client.RestTemplate; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link org.springframework.cloud.consul.binder.ConsulBinder}. - * - * @author Spencer Gibb - */ -public class ConsulBinderTests { - - /** - * Payload of test message. - */ - public static final String MESSAGE_PAYLOAD = "hello world"; - - /** - * Name of binding used for producer and consumer bindings. - */ - public static final String BINDING_NAME = "test"; - - private static final Logger logger = LoggerFactory.getLogger(ConsulBinderTests.class); - - /** - * Timeout value in milliseconds for operations to complete. - */ - private static final long TIMEOUT = 30000; - - /** - * Deployer to launch producer and consumer test applications. - */ - private final AppDeployer deployer; - - /** - * Rest template for communicating with producer/consumer test applications. - */ - private final RestTemplate restTemplate = new RestTemplate(); - - public ConsulBinderTests() { - LocalDeployerProperties properties = new LocalDeployerProperties(); - properties.setDeleteFilesOnExit(false); - this.deployer = new ClasspathDeployer(properties); - } - - /** - * Test basic message sending functionality. - * @throws InterruptedException when waiting for message was interrupted - */ - @Test - @Ignore // FIXME: 2.0.0 need stream fix - public void testMessageSendReceive() throws InterruptedException { - testMessageSendReceive(null); - } - - /** - * Test usage of partition selector. - * @throws Exception - */ - /* - * @Test public void testPartitionedMessageSendReceive() throws Exception { - * testMessageSendReceive(null, true); } - */ - - /** - * Test consumer group functionality. - * @throws Exception - */ - /* - * @Test public void testMessageSendReceiveConsumerGroups() throws Exception { - * testMessageSendReceive(new String[]{"a", "b"}, false); } - */ - - /** - * Test message sending functionality. - * @param groups consumer groups; may be {@code null} - * @throws InterruptedException when waiting for message was interrupted - */ - private void testMessageSendReceive(String[] groups) throws InterruptedException { - Set consumers = null; - AppId producer = null; - - try { - consumers = launchConsumers(groups); - producer = launchProducer(); - - for (AppId consumer : consumers) { - assertThat(waitForMessage(consumer.port)).isEqualTo(MESSAGE_PAYLOAD); - } - } - finally { - if (producer != null) { - shutdownApplication(producer.id); - } - if (consumers != null) { - for (AppId consumer : consumers) { - shutdownApplication(consumer.id); - } - } - } - } - - /** - * Launch one or more consumers based on the number of consumer groups. Blocks - * execution until the consumers are bound. - * @param groups consumer groups; may be {@code null} - * @return a set of {@link AppId}s for the consumers - * @throws InterruptedException when waiting for message was interrupted - */ - private Set launchConsumers(String[] groups) throws InterruptedException { - Set consumers = new HashSet<>(); - - Map appProperties = new HashMap<>(); - int consumerCount = groups == null ? 1 : groups.length; - for (int i = 0; i < consumerCount; i++) { - int consumerPort = TestSocketUtils.findAvailableTcpPort(); - appProperties.put("server.port", String.valueOf(consumerPort)); - List args = new ArrayList<>(); - args.add(String.format("--server.port=%d", consumerPort)); - args.add("--management.context-path=/"); - args.add("--management.security.enabled=false"); - args.add("--endpoints.shutdown.enabled=true"); - args.add("--debug"); - if (groups != null) { - args.add(String.format("--group=%s", groups[i])); - } - consumers.add(new AppId(launchApplication(TestConsumer.class, appProperties, args), consumerPort)); - } - for (AppId app : consumers) { - waitForConsumer(app.port); - } - - return consumers; - } - - /** - * Launch a producer that publishes a test message. - * @return {@link AppId} for producer - */ - private AppId launchProducer() { - int producerPort = TestSocketUtils.findAvailableTcpPort(); - Map appProperties = new HashMap<>(); - appProperties.put("server.port", String.valueOf(producerPort)); - List args = new ArrayList<>(); - args.add(String.format("--server.port=%d", producerPort)); - args.add("--management.context-path=/"); - args.add("--management.security.enabled=false"); - args.add("--endpoints.shutdown.enabled=true"); - args.add(String.format("--partitioned=%b", false)); - args.add("--debug"); - - return new AppId(launchApplication(TestProducer.class, appProperties, args), producerPort); - } - - /** - * Block the executing thread until the consumer is bound. - * @param port server port of the consumer application - * @throws InterruptedException if the thread is interrupted - * @throws AssertionError if the consumer is not bound after {@value #TIMEOUT} - * milliseconds - */ - private void waitForConsumer(int port) throws InterruptedException { - long start = System.currentTimeMillis(); - while (System.currentTimeMillis() < start + TIMEOUT) { - if (isConsumerBound(port)) { - return; - } - else { - Thread.sleep(1000); - } - } - assertThat(isConsumerBound(port)).as("Consumer not bound").isTrue(); - } - - /** - * Return {@code true} if the consumer at the provided port is bound. - * @param port http port for consumer - * @return true if consumer is bound - */ - private boolean isConsumerBound(int port) { - try { - return this.restTemplate.getForObject(String.format("http://localhost:%d/is-bound", port), Boolean.class); - } - catch (ResourceAccessException e) { - logger.trace("isConsumerBound", e); - return false; - } - } - - /** - * Return the most recent payload message a consumer received. - * @param port http port for consumer - * @return the most recent payload message a consumer received; may be {@code null} - */ - private String getConsumerMessagePayload(int port) { - try { - return this.restTemplate.getForObject(String.format("http://localhost:%d/message-payload", port), - String.class); - } - catch (ResourceAccessException e) { - logger.debug("getConsumerMessagePayload", e); - return null; - } - } - - /** - * Return {@code true} if the producer made use of a custom partition selector. - * @param port http port for producer - * @return true if the producer used a custom partition selector - */ - private boolean partitionSelectorUsed(int port) { - try { - return this.restTemplate.getForObject(String.format("http://localhost:%d/partition-strategy-invoked", port), - Boolean.class); - } - catch (ResourceAccessException e) { - logger.debug("partitionSelectorUsed", e); - return false; - } - } - - /** - * Block the executing thread until a message is received by the consumer application, - * or until {@value #TIMEOUT} milliseconds elapses. - * @param port server port of the consumer application - * @return the message payload that was received - * @throws InterruptedException if the thread is interrupted - */ - private String waitForMessage(int port) throws InterruptedException { - long start = System.currentTimeMillis(); - String message = null; - while (System.currentTimeMillis() < start + TIMEOUT) { - message = getConsumerMessagePayload(port); - if (message == null) { - Thread.sleep(1000); - } - else { - break; - } - } - return message; - } - - /** - * Launch an application in a separate JVM. - * @param clz the main class to launch - * @param properties the properties to pass to the application - * @param args the command line arguments for the application - * @return a string identifier for the application - */ - private String launchApplication(Class clz, Map properties, List args) { - Resource resource = new UrlResource(clz.getProtectionDomain().getCodeSource().getLocation()); - - properties.put(AppDeployer.GROUP_PROPERTY_KEY, "test-group"); - properties.put("main", clz.getName()); - properties.put("classpath", System.getProperty("java.class.path")); - - String appName = String.format("%s-%s", clz.getSimpleName(), properties.get("server.port")); - AppDefinition definition = new AppDefinition(appName, properties); - - AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties, args); - return this.deployer.deploy(request); - } - - /** - * Shut down the application with the provided id. - * @param id id of application to shut down - */ - private void shutdownApplication(String id) { - this.deployer.undeploy(id); - } - - private static class ClasspathDeployer extends LocalAppDeployer { - - /** - * Instantiates a new local app deployer. - * @param properties the properties - */ - ClasspathDeployer(LocalDeployerProperties properties) { - super(properties); - } - - /** - * Builds the jar execution command. - * @param jarPath the jar path - * @param request the request - * @return the string[] - */ - protected String[] buildJarExecutionCommand(String jarPath, AppDeploymentRequest request) { - - ArrayList commands = new ArrayList<>(); - commands.add(super.getLocalDeployerProperties().getJavaCmd()); - commands.add("-cp"); - commands.add(request.getDefinition().getProperties().get("classpath")); - commands.add(request.getDefinition().getProperties().get("main")); - commands.addAll(request.getCommandlineArguments()); - - return commands.toArray(new String[commands.size()]); - } - - } - - /** - * String identification and http port for a launched application. - */ - private static class AppId { - - final String id; - - final int port; - - AppId(String id, int port) { - this.id = id; - this.port = port; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - AppId appId = (AppId) o; - return this.port == appId.port && this.id.equals(appId.id); - } - - @Override - public int hashCode() { - int result = this.id.hashCode(); - result = 31 * result + this.port; - return result; - } - - } - -} diff --git a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulInboundMessageProducerTests.java b/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulInboundMessageProducerTests.java deleted file mode 100644 index 5d828866..00000000 --- a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/ConsulInboundMessageProducerTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder; - -import com.ecwid.consul.v1.OperationException; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author Spencer Gibb - */ -public class ConsulInboundMessageProducerTests { - - @Test - public void getEventsShouldNotThrowException() { - EventService eventService = mock(EventService.class); - when(eventService.watch()).thenThrow(new OperationException(500, "error", "")); - - ConsulInboundMessageProducer producer = new ConsulInboundMessageProducer(eventService); - - try { - producer.getEvents(); - } - catch (Exception e) { - fail("ConsulInboundMessageProducer threw unexpected exception: " + e); - } - - } - -} diff --git a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/config/ConsulBinderConfigurationTests.java b/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/config/ConsulBinderConfigurationTests.java deleted file mode 100644 index 3da4e448..00000000 --- a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/config/ConsulBinderConfigurationTests.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder.config; - -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.consul.test.ConsulTestcontainers; -import org.springframework.context.annotation.Configuration; -import org.springframework.messaging.MessageChannel; - -import static org.hamcrest.Matchers.containsString; - -/** - * @author Spencer Gibb - */ -public class ConsulBinderConfigurationTests { - - @Rule - public ExpectedException exception = ExpectedException.none(); - - @Test - @Ignore // FIXME 2.0.0 need stream fix - public void consulBinderDisabledWorks() { - this.exception.expectMessage(containsString("no proper implementation found")); - new SpringApplicationBuilder(Application.class).initializers(new ConsulTestcontainers()) - .properties("spring.cloud.consul.binder.enabled=false").run(); - } - - @Test - @Ignore // FIXME 2.0.0 need stream fix - public void consulDisabledDisablesBinder() { - this.exception.expectMessage(containsString("no proper implementation found")); - new SpringApplicationBuilder(Application.class).initializers(new ConsulTestcontainers()) - .properties("spring.cloud.consul.enabled=false").run(); - } - - interface Events { - - // @Output - MessageChannel purchases(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - // @EnableBinding(Events.class) - public static class Application { - - } - -} diff --git a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/test/consumer/TestConsumer.java b/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/test/consumer/TestConsumer.java deleted file mode 100644 index 591a328e..00000000 --- a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/test/consumer/TestConsumer.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder.test.consumer; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.consul.binder.ConsulBinder; -import org.springframework.cloud.consul.binder.ConsulBinderTests; -import org.springframework.cloud.consul.binder.config.ConsulBinderConfiguration; -import org.springframework.cloud.stream.binder.ConsumerProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.MessagingException; -import org.springframework.messaging.SubscribableChannel; -import org.springframework.messaging.support.ExecutorSubscribableChannel; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Consumer application that binds a channel to a {@link ConsulBinder} and stores the - * received message payload. - */ -@RestController -@Import(ConsulBinderConfiguration.class) -@Configuration(proxyBeanMethods = false) -@EnableAutoConfiguration -public class TestConsumer implements ApplicationRunner { - - private static final Logger logger = LoggerFactory.getLogger(TestConsumer.class); - - /** - * Flag that indicates if the consumer has been bound. - */ - private volatile boolean isBound = false; - - /** - * Payload of last received message. - */ - private volatile String messagePayload; - - @Autowired - private ConsulBinder binder; - - /** - * Main method. - * @param args if present, first arg is consumer group name - */ - public static void main(String[] args) { - SpringApplication.run(TestConsumer.class, args); - } - - @Override - public void run(ApplicationArguments args) throws Exception { - logger.info("Consumer running with binder {}", this.binder); - SubscribableChannel consumerChannel = new ExecutorSubscribableChannel(); - consumerChannel.subscribe(new MessageHandler() { - @Override - public void handleMessage(Message message) throws MessagingException { - TestConsumer.this.messagePayload = (String) message.getPayload(); - logger.info("Received message: {}", TestConsumer.this.messagePayload); - } - }); - String group = null; - - if (args.containsOption("group")) { - group = args.getOptionValues("group").get(0); - } - - this.binder.bindConsumer(ConsulBinderTests.BINDING_NAME, group, consumerChannel, new ConsumerProperties()); - this.isBound = true; - } - - @GetMapping("/is-bound") - public boolean isBound() { - return this.isBound; - } - - @GetMapping("/message-payload") - public String getMessagePayload() { - return this.messagePayload; - } - -} diff --git a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/test/producer/TestProducer.java b/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/test/producer/TestProducer.java deleted file mode 100644 index e15a2a9e..00000000 --- a/spring-cloud-consul-binder/src/test/java/org/springframework/cloud/consul/binder/test/producer/TestProducer.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.binder.test.producer; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.consul.binder.ConsulBinder; -import org.springframework.cloud.consul.binder.ConsulBinderTests; -import org.springframework.cloud.consul.binder.config.ConsulBinderConfiguration; -import org.springframework.cloud.stream.binder.PartitionSelectorStrategy; -import org.springframework.cloud.stream.binder.ProducerProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.messaging.Message; -import org.springframework.messaging.SubscribableChannel; -import org.springframework.messaging.support.ExecutorSubscribableChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Producer application that binds a channel to a {@link ConsulBinder} and sends a test - * message. - */ -@RestController -@Import(ConsulBinderConfiguration.class) -@Configuration(proxyBeanMethods = false) -@EnableAutoConfiguration -public class TestProducer implements ApplicationRunner { - - private static final Logger logger = LoggerFactory.getLogger(TestProducer.class); - - @Autowired - private ConsulBinder binder; - - public static void main(String[] args) { - SpringApplication.run(TestProducer.class, args); - } - - @Override - public void run(ApplicationArguments args) throws Exception { - /* - * if (args.containsOption("partitioned") && - * Boolean.valueOf(args.getOptionValues("partitioned").get(0))) { - * binder.setPartitionSelector(stubPartitionSelectorStrategy()); } - */ - SubscribableChannel producerChannel = producerChannel(); - ProducerProperties properties = new ProducerProperties(); - properties.setPartitionKeyExpression(new SpelExpressionParser().parseExpression("payload")); - this.binder.bindProducer(ConsulBinderTests.BINDING_NAME, producerChannel, properties); - - Message message = new GenericMessage<>(ConsulBinderTests.MESSAGE_PAYLOAD); - logger.info("Writing message to binder {}", this.binder); - producerChannel.send(message); - } - - @Bean - public SubscribableChannel producerChannel() { - return new ExecutorSubscribableChannel(); - } - - @Bean - public StubPartitionSelectorStrategy stubPartitionSelectorStrategy() { - return new StubPartitionSelectorStrategy(); - } - - @GetMapping("/partition-strategy-invoked") - public boolean partitionStrategyInvoked() { - return stubPartitionSelectorStrategy().invoked; - } - - public static class StubPartitionSelectorStrategy implements PartitionSelectorStrategy { - - public volatile boolean invoked = false; - - @Override - public int selectPartition(Object key, int partitionCount) { - logger.info("Selecting partition for key {}; partition count: {}", key, partitionCount); - this.invoked = true; - return 1; - } - - } - -} diff --git a/spring-cloud-consul-binder/src/test/resources/application.yml b/spring-cloud-consul-binder/src/test/resources/application.yml deleted file mode 100644 index 0c1f35a9..00000000 --- a/spring-cloud-consul-binder/src/test/resources/application.yml +++ /dev/null @@ -1,13 +0,0 @@ -spring: - cloud: - stream: - binders: - purchases: - type: consul - consul: - binder: -management: - security: - enabled: false -# host: localhost -# port: 18500 diff --git a/spring-cloud-consul-config/pom.xml b/spring-cloud-consul-config/pom.xml deleted file mode 100644 index 06c051b8..00000000 --- a/spring-cloud-consul-config/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - 4.0.0 - - spring-cloud-consul-config - jar - Spring Cloud Consul Config - Spring Cloud Consul Config - - - org.springframework.cloud - spring-cloud-consul - 4.1.0-SNAPSHOT - .. - - - - - org.springframework.cloud - spring-cloud-commons - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter-web - true - - - org.springframework.boot - spring-boot-starter-actuator - true - - - com.ecwid.consul - consul-api - true - - - org.springframework.cloud - spring-cloud-consul-core - true - - - org.springframework.cloud - spring-cloud-context - true - - - org.springframework.retry - spring-retry - true - - - org.springframework - spring-core - - - - - org.springframework.boot - spring-boot-autoconfigure-processor - true - - - org.springframework.boot - spring-boot-starter-aop - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - test - - - org.testcontainers - consul - test - - - org.springframework.cloud - spring-cloud-consul-core - ${project.version} - test-jar - test - - - - diff --git a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConfigWatch.java b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConfigWatch.java deleted file mode 100644 index db97c665..00000000 --- a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConfigWatch.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.config; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.atomic.AtomicBoolean; - -import com.ecwid.consul.v1.ConsulClient; -import com.ecwid.consul.v1.QueryParams; -import com.ecwid.consul.v1.Response; -import com.ecwid.consul.v1.kv.model.GetValue; -import io.micrometer.core.annotation.Timed; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.endpoint.event.RefreshEvent; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.ApplicationEventPublisherAware; -import org.springframework.context.SmartLifecycle; -import org.springframework.core.style.ToStringCreator; -import org.springframework.scheduling.TaskScheduler; -import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; -import org.springframework.util.ObjectUtils; -import org.springframework.util.ReflectionUtils; - -import static org.springframework.cloud.consul.config.ConsulConfigProperties.Format.FILES; - -/** - * @author Spencer Gibb - */ -public class ConfigWatch implements ApplicationEventPublisherAware, SmartLifecycle { - - private static final Log log = LogFactory.getLog(ConfigWatch.class); - - private final ConsulConfigProperties properties; - - private final ConsulClient consul; - - private final TaskScheduler taskScheduler; - - private final AtomicBoolean running = new AtomicBoolean(false); - - private LinkedHashMap consulIndexes; - - private ApplicationEventPublisher publisher; - - private boolean firstTime = true; - - private ScheduledFuture watchFuture; - - public ConfigWatch(ConsulConfigProperties properties, ConsulClient consul, - LinkedHashMap initialIndexes) { - this(properties, consul, initialIndexes, getTaskScheduler()); - } - - public ConfigWatch(ConsulConfigProperties properties, ConsulClient consul, - LinkedHashMap initialIndexes, TaskScheduler taskScheduler) { - this.properties = properties; - this.consul = consul; - this.consulIndexes = new LinkedHashMap<>(initialIndexes); - this.taskScheduler = taskScheduler; - } - - private static ThreadPoolTaskScheduler getTaskScheduler() { - ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); - taskScheduler.initialize(); - return taskScheduler; - } - - @Override - public void setApplicationEventPublisher(ApplicationEventPublisher publisher) { - this.publisher = publisher; - } - - @Override - public void start() { - if (this.running.compareAndSet(false, true)) { - this.watchFuture = this.taskScheduler.scheduleWithFixedDelay(this::watchConfigKeyValues, - this.properties.getWatch().getDelay()); - } - } - - @Override - public boolean isAutoStartup() { - return true; - } - - @Override - public void stop(Runnable callback) { - this.stop(); - callback.run(); - } - - @Override - public int getPhase() { - return 0; - } - - @Override - public void stop() { - if (this.running.compareAndSet(true, false) && this.watchFuture != null) { - this.watchFuture.cancel(true); - } - } - - @Override - public boolean isRunning() { - return this.running.get(); - } - - @Timed("consul.watch-config-keys") - public void watchConfigKeyValues() { - if (!this.running.get()) { - return; - } - for (String context : this.consulIndexes.keySet()) { - - // turn the context into a Consul folder path (unless our config format - // are FILES) - if (this.properties.getFormat() != FILES && !context.endsWith("/")) { - context = context + "/"; - } - - try { - Long currentIndex = this.consulIndexes.get(context); - if (currentIndex == null) { - currentIndex = -1L; - } - - if (log.isTraceEnabled()) { - log.trace("watching consul for context '" + context + "' with index " + currentIndex); - } - - // use the consul ACL token if found - String aclToken = this.properties.getAclToken(); - if (ObjectUtils.isEmpty(aclToken)) { - aclToken = null; - } - - Response> response = this.consul.getKVValues(context, aclToken, - new QueryParams(this.properties.getWatch().getWaitTime(), currentIndex)); - - // if response.value == null, response was a 404, otherwise it was a - // 200, reducing churn if there wasn't anything - if (response.getValue() != null && !response.getValue().isEmpty()) { - Long newIndex = response.getConsulIndex(); - - if (newIndex != null && !newIndex.equals(currentIndex)) { - // don't publish the same index again, don't publish the first - // time (-1) so index can be primed - if (!this.consulIndexes.containsValue(newIndex) && !currentIndex.equals(-1L)) { - if (log.isTraceEnabled()) { - log.trace("Context " + context + " has new index " + newIndex); - } - RefreshEventData data = new RefreshEventData(context, currentIndex, newIndex); - this.publisher.publishEvent(new RefreshEvent(this, data, data.toString())); - } - else if (log.isTraceEnabled()) { - log.trace("Event for index already published for context " + context); - } - this.consulIndexes.put(context, newIndex); - } - else if (log.isTraceEnabled()) { - log.trace("Same index for context " + context); - } - } - else if (log.isTraceEnabled()) { - log.trace("No value for context " + context); - } - - } - catch (Exception e) { - // only fail fast on the initial query, otherwise just log the error - if (this.firstTime && this.properties.isFailFast()) { - log.error("Fail fast is set and there was an error reading configuration from consul."); - ReflectionUtils.rethrowRuntimeException(e); - } - else if (log.isTraceEnabled()) { - log.trace("Error querying consul Key/Values for context '" + context + "'", e); - } - else if (log.isWarnEnabled()) { - // simplified one line log message in the event of an agent - // failure - log.warn("Error querying consul Key/Values for context '" + context + "'. Message: " - + e.getMessage()); - } - } - } - this.firstTime = false; - } - - public static class RefreshEventData { - - private final String context; - - private final Long prevIndex; - - private final Long newIndex; - - RefreshEventData(String context, Long prevIndex, Long newIndex) { - this.context = context; - this.prevIndex = prevIndex; - this.newIndex = newIndex; - } - - public String getContext() { - return this.context; - } - - public Long getPrevIndex() { - return this.prevIndex; - } - - public Long getNewIndex() { - return this.newIndex; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RefreshEventData that = (RefreshEventData) o; - return Objects.equals(this.context, that.context) && Objects.equals(this.prevIndex, that.prevIndex) - && Objects.equals(this.newIndex, that.newIndex); - } - - @Override - public int hashCode() { - return Objects.hash(this.context, this.prevIndex, this.newIndex); - } - - @Override - public String toString() { - return new ToStringCreator(this).append("context", this.context).append("prevIndex", this.prevIndex) - .append("newIndex", this.newIndex).toString(); - } - - } - -} diff --git a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulBootstrapper.java b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulBootstrapper.java deleted file mode 100644 index 25eb44c9..00000000 --- a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulBootstrapper.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.config; - -import java.util.function.BiFunction; -import java.util.function.Function; - -import com.ecwid.consul.v1.ConsulClient; - -import org.springframework.boot.BootstrapContext; -import org.springframework.boot.BootstrapRegistry; -import org.springframework.boot.BootstrapRegistryInitializer; -import org.springframework.boot.context.config.ConfigData; -import org.springframework.boot.context.config.ConfigDataLoaderContext; -import org.springframework.boot.context.properties.bind.Binder; -import org.springframework.cloud.consul.ConsulProperties; -import org.springframework.util.Assert; - -public class ConsulBootstrapper implements BootstrapRegistryInitializer { - - private Function consulClientFactory; - - private LoaderInterceptor loaderInterceptor; - - static BootstrapRegistryInitializer fromConsulProperties(Function factory) { - return registry -> registry.register(ConsulClient.class, context -> { - ConsulProperties properties = context.get(ConsulProperties.class); - return factory.apply(properties); - }); - } - - static BootstrapRegistryInitializer fromBootstrapContext(Function factory) { - return registry -> registry.register(ConsulClient.class, factory::apply); - } - - static ConsulBootstrapper create() { - return new ConsulBootstrapper(); - } - - // TODO: document there will be a ConsulProperties in BootstrapContext - public ConsulBootstrapper withConsulClientFactory(Function consulClientFactory) { - this.consulClientFactory = consulClientFactory; - return this; - } - - public ConsulBootstrapper withLoaderInterceptor(LoaderInterceptor loaderInterceptor) { - this.loaderInterceptor = loaderInterceptor; - return this; - } - - @Override - public void initialize(BootstrapRegistry registry) { - if (consulClientFactory != null) { - registry.register(ConsulClient.class, consulClientFactory::apply); - } - if (loaderInterceptor != null) { - registry.register(LoaderInterceptor.class, BootstrapRegistry.InstanceSupplier.of(loaderInterceptor)); - } - } - - public interface LoaderInterceptor extends Function { - - } - - @FunctionalInterface - public interface LoaderInvocation - extends BiFunction { - - } - - public static class LoadContext { - - private final ConfigDataLoaderContext loaderContext; - - private final ConsulConfigDataResource resource; - - private final Binder binder; - - private final LoaderInvocation invocation; - - LoadContext(ConfigDataLoaderContext loaderContext, ConsulConfigDataResource resource, Binder binder, - LoaderInvocation invocation) { - Assert.notNull(loaderContext, "loaderContext may not be null"); - Assert.notNull(resource, "resource may not be null"); - Assert.notNull(binder, "binder may not be null"); - Assert.notNull(invocation, "invocation may not be null"); - this.loaderContext = loaderContext; - this.resource = resource; - this.binder = binder; - this.invocation = invocation; - } - - public ConfigDataLoaderContext getLoaderContext() { - return this.loaderContext; - } - - public ConsulConfigDataResource getResource() { - return this.resource; - } - - public Binder getBinder() { - return this.binder; - } - - public LoaderInvocation getInvocation() { - return this.invocation; - } - - } - -} diff --git a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigAutoConfiguration.java b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigAutoConfiguration.java deleted file mode 100644 index 36256f9f..00000000 --- a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigAutoConfiguration.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.config; - -import com.ecwid.consul.v1.ConsulClient; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.consul.ConditionalOnConsulEnabled; -import org.springframework.cloud.endpoint.RefreshEndpoint; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.TaskScheduler; -import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; - -/** - * @author Spencer Gibb - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnConsulEnabled -@ConditionalOnProperty(name = "spring.cloud.consul.config.enabled", matchIfMissing = true) -@EnableConfigurationProperties -public class ConsulConfigAutoConfiguration { - - /** - * Name of the config watch task scheduler bean. - */ - public static final String CONFIG_WATCH_TASK_SCHEDULER_NAME = "configWatchTaskScheduler"; - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(RefreshEndpoint.class) - @ConditionalOnProperty(name = "spring.cloud.consul.config.watch.enabled", matchIfMissing = true) - protected static class ConsulRefreshConfiguration { - - @Bean - @ConditionalOnBean(ConsulConfigIndexes.class) - public ConfigWatch configWatch(ConsulConfigProperties properties, ConsulConfigIndexes indexes, - ConsulClient consul, @Qualifier(CONFIG_WATCH_TASK_SCHEDULER_NAME) TaskScheduler taskScheduler) { - return new ConfigWatch(properties, consul, indexes.getIndexes(), taskScheduler); - } - - @Bean(name = CONFIG_WATCH_TASK_SCHEDULER_NAME) - public TaskScheduler configWatchTaskScheduler() { - return new ThreadPoolTaskScheduler(); - } - - } - -} diff --git a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigBootstrapConfiguration.java b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigBootstrapConfiguration.java deleted file mode 100644 index 3a1c5f67..00000000 --- a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigBootstrapConfiguration.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.config; - -import com.ecwid.consul.v1.ConsulClient; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.consul.ConditionalOnConsulEnabled; -import org.springframework.cloud.consul.ConsulAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.core.env.Environment; -import org.springframework.util.ObjectUtils; - -/** - * @author Spencer Gibb - * @author Edvin Eriksson - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnConsulEnabled -public class ConsulConfigBootstrapConfiguration { - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties - @Import(ConsulAutoConfiguration.class) - @ConditionalOnProperty(name = "spring.cloud.consul.config.enabled", matchIfMissing = true) - protected static class ConsulPropertySourceConfiguration { - - @Autowired - private ConsulClient consul; - - @Bean - @ConditionalOnMissingBean - public ConsulConfigProperties consulConfigProperties(Environment env) { - ConsulConfigProperties properties = new ConsulConfigProperties(); - if (ObjectUtils.isEmpty(properties.getName())) { - properties.setName(env.getProperty("spring.application.name", "application")); - } - return properties; - } - - @Bean - public ConsulPropertySourceLocator consulPropertySourceLocator(ConsulConfigProperties consulConfigProperties) { - return new ConsulPropertySourceLocator(this.consul, consulConfigProperties); - } - - } - -} diff --git a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigDataLoader.java b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigDataLoader.java deleted file mode 100644 index f1d7cd54..00000000 --- a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigDataLoader.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.consul.config; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; - -import com.ecwid.consul.v1.ConsulClient; -import org.apache.commons.logging.Log; - -import org.springframework.boot.context.config.ConfigData; -import org.springframework.boot.context.config.ConfigData.Option; -import org.springframework.boot.context.config.ConfigData.Options; -import org.springframework.boot.context.config.ConfigDataLoader; -import org.springframework.boot.context.config.ConfigDataLoaderContext; -import org.springframework.boot.context.config.ConfigDataResourceNotFoundException; -import org.springframework.boot.context.properties.bind.Binder; -import org.springframework.boot.logging.DeferredLogFactory; -import org.springframework.cloud.consul.config.ConsulBootstrapper.LoadContext; -import org.springframework.cloud.consul.config.ConsulBootstrapper.LoaderInterceptor; -import org.springframework.util.StringUtils; - -public class ConsulConfigDataLoader implements ConfigDataLoader { - - private static final EnumSet