diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f51ef4d --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @TrogonStack/trogon-eventstore-maintainers diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 06b004b..4a3380d 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -1,97 +1,97 @@ -name: Bug report -description: Help us improve the Java client -labels: - - triage -body: - - type: textarea - id: current-behavior - attributes: - label: 🐛 Current behavior - description: A clear and concise description of what the bug is. - validations: - required: true - - type: textarea - id: reproduction-steps - attributes: - label: 🔍 Steps to reproduce - description: Steps to reproduce the behavior. - placeholder: | - 1. Go to ... - 2. Click on ... - 3. Scroll down to ... - 4. See error - - You can attach screenshots by dragging and dropping, or selecting and pasting them in the text field. - validations: - required: true - - type: input - id: reproduction-links - attributes: - label: Reproducible link - description: A link to a minimal reproducible example. This could be a GitHub repository, CodeSandbox, or any other online code editor. - placeholder: e.g, github.com/company/repo - validations: - required: true - - type: textarea - id: expected-behavior - attributes: - label: 💭 Expected behavior - description: A clear and concise description of what you expected to happen. - validations: - required: true - - type: input - id: client-version - attributes: - label: Package version - description: What version of the client you're experiencing the issue with. - placeholder: e.g., kurrentdb-client 1.1.2 - validations: - required: true - - type: input - id: kurrentdb-version - attributes: - label: KurrentDB Version - description: What version of the database you are using. - placeholder: e.g., KurrentDB v24.10 - validations: - required: true - - type: input - id: connection - attributes: - label: Connection string - description: What connection string you're using. Hide and sensitive information if necessary. - placeholder: e.g., kurrentdb://admin:changeit@localhost:2113 - validations: - required: true - - type: dropdown - id: deployment-environment - attributes: - label: ☁️ Deployment Environment - description: How is KurrentDB deployed? - options: - - Single-node (Docker) - - Single-node (Bare metal/VM) - - Multi-node cluster (On-prem) - - Multi-node cluster (Cloud) - - Managed KurrentDB Cloud - - Other (please specify below) - validations: - required: true - - type: input - id: deployment-other - attributes: - label: Other Deployment Details - description: If you selected "Other," please specify your deployment setup. - placeholder: e.g., Kubernetes with custom networking - - type: input - id: os - attributes: - label: Operating system - placeholder: e.g., macOS 13.1 - - type: checkboxes - attributes: - label: Code of Conduct - description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/algolia/.github/blob/main/CODE_OF_CONDUCT.md). - options: - - label: I agree to follow this project's Code of Conduct - required: true +name: Bug report +description: Help us improve the Java client +labels: + - triage +body: + - type: textarea + id: current-behavior + attributes: + label: 🐛 Current behavior + description: A clear and concise description of what the bug is. + validations: + required: true + - type: textarea + id: reproduction-steps + attributes: + label: 🔍 Steps to reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. Go to ... + 2. Click on ... + 3. Scroll down to ... + 4. See error + + You can attach screenshots by dragging and dropping, or selecting and pasting them in the text field. + validations: + required: true + - type: input + id: reproduction-links + attributes: + label: Reproducible link + description: A link to a minimal reproducible example. This could be a GitHub repository, CodeSandbox, or any other online code editor. + placeholder: e.g, github.com/company/repo + validations: + required: true + - type: textarea + id: expected-behavior + attributes: + label: 💭 Expected behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + - type: input + id: client-version + attributes: + label: Package version + description: What version of the client you're experiencing the issue with. + placeholder: e.g., trogon-eventstore-client 1.1.2 + validations: + required: true + - type: input + id: kurrentdb-version + attributes: + label: TrogonEventStore Version + description: What version of the database you are using. + placeholder: e.g., TrogonEventStore v24.10 + validations: + required: true + - type: input + id: connection + attributes: + label: Connection string + description: What connection string you're using. Hide and sensitive information if necessary. + placeholder: e.g., trogon-eventstore://admin:changeit@localhost:2113 + validations: + required: true + - type: dropdown + id: deployment-environment + attributes: + label: ☁️ Deployment Environment + description: How is TrogonEventStore deployed? + options: + - Single-node (Docker) + - Single-node (Bare metal/VM) + - Multi-node cluster (On-prem) + - Multi-node cluster (Cloud) + - Managed TrogonEventStore Cloud + - Other (please specify below) + validations: + required: true + - type: input + id: deployment-other + attributes: + label: Other Deployment Details + description: If you selected "Other," please specify your deployment setup. + placeholder: e.g., Kubernetes with custom networking + - type: input + id: os + attributes: + label: Operating system + placeholder: e.g., macOS 13.1 + - type: checkboxes + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/algolia/.github/blob/main/CODE_OF_CONDUCT.md). + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 5e587d7..7171d34 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,8 @@ -blank_issues_enabled: false -contact_links: - - name: Feature Request - url: https://github.com/kurrent-io/KurrentDB-Client-Java/discussions/new?category=ideas&labels=triage&title=Feature%20request%3A%20 - about: Request a feature to add to the client - - name: Ask a Question - url: https://github.com/kurrent-io/KurrentDB-Client-Java/discussions/new?category=q-a&labels=triage +blank_issues_enabled: false +contact_links: + - name: Feature Request + url: https://github.com/TrogonStack/TrogonEventStore-Client-Java/discussions/new?category=ideas&labels=triage&title=Feature%20request%3A%20 + about: Request a feature to add to the client + - name: Ask a Question + url: https://github.com/TrogonStack/TrogonEventStore-Client-Java/discussions/new?category=q-a&labels=triage about: Ask questions and discuss with other community members. \ No newline at end of file diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 0000000..7635c38 --- /dev/null +++ b/.github/release-please-config.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "bootstrap-sha": "06ed98a163cbef376b50d0cd195716b8d7e58135", + "signoff": "SHT Bot <61149376+sht-bot@users.noreply.github.com>", + "packages": { + ".": { + "release-type": "java", + "package-name": "trogon-eventstore-client", + "component": "trogon-eventstore-client", + "include-component-in-tag": false, + "include-v-in-tag": true, + "skip-snapshot": true, + "pull-request-title-pattern": "chore${scope}: release ${version}", + "extra-files": [ + { + "type": "generic", + "path": "build.gradle" + } + ], + "bump-minor-pre-major": false, + "bump-patch-for-minor-pre-major": false + } + } +} diff --git a/.github/release-please-manifest.json b/.github/release-please-manifest.json new file mode 100644 index 0000000..b985ff6 --- /dev/null +++ b/.github/release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1" +} diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml deleted file mode 100644 index 0d56702..0000000 --- a/.github/workflows/build-docs.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Build Production Site - -on: - push: - branches: [release/**/**] - paths: - - '**.md' - -jobs: - dispatch: - runs-on: ubuntu-latest - steps: - - name: Trigger build - run: curl -X POST -d {} "${{ secrets.CLOUDFLARE_BUILD_HOOK }}" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index b13e573..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Build and Run Tests -on: - workflow_call: - -jobs: - build: - name: Build - strategy: - fail-fast: false - matrix: - java: [ 8, 11, 17 ] - runs-on: ubuntu-latest - - steps: - - name: Check Out Sources - uses: actions/checkout@v4 - - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - with: - gradle-version: 8.13 - - - name: Build - run: ./gradlew compileTest - - # Tests that do not require a database connection. - - name: Misc tests - run: ./gradlew ci --tests MiscTests diff --git a/.github/workflows/cherry-pick-pr-for-label.yml b/.github/workflows/cherry-pick-pr-for-label.yml deleted file mode 100644 index b60bec4..0000000 --- a/.github/workflows/cherry-pick-pr-for-label.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Cherry pick PR commits for label -on: - pull_request_target: - types: [closed] -jobs: - cherry_pick_pr_for_label: - name: Cherry pick PR commits for label - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Cherry Pick PR for label - uses: kurrent-io/Automations/cherry-pick-pr-for-label@master - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 227acc4..9d9ae80 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,23 +1,55 @@ -name: CI -on: - pull_request: - paths-ignore: - - "docs/**" - - "samples/**" - - "**.md" - push: - branches: - - trunk - schedule: - - cron: '0 0 * * 0' # Run every Sunday at midnight UTC - -jobs: - build: - uses: ./.github/workflows/build.yml - - ci: - name: Tests (CI) - uses: ./.github/workflows/tests.yml - with: - runtime: ci - secrets: inherit +name: CI + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + build: + name: Java ${{ matrix.java }} + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + java: + - "17" + - "21" + steps: + - name: Checkout + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false + - name: Set up Java + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.7.1 + with: + distribution: temurin + java-version: ${{ matrix.java }} + - name: Set up Gradle + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.4 + - name: Compile and run unit tests + run: ./gradlew clean compileTestJava ci --tests MiscTests + + package: + name: Package + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false + - name: Set up Java + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.7.1 + with: + distribution: temurin + java-version: "21" + - name: Set up Gradle + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.4 + - name: Build publication + run: ./gradlew assemble generatePomFileForMavenPublication diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..7f31c9a --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,39 @@ +name: Integration Tests + +on: + pull_request: + push: + branches: + - main + workflow_dispatch: + inputs: + server_image: + description: Fully qualified TrogonEventStore container image + required: false + default: ghcr.io/trogonstack/trogoneventstore:ci + type: string + +permissions: + contents: read + +jobs: + integration: + name: Integration + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false + - name: Set up Java + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.7.1 + with: + distribution: temurin + java-version: "21" + - name: Set up Gradle + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.4 + - name: Run single-node integration tests + env: + TROGON_EVENTSTORE_IMAGE: ${{ inputs.server_image || 'ghcr.io/trogonstack/trogoneventstore:ci' }} + run: ./gradlew ci --tests StreamsTests --tests PersistentSubscriptionsTests --tests TelemetryTests diff --git a/.github/workflows/load-configuration.yml b/.github/workflows/load-configuration.yml deleted file mode 100644 index a299558..0000000 --- a/.github/workflows/load-configuration.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Load KurrentDB Runtime Configuration -on: - workflow_call: - inputs: - runtime: - description: "The runtime's name. Current options are: `ci`, `previous-lts`, `latest`" - type: string - - outputs: - runtime: - description: The runtime's name - value: ${{ inputs.runtime }} - - registry: - description: The Docker registry - value: ${{ jobs.load.outputs.registry }} - - image: - description: The Docker image - value: ${{ jobs.load.outputs.image }} - - tag: - description: The Docker image tag - value: ${{ jobs.load.outputs.tag }} - - full_image_name: - description: The full Docker image name (including registry, image, and tag) - value: ${{ jobs.load.outputs.full_image_name }} - -jobs: - load: - runs-on: ubuntu-latest - outputs: - registry: ${{ steps.set.outputs.registry }} - image: ${{ steps.set.outputs.image }} - tag: ${{ steps.set.outputs.tag }} - full_image_name: ${{ steps.set.outputs.full_image_name }} - - steps: - - name: Set KurrentDB Runtime Configuration Properties - id: set - run: | - echo "registry=${{ fromJSON(vars.KURRENTDB_DOCKER_IMAGES)[inputs.runtime].registry }}" >> $GITHUB_OUTPUT - echo "tag=${{ fromJSON(vars.KURRENTDB_DOCKER_IMAGES)[inputs.runtime].tag }}" >> $GITHUB_OUTPUT - echo "image=${{ fromJSON(vars.KURRENTDB_DOCKER_IMAGES)[inputs.runtime].image }}" >> $GITHUB_OUTPUT - echo "full_image_name=${{ fromJSON(vars.KURRENTDB_DOCKER_IMAGES)[inputs.runtime].fullname }}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/lts.yml b/.github/workflows/lts.yml deleted file mode 100644 index 3c8fb25..0000000 --- a/.github/workflows/lts.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: LTS -on: - pull_request: - paths-ignore: - - "docs/**" - - "samples/**" - - "**.md" - push: - branches: - - trunk - schedule: - - cron: '0 0 * * 0' # Run every Sunday at midnight UTC - -jobs: - build: - uses: ./.github/workflows/build.yml - - lts: - name: Tests (LTS) - uses: ./.github/workflows/tests.yml - with: - runtime: lts - secrets: inherit - - # Will be removed in the future - plugins-tests: - name: Plugins Tests - - uses: ./.github/workflows/plugins-tests.yml - with: - registry: docker.eventstore.com/eventstore-ee - image: eventstoredb-commercial - tag: 24.2.0-jammy - secrets: inherit diff --git a/.github/workflows/plugins-tests.yml b/.github/workflows/plugins-tests.yml deleted file mode 100644 index fed0338..0000000 --- a/.github/workflows/plugins-tests.yml +++ /dev/null @@ -1,115 +0,0 @@ -name: enterprise plugins tests workflow - -on: - workflow_call: - inputs: - registry: - required: true - type: string - image: - required: true - type: string - tag: - required: true - type: string - -jobs: - single_node: - name: Single Node - - strategy: - fail-fast: false - matrix: - test: [ Plugins ] - - runs-on: ubuntu-latest - steps: - - name: Login to Cloudsmith - uses: docker/login-action@v3 - with: - registry: docker.eventstore.com - username: ${{ secrets.CLOUDSMITH_CICD_USER }} - password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }} - - - uses: actions/checkout@v4 - - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - with: - gradle-version: 8.13 - - - name: Generate certificates - run: | - docker compose --file configure-tls-for-tests.yml up - docker compose --file configure-user-certs-for-tests.yml up - - - name: Execute Gradle build - run: ./gradlew ci --tests ${{ matrix.test }}Tests - env: - KURRENTDB_IMAGE: ${{inputs.registry}}/${{ inputs.image }}:${{ inputs.tag }} - SECURE: true - - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: esdb_logs.tar.gz - path: db-client-java/esdb_logs.tar.gz - if-no-files-found: error - - cluster: - name: Cluster - - strategy: - fail-fast: false - matrix: - test: [ Plugins ] - - runs-on: ubuntu-latest - steps: - - name: Login to Cloudsmith - uses: docker/login-action@v3 - with: - registry: docker.eventstore.com - username: ${{ secrets.CLOUDSMITH_CICD_USER }} - password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }} - - - uses: actions/checkout@v4 - - - name: Enable plugins - run: echo "EventStore__Plugins__UserCertificates__Enabled=true" >> vars.env - - - name: Set up cluster with Docker Compose - run: docker compose up -d - env: - KURRENTDB_DOCKER_REGISTRY: ${{ inputs.registry }} - KURRENTDB_DOCKER_IMAGE: ${{ inputs.image }} - KURRENTDB_DOCKER_TAG: ${{ inputs.tag }} - - - name: Generate user certificates - run: docker compose --file configure-user-certs-for-tests.yml up - - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - with: - gradle-version: 8.13 - - - name: Execute Gradle build - run: ./gradlew ci --tests ${{ matrix.test }}Tests - env: - SECURE: true - CLUSTER: true - - - name: Shutdown cluster - run: docker compose down \ No newline at end of file diff --git a/.github/workflows/previous-lts.yml b/.github/workflows/previous-lts.yml deleted file mode 100644 index df1d75e..0000000 --- a/.github/workflows/previous-lts.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Previous LTS -on: - pull_request: - paths-ignore: - - "docs/**" - - "samples/**" - - "**.md" - push: - branches: - - trunk - schedule: - - cron: '0 0 * * 0' # Run every Sunday at midnight UTC - -jobs: - build: - uses: ./.github/workflows/build.yml - - previous-lts: - name: Tests (Previous LTS) - uses: ./.github/workflows/tests.yml - with: - runtime: previous-lts - secrets: inherit diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ca5ea0a..a481d1c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,46 +1,31 @@ -name: Publish - -on: - push: - tags: - - 'release/*' - workflow_dispatch: - inputs: - dry_run: - description: 'Perform a dry run release' - type: boolean - required: false - default: true - -jobs: - publish: - name: Publish - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - with: - gradle-version: 8.13 - - - name: Release - env: - JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} - JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} - JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} - JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} - JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }} - JRELEASER_GENERIC_TOKEN: ${{ secrets.GH_PAT }} - run: | - if [ "${{ inputs.dry_run }}" = "true" ]; then - ./gradlew publish jreleaserFullRelease -S --dryrun - else - ./gradlew publish jreleaserFullRelease -S - fi +name: Publish + +on: + push: + tags: + - "v*" + +permissions: + contents: read + packages: write + +jobs: + publish: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false + - name: Set up Java + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.7.1 + with: + distribution: temurin + java-version: "21" + - name: Set up Gradle + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.4 + - name: Publish to GitHub Packages + env: + GITHUB_TOKEN: ${{ github.token }} + run: ./gradlew publishMavenPublicationToGitHubPackagesRepository diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml deleted file mode 100644 index 55e9573..0000000 --- a/.github/workflows/qa.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: QA - -on: - workflow_dispatch: - inputs: - image: - description: Docker full image name - required: true - type: string - default: "docker.kurrent.io/eventstore/eventstoredb-ee:lts" - -jobs: - test: - name: Test - uses: ./.github/workflows/tests.yml - with: - image: ${{ inputs.image }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..e61f84d --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,24 @@ +name: Release Please + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: write + issues: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Create release pull request or release + uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1 + with: + token: ${{ secrets.GH_PAT_RELEASE_PLEASE_ACTION }} + config-file: .github/release-please-config.json + manifest-file: .github/release-please-manifest.json diff --git a/.github/workflows/semconv.yml b/.github/workflows/semconv.yml new file mode 100644 index 0000000..eca8092 --- /dev/null +++ b/.github/workflows/semconv.yml @@ -0,0 +1,74 @@ +name: SemConv + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + - reopened + +permissions: + pull-requests: read + +jobs: + validate: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Validate pull request title and commits + shell: bash + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + REPOSITORY: ${{ github.repository }} + run: | + pattern='^(feat|fix|chore)(\([A-Za-z0-9][A-Za-z0-9._/-]*\))?!?: .+' + + if [[ ! "$PR_TITLE" =~ $pattern ]]; then + echo "Invalid pull request title: $PR_TITLE" >&2 + exit 1 + fi + + if ! commit_records=$(gh api --paginate \ + "repos/$REPOSITORY/pulls/$PR_NUMBER/commits" \ + --jq '.[] | { + parent_count: (.parents | length), + subject: (.commit.message | split("\n")[0]) + }'); then + echo "Unable to enumerate pull request commits." >&2 + exit 1 + fi + + if [ -z "$commit_records" ]; then + echo "Pull request contains no commits." >&2 + exit 1 + fi + + invalid_commits=0 + non_merge_commits=0 + while IFS= read -r record; do + if ! parent_count=$(jq -er '.parent_count' <<< "$record") || + ! subject=$(jq -er '.subject' <<< "$record"); then + echo "Unable to parse pull request commit metadata." >&2 + exit 1 + fi + + if [ "$parent_count" -gt 1 ]; then + continue + fi + + non_merge_commits=$((non_merge_commits + 1)) + if [[ ! "$subject" =~ $pattern ]]; then + echo "Invalid commit subject: $subject" >&2 + invalid_commits=1 + fi + done <<< "$commit_records" + + if [ "$non_merge_commits" -eq 0 ]; then + echo "Pull request contains no non-merge commits." >&2 + exit 1 + fi + + exit "$invalid_commits" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 92ce26e..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,143 +0,0 @@ -name: tests workflow - -on: - workflow_call: - inputs: - runtime: - required: true - type: string - -jobs: - load_configuration: - uses: ./.github/workflows/load-configuration.yml - with: - runtime: ${{ inputs.runtime }} - - single_node: - needs: load_configuration - name: Single node - - strategy: - fail-fast: false - matrix: - test: [Streams, PersistentSubscriptions, Telemetry, MultiStreamAppend] - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Login to Cloudsmith - uses: docker/login-action@v3 - with: - registry: docker.kurrent.io - username: ${{ secrets.CLOUDSMITH_CICD_USER }} - password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }} - - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - with: - gradle-version: 8.13 - - - name: Execute Gradle build - run: ./gradlew ci --tests ${{ matrix.test }}Tests - env: - KURRENTDB_IMAGE: ${{ needs.load_configuration.outputs.full_image_name }} - - secure: - needs: load_configuration - name: Secure - - strategy: - fail-fast: false - matrix: - test: [Streams, PersistentSubscriptions] - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Login to Cloudsmith - uses: docker/login-action@v3 - with: - registry: docker.kurrent.io - username: ${{ secrets.CLOUDSMITH_CICD_USER }} - password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }} - - - name: Generate certificates - run: docker compose --file configure-tls-for-tests.yml up - - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - with: - gradle-version: 8.13 - - - name: Execute Gradle build - run: ./gradlew ci --tests ${{ matrix.test }}Tests - env: - KURRENTDB_IMAGE: ${{ needs.load_configuration.outputs.full_image_name }} - SECURE: true - - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: esdb_logs.tar.gz - path: /tmp/esdb_logs.tar.gz - - cluster: - needs: load_configuration - name: Cluster - - strategy: - fail-fast: false - matrix: - test: [Streams, PersistentSubscriptions, MultiStreamAppend] - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Login to Cloudsmith - uses: docker/login-action@v3 - with: - registry: docker.kurrent.io - username: ${{ secrets.CLOUDSMITH_CICD_USER }} - password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }} - - - name: Set up cluster with Docker Compose - run: docker compose up -d - env: - KURRENTDB_DOCKER_REGISTRY: ${{ needs.load_configuration.outputs.registry }} - KURRENTDB_DOCKER_IMAGE: ${{ needs.load_configuration.outputs.image }} - KURRENTDB_DOCKER_TAG: ${{ needs.load_configuration.outputs.tag }} - - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - with: - gradle-version: 8.13 - - - name: Execute Gradle build - run: ./gradlew ci --tests ${{ matrix.test }}Tests - env: - CLUSTER: true - SECURE: true - - - name: Shutdown cluster - run: docker compose down \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d3794a..06f0180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,3 @@ -This changelog is no longer maintained. The information has been moved to the [GitHub release notes](https://github.com/kurrent-io/KurrentDB-Client-Java/releases) page. +# Changelog + +Release Please maintains this file from Conventional Commits. diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.md index d9e2603..22c237a 100644 --- a/CODE-OF-CONDUCT.md +++ b/CODE-OF-CONDUCT.md @@ -1,6 +1,6 @@ # Contributor Covenant Code of Conduct -`KurrentDB-Client-Java` follows the widely-adopted Contributor Covenant Code of Conduct. +`TrogonEventStore-Client-Java` follows the widely adopted Contributor Covenant Code of Conduct. ## Our Pledge @@ -62,7 +62,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -[`abuse@eventstore.com`](mailto:abuse@eventstore.com). +through the repository maintainers on GitHub. All complaints will be reviewed and investigated promptly and fairly. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0796e52..97836cd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,54 +1,15 @@ -# Contributing to `KurrentDB-Client-Java` +# Contributing -Welcome to the Kurrent community, and thank you for contributing! The following guide outlines the basics of how to get involved. Pull requests to update and expand this guide are very welcome! +Contributions to TrogonEventStore-Client-Java are welcome. -## Getting Started +By submitting a contribution, you represent that you have the right to license it under Apache-2.0 and agree that it is provided under that license. -### Community Guidelines +Use Conventional Commit subjects with `feat`, `fix`, or `chore`, and include a DCO sign-off in every commit. -We want the Kurrent community to be as welcoming and inclusive as possible, and have adopted a [Code of Conduct][conduct] that we ask all community members to read and observe. +Run the local verification before opening a pull request: -### Licensing +```shell +./gradlew clean check +``` -`KurrentDB-Client-Java` is licensed under the [Apache-2.0][apache2] license. By submitting a pull request, you represent that you have right to license your contribution to Kurrent, Inc and the community, and that by submitting a patch your contributions are licensed under the Apache-2.0 license. - -## Contributing - -### Security Issues - -Please disclose issues which you believe to be a security threat _by e-mail_ to [security@kurrent.io](mailto:security@kurrent.io) rather than opening a public issue. - -### Reporting Issues - -Issues may be reported via the [GitHub Repository][github-repo]. When reporting issues, please ensure that you include relevant information which can help diagnose the problem. This includes: - -- The version of `KurrentDB-Client-Java` - including a commit SHA if using a local build - -- The operating system on which the issue is exhibited (on Unix, the output of `uname -a`) - -- The JVM version on which the issue is exhibited (i.e. the output of `java -version`) - -- Any steps which required to reproduce the issue, including non-default KurrentDB server configuration. - -### Writing a Pull Request - -A good client pull request makes a single set of coherent changes, with testing, documentation and a commit message which follows our [Commit Message Template][commit-template]. - -All contributions to the project are submitted, reviewed and merged via pull requests to the [GitHub repository][github-repo]. We strongly encourage use of [draft pull request][drafts] to open up early discussion about contributions which are not yet ready for review - this also helps reduce work duplicated between community members. - -### Checklist - -Please ensure that the following steps have been undertaken before marking pull requests as "Ready for Review": - -- Rebase the pull request against the target branch, and ensure there are no merge commits. - -- Ensure the build works and tests pass locally using `./gradlew build` (on Unix) or `gradlew build` (on Windows). CI will test all platforms. - -- Ensure that commits are atomic units of work, and that the message follows our [Commit Message Template][commit-template]. A good way to do this is to configure your local clone of the repository to use our included template, by running: `git config commit.template .git.commit.template` in the root directory of the clone. - - -[conduct]: https://github.com/kurrent-io/KurrentDB-Client-Java/tree/master/CODE-OF-CONDUCT.md -[apache2]: https://www.apache.org/licenses/LICENSE-2.0 -[commit-template]: https://github.com/kurrent-io/KurrentDB-Client-Java/tree/master/.git.commit.template -[github-repo]: https://github.com/kurrent-io/KurrentDB-Client-Java -[drafts]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests +Report security vulnerabilities through the repository's private GitHub security advisory flow rather than a public issue. diff --git a/KurrentLogo-Black.png b/KurrentLogo-Black.png deleted file mode 100644 index 0ff9694..0000000 Binary files a/KurrentLogo-Black.png and /dev/null differ diff --git a/KurrentLogo-Plum.png b/KurrentLogo-Plum.png deleted file mode 100644 index a27a816..0000000 Binary files a/KurrentLogo-Plum.png and /dev/null differ diff --git a/KurrentLogo-White.png b/KurrentLogo-White.png deleted file mode 100644 index e49bfb0..0000000 Binary files a/KurrentLogo-White.png and /dev/null differ diff --git a/LICENSE b/LICENSE index 0fdf685..fbeae2f 100644 --- a/LICENSE +++ b/LICENSE @@ -187,6 +187,7 @@ identification within third-party archives. Copyright 2011-2025 Kurrent, Inc + Copyright 2026 Straw Hat, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 3f1f690..cfec537 100644 --- a/README.md +++ b/README.md @@ -1,72 +1,56 @@ - - - - - Kurrent - - +# TrogonEventStore Java Client -# KurrentDB Java Client +[![CI](https://github.com/TrogonStack/TrogonEventStore-Client-Java/actions/workflows/ci.yml/badge.svg)](https://github.com/TrogonStack/TrogonEventStore-Client-Java/actions/workflows/ci.yml) -[![CI](https://github.com/kurrent-io/KurrentDB-Client-Java/actions/workflows/ci.yml/badge.svg)](https://github.com/kurrent-io/KurrentDB-Client-Java/actions/workflows/ci.yml) -[![LTS](https://github.com/kurrent-io/KurrentDB-Client-Java/actions/workflows/lts.yml/badge.svg)](https://github.com/kurrent-io/KurrentDB-Client-Java/actions/workflows/lts.yml) -[![Previous LTS](https://github.com/kurrent-io/KurrentDB-Client-Java/actions/workflows/previous-lts.yml/badge.svg)](https://github.com/kurrent-io/KurrentDB-Client-Java/actions/workflows/previous-lts.yml) +The Java client for [TrogonEventStore](https://github.com/TrogonStack/TrogonEventStore), compatible with Java 8 and newer. -KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its -event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves -distributed messaging challenges and ensures data consistency. +## Install -This repository contains an [KurrentDB](https://kurrent.io) Client SDK written in Java for use with languages on the -JVM. It is compatible with Java 8 and above. +Packages are published to GitHub Packages under `io.trogonstack:trogon-eventstore-client`. -## Access to binaries +```groovy +repositories { + maven { + url = uri("https://maven.pkg.github.com/TrogonStack/TrogonEventStore-Client-Java") + credentials { + username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_ACTOR") + password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN") + } + } +} -Kurrent, Inc publishes GA (general availability) versions -to [Maven Central](https://search.maven.org/artifact/io.kurrent/kurrentdb-client). +dependencies { + implementation "io.trogonstack:trogon-eventstore-client:VERSION" +} +``` -## KurrentDB Server Compatibility +GitHub Packages requires authentication. Use a classic personal access token with `read:packages` outside GitHub Actions. Do not commit credentials or a credential-bearing Gradle properties file. -This client is compatible with version `20.6.1` upwards. +## Connect -Server setup instructions can be found in -the [docs](https://developers.kurrent.io/server/v25.0/quick-start/installation), follow the docker setup for the -simplest configuration. +```java +import io.trogonstack.eventstore.client.TrogonEventStoreClient; +import io.trogonstack.eventstore.client.TrogonEventStoreClientSettings; +import io.trogonstack.eventstore.client.TrogonEventStoreConnectionString; -### Documentation +TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString.parseOrThrow( + "trogon-eventstore://localhost:2113?tls=false" +); +TrogonEventStoreClient client = TrogonEventStoreClient.create(settings); +``` -* [Samples](https://github.com/kurrent-io/KurrentDB-Client-Java/tree/trunk/src/test/java/io/kurrent/dbclient/samples) +Use `trogon-eventstore+discover://` for DNS or gossip discovery. -## Communities +## Development -[Join our global community](https://www.kurrent.io/community) of developers. +The project uses the checked-in Gradle wrapper. -- [Discuss](https://discuss.kurrent.io/) -- [Discord (Kurrent)](https://discord.gg/Phn9pmCw3t) -- [Discord (ddd-cqrs-es)](https://discord.com/invite/sEZGSHNNbH) +```shell +./gradlew clean check +``` -## Contributing +Integration tests use `ghcr.io/trogonstack/trogoneventstore:ci` by default. Override it with `TROGON_EVENTSTORE_IMAGE`. -Development is done on the `main` branch. -We attempt to do our best to ensure that the history remains clean and to do so, we generally ask contributors to squash -their commits into a set or single logical commit. +## License -- [Create an issue](https://github.com/kurrent-io/KurrentDB-Client-Java/issues) -- [Documentation](https://docs.kurrent.io/) -- [Contributing guide](https://github.com/kurrent-io/KurrentDB-Client-Java/blob/main/CONTRIBUTING.md) - -### Running the tests - -The client is built using [`Gradle 8.13`](https://gradle.org). Integration tests run against a server using Docker. - -Tests are written using [TestContainers](https://www.testcontainers.org/) and require [Docker](https://www.docker.com/) -to be installed. - -Specific docker images can be specified via the environment variable `KURRENTDB_IMAGE`. - -## More resources - -- [Release notes](https://kurrent.io/blog/release-notes) -- [Beginners Guide to Event Sourcing](https://kurrent.io/event-sourcing) -- [Articles](https://kurrent.io/blog) -- [Webinars](https://kurrent.io/webinars) -- [Contact us](https://kurrent.io/contact) +Licensed under Apache-2.0. See [LICENSE](LICENSE). diff --git a/build.gradle b/build.gradle index f921d70..e2e3a15 100644 --- a/build.gradle +++ b/build.gradle @@ -10,8 +10,6 @@ plugins { id 'com.google.protobuf' version '0.9.4' id 'idea' id 'maven-publish' - id 'signing' - id 'org.jreleaser' version '1.17.0' } def ENV = System.getenv() @@ -24,8 +22,8 @@ tasks.withType(JavaCompile) { options.compilerArgs += ['-Xlint:deprecation', '-Xlint:unchecked'] } -group = 'io.kurrent' -version = '1.2.1' +group = 'io.trogonstack' +version = '0.0.1' // x-release-please-version java { withSourcesJar() @@ -101,7 +99,7 @@ tasks.withType(Test).configureEach { } tasks.register("generateCertificates", Exec) { - description = "Generates SSL certificates to start a secured ESDB server" + description = "Generates SSL certificates to start a secured TrogonEventStore server" commandLine 'docker', 'compose', '--file', './configure-tls-for-tests.yml', 'up' } @@ -111,12 +109,12 @@ tasks.register("generateUserCertificates", Exec) { } tasks.register("startDockerCompose", Exec) { - description = "Starts ESDB cluster" + description = "Starts the TrogonEventStore cluster" commandLine 'docker', 'compose', '--file', './docker-compose.yml', 'up', '-d' } tasks.register("stopDockerCompose", Exec) { - description = "Stop ESDB cluster" + description = "Stops the TrogonEventStore cluster" commandLine 'docker', 'compose', '--file', './docker-compose.yml', 'down' } @@ -207,47 +205,33 @@ javadoc { failOnError = false } -tasks.register('checkVersion') { - doFirst { - def xml = new URL( - 'https://repo.maven.apache.org/maven2/dev/aoqia/leaf/installer/maven-metadata.xml').text - def metadata = new groovy.xml.XmlSlurper().parseText(xml) - def versions = metadata.versioning.versions.version*.text(); - if (versions.contains(version)) { - throw new RuntimeException("${version} has already been released!") - } - } -} -publish.mustRunAfter checkVersion - publishing { publications { maven(MavenPublication) { - groupId = 'io.kurrent' - artifactId = 'kurrentdb-client' + groupId = 'io.trogonstack' + artifactId = 'trogon-eventstore-client' from components.java pom { - name = 'KurrentDB gRPC Java client' - description = 'KurrentDB gRPC Java client' - url = 'https://kurrent.io' + name = 'TrogonEventStore Java Client' + description = 'Java client for TrogonEventStore' + url = 'https://github.com/TrogonStack/TrogonEventStore-Client-Java' scm { - connection = 'scm:git:https://github.com/kurrent-io/KurrentDB-Client-Java.git' - developerConnection = 'scm:git:ssh:https://github.com/kurrent-io/KurrentDB-Client-Java.git' - url = 'https://github.com/kurrent-io/KurrentDB-Client-Java' + connection = 'scm:git:https://github.com/TrogonStack/TrogonEventStore-Client-Java.git' + developerConnection = 'scm:git:ssh://git@github.com/TrogonStack/TrogonEventStore-Client-Java.git' + url = 'https://github.com/TrogonStack/TrogonEventStore-Client-Java' } licenses { license { name = 'The Apache License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' } } developers { developer { - id = 'ylaupa' - name = 'Yorick Laupa' - email = 'yorick.laupa@eventstore.com' + id = 'straw-hat-team' + name = 'Straw Hat, LLC' } } } @@ -255,65 +239,11 @@ publishing { } repositories { maven { - name = "StagingDeploy" - url = layout.buildDirectory.dir('staging-deploy') - } - } -} - -jreleaser { - project { - copyright = 'Kurrent, Inc' - description = 'Kurrent gRPC Java client' - } - signing { - active = 'ALWAYS' - armored = true - passphrase = ENV.JRELEASER_GPG_PASSPHRASE - publicKey = ENV.JRELEASER_GPG_PUBLIC_KEY - secretKey = ENV.JRELEASER_GPG_SECRET_KEY - } - deploy { - maven { - mavenCentral { - sonatype { - active = 'ALWAYS' - url = 'https://central.sonatype.com/api/v1/publisher' - authorization = 'BEARER' - username = ENV.JRELEASER_MAVENCENTRAL_USERNAME - password = ENV.JRELEASER_MAVENCENTRAL_PASSWORD - retryDelay = 60 - maxRetries = 60 - stagingRepository('build/staging-deploy') - } - } - } - } - release { - generic { - enabled = true - repoOwner = 'kurrent-io' - name = 'kurrentdb-client' - host = 'https://www.kurrent.io' - username = 'w1am' - sign = false - token = ENV.JRELEASER_GENERIC_TOKEN - skipRelease = true - skipTag = true - } - github { - enabled = false - repoOwner = 'kurrent-io' - name = 'KurrentDB-Client-Java' - host = 'github.com' - token = ENV.JRELEASER_GENERIC_TOKEN - sign = true - overwrite = true - artifacts = true - changelog { - enabled = false - formatted = 'ALWAYS' - preset = 'conventional-commits' + name = 'GitHubPackages' + url = uri('https://maven.pkg.github.com/TrogonStack/TrogonEventStore-Client-Java') + credentials { + username = ENV.GITHUB_ACTOR + password = ENV.GITHUB_TOKEN } } } @@ -324,5 +254,5 @@ sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 if (!JavaVersion.current().isJava8Compatible()) { - throw new Exception("Java 8 is required to build Kurrent-Client-Java") + throw new Exception("Java 8 or newer is required to build TrogonEventStore-Client-Java") } diff --git a/docker-compose.yml b/docker-compose.yml index f0a084c..e4fc826 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,15 +23,15 @@ services: depends_on: - volumes-provisioner - esdb-node1: &template - image: ${KURRENTDB_DOCKER_REGISTRY:-kurrentplatform}/${KURRENTDB_DOCKER_IMAGE:-kurrentdb}:${KURRENTDB_DOCKER_TAG:-lts} + trogon-eventstore-node1: &template + image: ${TROGON_EVENTSTORE_IMAGE:-ghcr.io/trogonstack/trogoneventstore:ci} env_file: - vars.env environment: - EVENTSTORE_GOSSIP_SEED=172.30.240.12:2113,172.30.240.13:2113 - EVENTSTORE_REPLICATION_IP=172.30.240.11 - - EVENTSTORE_CERTIFICATE_FILE=/etc/kurrentdb/certs/node1/node.crt - - EVENTSTORE_CERTIFICATE_PRIVATE_KEY_FILE=/etc/kurrentdb/certs/node1/node.key + - EVENTSTORE_CERTIFICATE_FILE=/etc/trogon-eventstore/certs/node1/node.crt + - EVENTSTORE_CERTIFICATE_PRIVATE_KEY_FILE=/etc/trogon-eventstore/certs/node1/node.key - EVENTSTORE_ADVERTISE_NODE_PORT_TO_CLIENT_AS=2111 ports: - 2111:2113 @@ -39,18 +39,18 @@ services: clusternetwork: ipv4_address: 172.30.240.11 volumes: - - ./certs:/etc/kurrentdb/certs + - ./certs:/etc/trogon-eventstore/certs restart: unless-stopped depends_on: - cert-gen - esdb-node2: + trogon-eventstore-node2: <<: *template environment: - EVENTSTORE_GOSSIP_SEED=172.30.240.11:2113,172.30.240.13:2113 - EVENTSTORE_REPLICATION_IP=172.30.240.12 - - EVENTSTORE_CERTIFICATE_FILE=/etc/kurrentdb/certs/node2/node.crt - - EVENTSTORE_CERTIFICATE_PRIVATE_KEY_FILE=/etc/kurrentdb/certs/node2/node.key + - EVENTSTORE_CERTIFICATE_FILE=/etc/trogon-eventstore/certs/node2/node.crt + - EVENTSTORE_CERTIFICATE_PRIVATE_KEY_FILE=/etc/trogon-eventstore/certs/node2/node.key - EVENTSTORE_ADVERTISE_NODE_PORT_TO_CLIENT_AS=2112 ports: - 2112:2113 @@ -58,13 +58,13 @@ services: clusternetwork: ipv4_address: 172.30.240.12 - esdb-node3: + trogon-eventstore-node3: <<: *template environment: - EVENTSTORE_GOSSIP_SEED=172.30.240.11:2113,172.30.240.12:2113 - EVENTSTORE_REPLICATION_IP=172.30.240.13 - - EVENTSTORE_CERTIFICATE_FILE=/etc/kurrentdb/certs/node3/node.crt - - EVENTSTORE_CERTIFICATE_PRIVATE_KEY_FILE=/etc/kurrentdb/certs/node3/node.key + - EVENTSTORE_CERTIFICATE_FILE=/etc/trogon-eventstore/certs/node3/node.crt + - EVENTSTORE_CERTIFICATE_PRIVATE_KEY_FILE=/etc/trogon-eventstore/certs/node3/node.key - EVENTSTORE_ADVERTISE_NODE_PORT_TO_CLIENT_AS=2113 ports: - 2113:2113 @@ -74,9 +74,9 @@ services: networks: clusternetwork: - name: kurrentdb.local + name: trogon-eventstore.local driver: bridge ipam: driver: default config: - - subnet: 172.30.240.0/24 \ No newline at end of file + - subnet: 172.30.240.0/24 diff --git a/docs/api/appending-events.md b/docs/api/appending-events.md index 797b750..52ca8ec 100644 --- a/docs/api/appending-events.md +++ b/docs/api/appending-events.md @@ -4,7 +4,7 @@ order: 2 # Appending events -When you start working with KurrentDB, your application streams are empty. The first meaningful operation is to add one or more events to the database using this API. +When you start working with TrogonEventStore, your application streams are empty. The first meaningful operation is to add one or more events to the database using this API. ::: tip Check the [Getting Started](getting-started.md) guide to learn how to configure and use the client SDK. @@ -12,12 +12,12 @@ Check the [Getting Started](getting-started.md) guide to learn how to configure ## Append your first event -The simplest way to append an event to KurrentDB is to create an `EventData` object and call `appendToStream` method. +The simplest way to append an event to TrogonEventStore is to create an `EventData` object and call `appendToStream` method. ```java {38-49} -import io.kurrent.dbclient.AppendToStreamOptions; -import io.kurrent.dbclient.EventData; -import io.kurrent.dbclient.StreamState; +import io.trogonstack.eventstore.client.AppendToStreamOptions; +import io.trogonstack.eventstore.client.EventData; +import io.trogonstack.eventstore.client.StreamState; import java.util.UUID; @@ -68,8 +68,8 @@ client.appendToStream("orders", options, eventData) ``` `appendToStream` takes a collection or a single object that can be serialized in JSON or binary format, which allows you to save more than one event in a single batch. - -Outside the example above, other options exist for dealing with different scenarios. + +Outside the example above, other options exist for dealing with different scenarios. ::: tip If you are new to Event Sourcing, please study the [Handling concurrency](#handling-concurrency) section below. @@ -77,11 +77,11 @@ If you are new to Event Sourcing, please study the [Handling concurrency](#handl ## Working with EventData -Events appended to KurrentDB must be wrapped in an `EventData` object. This allows you to specify the event's content, the type of event, and whether it's in JSON format. In its simplest form, you need three arguments: **eventId**, **eventType**, and **eventData**. +Events appended to TrogonEventStore must be wrapped in an `EventData` object. This allows you to specify the event's content, the type of event, and whether it's in JSON format. In its simplest form, you need three arguments: **eventId**, **eventType**, and **eventData**. ### eventId -This takes the format of a `UUID` and is used to uniquely identify the event you are trying to append. If two events with the same `UUID` are appended to the same stream in quick succession, KurrentDB will only append one of the events to the stream. +This takes the format of a `UUID` and is used to uniquely identify the event you are trying to append. If two events with the same `UUID` are appended to the same stream in quick succession, TrogonEventStore will only append one of the events to the stream. For example, the following code will only append a single event: @@ -106,17 +106,17 @@ client.appendToStream("orders", options, eventData) ### eventType -Each event should be supplied with an event type. This unique string is used to identify the type of event you are saving. +Each event should be supplied with an event type. This unique string is used to identify the type of event you are saving. It is common to see the explicit event code type name used as the type as it makes serialising and de-serialising of the event easy. However, we recommend against this as it couples the storage to the type and will make it more difficult if you need to version the event at a later date. ### eventData -Representation of your event data. It is recommended that you store your events as JSON objects. This allows you to take advantage of all of KurrentDB's functionality, such as projections. That said, you can save events using whatever format suits your workflow. Eventually, the data will be stored as encoded bytes. +Representation of your event data. It is recommended that you store your events as JSON objects. This allows you to take advantage of all of TrogonEventStore's functionality, such as projections. That said, you can save events using whatever format suits your workflow. Eventually, the data will be stored as encoded bytes. ### userMetadata -Storing additional information alongside your event that is part of the event itself is standard practice. This can be correlation IDs, timestamps, access information, etc. KurrentDB allows you to store a separate byte array containing this information to keep it separate. +Storing additional information alongside your event that is part of the event itself is standard practice. This can be correlation IDs, timestamps, access information, etc. TrogonEventStore allows you to store a separate byte array containing this information to keep it separate. ### contentType @@ -124,7 +124,7 @@ The content type indicates whether the event is stored as JSON or binary format. ## Handling concurrency -When appending events to a stream, you can supply a *stream state*. Your client uses this to inform KurrentDB of the state or version you expect the stream to be in when appending an event. If the stream isn't in that state, an exception will be thrown. +When appending events to a stream, you can supply a *stream state*. Your client uses this to inform TrogonEventStore of the state or version you expect the stream to be in when appending an event. If the stream isn't in that state, an exception will be thrown. For example, if you try to append the same record twice, expecting both times that the stream doesn't exist, you will get an exception on the second: @@ -154,14 +154,14 @@ client.appendToStream("no-stream-stream", options, eventDataTwo) .get(); ``` -There are several available expected revision options: +There are several available expected revision options: - `StreamState.any()` - No concurrency check - `StreamState.noStream()` - Stream should not exist - `StreamState.streamExists()` - Stream should exist - `StreamState.streamRevision(long revision)` - Stream should be at specific revision This check can be used to implement optimistic concurrency. When retrieving a -stream from KurrentDB, note the current version number. When you save it back, +stream from TrogonEventStore, note the current version number. When you save it back, you can determine if somebody else has modified the record in the meantime. First, let's define the event classes for our ecommerce example: @@ -255,25 +255,25 @@ client.appendToStream("some-stream", options, eventData) ## Atomic appends -KurrentDB provides two operations for appending events to one or more streams in a single atomic transaction: `appendRecords` and `multiStreamAppend`. Both guarantee that either all writes succeed or the entire operation fails, but they differ in how records are organized, ordered, and validated. +TrogonEventStore provides two operations for appending events to one or more streams in a single atomic transaction: `appendRecords` and `multiStreamAppend`. Both guarantee that either all writes succeed or the entire operation fails, but they differ in how records are organized, ordered, and validated. | | `appendRecords` | `multiStreamAppend` | |------------------------|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------| -| **Available since** | KurrentDB 26.1 | KurrentDB 25.1 | +| **Available since** | TrogonEventStore 26.1 | TrogonEventStore 25.1 | | **Record ordering** | Interleaved. Records from different streams can be mixed, and their exact order is preserved in the global log. | Grouped. All records for a stream are sent together; ordering across streams is not guaranteed. | | **Consistency checks** | Decoupled. Can validate the state of any stream, including streams not being written to. | Coupled. Expected state is specified per stream being written to. | ::: warning Metadata must be a valid JSON object, using string keys and string values only. Binary metadata is not supported in this version to maintain compatibility with -KurrentDB's metadata handling. This restriction will be lifted in the next major +TrogonEventStore's metadata handling. This restriction will be lifted in the next major release. ::: ### AppendRecords ::: note -This feature is only available in KurrentDB 26.1 and later. +This feature is only available in TrogonEventStore 26.1 and later. ::: `appendRecords` appends events to one or more streams atomically. Each record specifies which stream it targets, and the exact order of records is preserved in the global log across all streams. @@ -347,7 +347,7 @@ Because checks are decoupled from writes, you can validate the state of streams ### MultiStreamAppend ::: note -This feature is only available in KurrentDB 25.1 and later. +This feature is only available in TrogonEventStore 25.1 and later. ::: `multiStreamAppend` appends events to one or more streams atomically. Records are grouped per stream using `AppendStreamRequest`, where each request specifies a stream name, an expected state, and the events for that stream. diff --git a/docs/api/authentication.md b/docs/api/authentication.md index b6b89ff..f7f7e70 100644 --- a/docs/api/authentication.md +++ b/docs/api/authentication.md @@ -4,10 +4,10 @@ order: 7 head: - - title - {} - - Authentication | Java | Clients | Kurrent Docs + - Authentication | Java | Clients | TrogonEventStore docs --- -# Client x.509 certificate +# Client x.509 certificate @@ -15,7 +15,7 @@ X.509 certificates are digital certificates that use the X.509 public key infras ## Prerequisites -1. KurrentDB 25.0 or greater, or KurrentDB 24.10 or later. +1. TrogonEventStore 25.0 or greater, or TrogonEventStore 24.10 or later. 2. A valid X.509 certificate configured on the Database. See [configuration steps](@server/security/user-authentication.html#user-x-509-certificates) for more details. ## Connect using an x.509 certificate @@ -36,8 +36,8 @@ The client supports the following parameters: To authenticate, include these two parameters in your connection string or constructor when initializing the client: ```java -KurrentDBClientSettings settings = KurrentDBConnectionString - .parseOrThrow("kurrentdb://admin:changeit@{endpoint}?tls=true&userCertFile={pathToCaFile}&userKeyFile={pathToKeyFile}"); +TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString + .parseOrThrow("trogon-eventstore://admin:changeit@{endpoint}?tls=true&userCertFile={pathToCaFile}&userKeyFile={pathToKeyFile}"); -KurrentDBClient client = KurrentDBClient.create(settings); +TrogonEventStoreClient client = TrogonEventStoreClient.create(settings); ``` \ No newline at end of file diff --git a/docs/api/delete-stream.md b/docs/api/delete-stream.md index 659be69..3ba0449 100644 --- a/docs/api/delete-stream.md +++ b/docs/api/delete-stream.md @@ -3,20 +3,20 @@ order: 9 head: - - title - {} - - Deleting Events | Java | Clients | Kurrent Docs + - Deleting Events | Java | Clients | TrogonEventStore docs --- # Deleting Events -In KurrentDB, you can delete events and streams either partially or +In TrogonEventStore, you can delete events and streams either partially or completely. Settings like $maxAge and $maxCount help control how long events are kept or how many events are stored in a stream, but they won't delete the entire -stream. When you need to fully remove a stream, KurrentDB offers two +stream. When you need to fully remove a stream, TrogonEventStore offers two options: Soft Delete and Hard Delete. ## Soft delete -Soft delete in KurrentDB allows you to mark a stream for deletion without +Soft delete in TrogonEventStore allows you to mark a stream for deletion without completely removing it, so you can still add new events later. While you can do this through the UI, using code is often better for automating the process, handling many streams at once, or including custom rules. Code is especially @@ -27,7 +27,7 @@ into other workflows. client.deleteStream(streamName, DeleteStreamOptions.get()).get(); ``` -::: note +::: note Clicking the delete button in the UI performs a soft delete, setting the TruncateBefore value to remove all events up to a certain point. While this marks the events for deletion, actual removal occurs during the next scavenging @@ -36,7 +36,7 @@ process. The stream can still be reopened by appending new events. ## Hard delete -Hard delete in KurrentDB permanently removes a stream and its events. While +Hard delete in TrogonEventStore permanently removes a stream and its events. While you can use the HTTP API, code is often better for automating the process, managing multiple streams, and ensuring precise control. Code is especially useful when you need to integrate hard delete into larger workflows or apply diff --git a/docs/api/getting-started.md b/docs/api/getting-started.md index ef810c5..a0f0f5b 100644 --- a/docs/api/getting-started.md +++ b/docs/api/getting-started.md @@ -3,63 +3,63 @@ order: 1 head: - - title - {} - - Getting Started | Java | Clients | KurrentDB Docs + - Getting Started | Java | Clients | TrogonEventStore Docs --- # Getting started -This guide will help you get started with KurrentDB in your Java application. -It covers the basic steps to connect to KurrentDB, create events, append them +This guide will help you get started with TrogonEventStore in your Java application. +It covers the basic steps to connect to TrogonEventStore, create events, append them to streams, and read them back. ## Required packages -Add the `kurrentdb-client` dependency to your project: +Add the `trogon-eventstore-client` dependency to your project: ::: tabs @tab gradle ```groovy -implementation 'io.kurrent:kurrentdb-client:1.1.x' +implementation 'io.trogonstack:trogon-eventstore-client:1.1.x' ``` @tab maven ```xml - io.kurrent - kurrentdb-client + io.trogonstack + trogon-eventstore-client 1.1.x ``` ::: -## Connecting to KurrentDB +## Connecting to TrogonEventStore -To connect your application to KurrentDB, you need to configure and create a client instance. +To connect your application to TrogonEventStore, you need to configure and create a client instance. ::: tip Insecure clusters -The recommended way to connect to KurrentDB is using secure mode (which is -the default). However, if your KurrentDB instance is running in insecure +The recommended way to connect to TrogonEventStore is using secure mode (which is +the default). However, if your TrogonEventStore instance is running in insecure mode, you must explicitly set `tls=false` in your connection string or client configuration. ::: -KurrentDB uses connection strings to configure the client connection. The connection string supports two protocols: +TrogonEventStore uses connection strings to configure the client connection. The connection string supports two protocols: -- **`kurrentdb://`** - for connecting directly to specific node endpoints (single node or multi-node cluster with explicit endpoints) -- **`kurrentdb+discover://`** - for connecting using cluster discovery via DNS or gossip endpoints +- **`trogon-eventstore://`** - for connecting directly to specific node endpoints (single node or multi-node cluster with explicit endpoints) +- **`trogon-eventstore+discover://`** - for connecting using cluster discovery via DNS or gossip endpoints -When using `kurrentdb://`, you specify the exact endpoints to connect to. The client will connect directly to these endpoints. For multi-node clusters, you can specify multiple endpoints separated by commas, and the client will query each node's Gossip API to get cluster information, then picks a node based on the URI's node preference. +When using `trogon-eventstore://`, you specify the exact endpoints to connect to. The client will connect directly to these endpoints. For multi-node clusters, you can specify multiple endpoints separated by commas, and the client will query each node's Gossip API to get cluster information, then picks a node based on the URI's node preference. -With `kurrentdb+discover://`, the client uses cluster discovery to find available nodes. This is particularly useful when you have a DNS A record pointing to cluster nodes or when you want the client to automatically discover the cluster topology. +With `trogon-eventstore+discover://`, the client uses cluster discovery to find available nodes. This is particularly useful when you have a DNS A record pointing to cluster nodes or when you want the client to automatically discover the cluster topology. ::: info Gossip support -Since version 22.10, KurrentDB supports gossip on single-node deployments, so -`kurrentdb+discover://` can be used for any topology, including single-node setups. +Since version 22.10, TrogonEventStore supports gossip on single-node deployments, so +`trogon-eventstore+discover://` can be used for any topology, including single-node setups. ::: For cluster connections using discovery, use the following format: ``` -kurrentdb+discover://admin:changeit@cluster.dns.name:2113 +trogon-eventstore+discover://admin:changeit@cluster.dns.name:2113 ``` Where `cluster.dns.name` is a DNS `A` record that points to all cluster nodes. @@ -67,13 +67,13 @@ Where `cluster.dns.name` is a DNS `A` record that points to all cluster nodes. For direct connections to specific endpoints, you can specify individual nodes: ``` -kurrentdb://admin:changeit@node1.dns.name:2113,node2.dns.name:2113,node3.dns.name:2113 +trogon-eventstore://admin:changeit@node1.dns.name:2113,node2.dns.name:2113,node3.dns.name:2113 ``` Or for a single node: ``` -kurrentdb://admin:changeit@localhost:2113 +trogon-eventstore://admin:changeit@localhost:2113 ``` There are a number of query parameters that can be used in the connection string to instruct the cluster how and where the connection should be established. All query parameters are optional. @@ -95,31 +95,31 @@ There are a number of query parameters that can be used in the connection string | `userKeyFile` | String, file path | None | Key file for the user certificate used for X.509 authentication. | | `feature` | `dns-lookup` | None | Enable specific client features. Use `dns-lookup` with `dnsDiscover=true` to resolve hostnames to multiple IP addresses for cluster discovery. | -When connecting to an insecure instance, specify `tls=false` parameter. For example, for a node running locally use `kurrentdb://localhost:2113?tls=false`. Note that usernames and passwords aren't provided there because insecure deployments don't support authentication and authorisation. +When connecting to an insecure instance, specify `tls=false` parameter. For example, for a node running locally use `trogon-eventstore://localhost:2113?tls=false`. Note that usernames and passwords aren't provided there because insecure deployments don't support authentication and authorisation. ## Creating a client First, create a client and get it connected to the database. ```java -import io.kurrent.dbclient.KurrentDBClient; -import io.kurrent.dbclient.KurrentDBClientSettings; -import io.kurrent.dbclient.KurrentDBConnectionString; +import io.trogonstack.eventstore.client.TrogonEventStoreClient; +import io.trogonstack.eventstore.client.TrogonEventStoreClientSettings; +import io.trogonstack.eventstore.client.TrogonEventStoreConnectionString; -KurrentDBClientSettings settings = KurrentDBConnectionString.parseOrThrow("kurrentdb://localhost:2113?tls=false"); -KurrentDBClient client = KurrentDBClient.create(settings); +TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString.parseOrThrow("trogon-eventstore://localhost:2113?tls=false"); +TrogonEventStoreClient client = TrogonEventStoreClient.create(settings); ``` The client instance can be used as a singleton across the whole application. It doesn't need to open or close the connection. ## Creating an event -You can write anything to KurrentDB as events. The client needs a byte array as the event payload. Normally, you'd use a serialized object, and it's up to you to choose the serialization method. +You can write anything to TrogonEventStore as events. The client needs a byte array as the event payload. Normally, you'd use a serialized object, and it's up to you to choose the serialization method. The code snippet below creates an event object instance, serializes it, and adds it as a payload to the `EventData` structure, which the client can then write to the database. ```java -import io.kurrent.dbclient.EventData; +import io.trogonstack.eventstore.client.EventData; import com.fasterxml.jackson.databind.json.JsonMapper; public class OrderPlaced { diff --git a/docs/api/observability.md b/docs/api/observability.md index a216fd2..e46d48d 100644 --- a/docs/api/observability.md +++ b/docs/api/observability.md @@ -3,7 +3,7 @@ order: 8 head: - - title - {} - - Observability | Java | Clients | Kurrent Docs + - Observability | Java | Clients | TrogonEventStore docs --- # Observability @@ -27,21 +27,21 @@ Maven `pom.xml` or Gradle `build.gradle`: opentelemetry-sdk 1.40.0 - + io.opentelemetry opentelemetry-exporter-logging 1.40.0 - + io.opentelemetry opentelemetry-exporter-otlp 1.40.0 - + io.opentelemetry.semconv @@ -97,10 +97,10 @@ public class EventStoreObservability { .setTracerProvider(sdkTracerProvider) .buildAndRegisterGlobal(); - // Your KurrentDB client operations will now be traced - KurrentDBClientSettings settings = KurrentDBConnectionString - .parseOrThrow("kurrentdb://localhost:2113?tls=false"); - KurrentDBClient client = KurrentDBClient.create(settings); + // Your TrogonEventStore client operations will now be traced + TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString + .parseOrThrow("trogon-eventstore://localhost:2113?tls=false"); + TrogonEventStoreClient client = TrogonEventStoreClient.create(settings); } } ``` @@ -169,14 +169,14 @@ Each trace includes metadata to help with debugging and monitoring: | Attribute | Description | Example | | --------------------------------- | -------------------------------------- | ------------------------------------- | | `db.user` | Database user name | `admin` | -| `db.system` | Database system identifier | `eventstoredb` | +| `db.system` | Database system identifier | `trogon_eventstore` | | `db.operation` | Type of operation performed | `streams.append`, `streams.subscribe` | -| `db.eventstoredb.stream` | Stream name or identifier | `user-events-123` | -| `db.eventstoredb.subscription.id` | Subscription identifier | `user-events-123-sub` | -| `db.eventstoredb.event.id` | Event identifier | `event-456` | -| `db.eventstoredb.event.type` | Event type identifier | `user.created` | -| `server.address` | KurrentDB server address | `localhost` | -| `server.port` | KurrentDB server port | `2113` | +| `db.trogon_eventstore.stream` | Stream name or identifier | `user-events-123` | +| `db.trogon_eventstore.subscription.id` | Subscription identifier | `user-events-123-sub` | +| `db.trogon_eventstore.event.id` | Event identifier | `event-456` | +| `db.trogon_eventstore.event.type` | Event type identifier | `user.created` | +| `server.address` | TrogonEventStore server address | `localhost` | +| `server.port` | TrogonEventStore server port | `2113` | | `exception.type` | Exception type if an error occurred | | | `exception.message` | Exception message if an error occurred | | | `exception.stacktrace` | Stack trace of the exception | | diff --git a/docs/api/persistent-subscriptions.md b/docs/api/persistent-subscriptions.md index 7143ea2..466860a 100644 --- a/docs/api/persistent-subscriptions.md +++ b/docs/api/persistent-subscriptions.md @@ -3,7 +3,7 @@ order: 5 head: - - title - {} - - Persistent Subscriptions | Java | Clients | Kurrent Docs + - Persistent Subscriptions | Java | Clients | TrogonEventStore docs --- # Persistent Subscriptions @@ -29,7 +29,7 @@ You can read more about persistent subscriptions in the [server documentation](@ The Java client provides a `PersistentSubscriptionsClient` that you can use to manage persistent subscriptions. ```java -KurrentDBClientSettings settings = KurrentDBConnectionString.parseOrThrow("kurrentdb://localhost:2113?tls=false"); +TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString.parseOrThrow("trogon-eventstore://localhost:2113?tls=false"); PersistentSubscriptionsClient client = PersistentSubscriptionsClient.create(settings); ``` @@ -65,7 +65,7 @@ client.createToAll( ``` ::: note -As from EventStoreDB 21.10, the ability to subscribe to `$all` supports +Subscriptions to `$all` support [server-side filtering](subscriptions.md#server-side-filtering). You can create a subscription group for `$all` similarly to how you would for a specific stream: @@ -212,7 +212,7 @@ resources. For use with an indexing projection such as the system `$by_category` projection. -KurrentDB inspects the event for its source stream id, hashing the id to one +TrogonEventStore inspects the event for its source stream id, hashing the id to one of 1024 buckets assigned to individual clients. When a client disconnects, its buckets are assigned to other clients. When a client connects, it is assigned some existing buckets. This naively attempts to maintain a balanced workload. diff --git a/docs/api/projections.md b/docs/api/projections.md index 18e4072..85457b6 100644 --- a/docs/api/projections.md +++ b/docs/api/projections.md @@ -4,22 +4,22 @@ title: Projections head: - - title - {} - - Projections | Java | Clients | Kurrent Docs + - Projections | Java | Clients | TrogonEventStore docs --- # Projection management -The client provides a way to manage projections in KurrentDB. +The client provides a way to manage projections in TrogonEventStore. For a detailed explanation of projections, see the [server documentation](@server/features/projections/README.md). ## Creating a client -The Java client provides a `KurrentDBProjectionManagementClient` that you can use to manage persistent subscriptions. +The Java client provides a `TrogonEventStoreProjectionManagementClient` that you can use to manage persistent subscriptions. ```java -KurrentDBClientSettings settings = KurrentDBConnectionString.parseOrThrow("kurrentdb://localhost:2113?tls=false"); -KurrentDBProjectionManagementClient client = KurrentDBProjectionManagementClient.create(settings); +TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString.parseOrThrow("trogon-eventstore://localhost:2113?tls=false"); +TrogonEventStoreProjectionManagementClient client = TrogonEventStoreProjectionManagementClient.create(settings); ``` ## Create a projection diff --git a/docs/api/reading-events.md b/docs/api/reading-events.md index c19c305..0ef7980 100644 --- a/docs/api/reading-events.md +++ b/docs/api/reading-events.md @@ -3,21 +3,21 @@ order: 3 head: - - title - {} - - Reading Events | Java | Clients | Kurrent Docs + - Reading Events | Java | Clients | TrogonEventStore docs --- # Reading Events -KurrentDB provides two primary methods for reading events: reading from an +TrogonEventStore provides two primary methods for reading events: reading from an individual stream to retrieve events from a specific named stream, or reading from the `$all` stream to access all events across the entire event store. -Events in KurrentDB are organized within individual streams and use two +Events in TrogonEventStore are organized within individual streams and use two distinct positioning systems to track their location. The **revision number** is a 64-bit signed integer (`long`) that represents the sequential position of an event within its specific stream. Events are numbered starting from 0, with each new event receiving the next sequential revision number (0, 1, 2, 3...). The -**global position** represents the event's location in KurrentDB's global +**global position** represents the event's location in TrogonEventStore's global transaction log and consists of two coordinates: the `commit` position (where the transaction was committed in the log) and the `prepare` position (where the transaction was initially prepared). @@ -92,7 +92,7 @@ ReadStreamOptions options = ReadStreamOptions.get() #### resolveLinkTos -When using projections to create new events you can set whether the generated events are pointers to existing events. Setting this value to true will tell KurrentDB to return the event as well as the event linking to it. +When using projections to create new events you can set whether the generated events are pointers to existing events. Setting this value to true will tell TrogonEventStore to return the event as well as the event linking to it. ```java{4} ReadStreamOptions options = ReadStreamOptions.get() @@ -146,7 +146,7 @@ Read one event backwards to find the last position in the stream. Reading a stream returns a `ReadStreamResult`, which contains a property `ReadState`. This property can have the value `StreamNotFound` or `Ok`. -It is important to check the value of this field before attempting to iterate an empty stream, as it will throw an exception. +It is important to check the value of this field before attempting to iterate an empty stream, as it will throw an exception. For example: @@ -180,7 +180,7 @@ direction and the transaction log position from which you want to start. The transaction log position can be specified in several ways: - Use `fromStart()` to begin from the very beginning of the transaction log -- Use `fromEnd()` to begin from the current end of the transaction log +- Use `fromEnd()` to begin from the current end of the transaction log - Use `fromPosition(Position position)` with a specific `Position` object containing commit and prepare coordinates ```java{2-3} @@ -233,7 +233,7 @@ ReadAllOptions options = ReadAllOptions.get() #### resolveLinkTos -When using projections to create new events you can set whether the generated events are pointers to existing events. Setting this value to true will tell KurrentDB to return the event as well as the event linking to it. +When using projections to create new events you can set whether the generated events are pointers to existing events. Setting this value to true will tell TrogonEventStore to return the event as well as the event linking to it. ```java{4} ReadAllOptions options = ReadAllOptions.get() @@ -278,7 +278,7 @@ Read one event backwards to find the last position in the `$all` stream. ### Handling system events -KurrentDB will also return system events when reading from the `$all` stream. In most cases you can ignore these events. +TrogonEventStore will also return system events when reading from the `$all` stream. In most cases you can ignore these events. All system events begin with `$` or `$$` and can be easily ignored by checking the `eventType` property. @@ -298,7 +298,7 @@ for (ResolvedEvent resolvedEvent : result.getEvents()) { } ``` -## Java Reactive Streams +## Java Reactive Streams The Java Reactive Streams API allows you to read events in a non-blocking manner, which is particularly useful for applications that require high throughput and low latency. The reactive API provides a way to subscribe to streams of events and process them as they arrive. diff --git a/docs/api/subscriptions.md b/docs/api/subscriptions.md index eacc54d..0f68487 100644 --- a/docs/api/subscriptions.md +++ b/docs/api/subscriptions.md @@ -3,7 +3,7 @@ order: 4 head: - - title - {} - - Catch-up Subscriptions | Java | Clients | Kurrent Docs + - Catch-up Subscriptions | Java | Clients | TrogonEventStore docs --- # Catch-up Subscriptions @@ -102,7 +102,7 @@ client.subscribeToAll( ## Resolving link-to events -Link-to events point to events in other streams in KurrentDB. These are +Link-to events point to events in other streams in TrogonEventStore. These are generally created by projections such as the `$by_event_type` projection which links events of the same event type into the same stream. This makes it easier to look up all events of a specific type. @@ -205,8 +205,8 @@ client.subscribeToAll( ## Handling Subscription State Changes -::: info KurrentDB 23.10.0+ -This feature requires KurrentDB version 23.10.0 or later. +::: info TrogonEventStore 23.10.0+ +This feature requires TrogonEventStore version 23.10.0 or later. ::: When a subscription processes historical events and reaches the end of the @@ -265,7 +265,7 @@ client.subscribeToAll(listener, options); ## Server-side Filtering -KurrentDB allows you to filter events while subscribing to the `$all` stream to only receive the events you care about. You can filter by event type or stream name using a regular expression or a prefix. Server-side filtering is currently only available on the `$all` stream. +TrogonEventStore allows you to filter events while subscribing to the `$all` stream to only receive the events you care about. You can filter by event type or stream name using a regular expression or a prefix. Server-side filtering is currently only available on the `$all` stream. ::: tip Server-side filtering was introduced as a simpler alternative to projections. You should consider filtering before creating a projection to include the events you care about. @@ -348,7 +348,7 @@ A checkpoint is the position of an event in the `$all` stream to which your appl To create a checkpoint, store the event's commit or prepare position. ::: warning -If your database contains events created by the legacy TCP client using the [transaction feature](https://docs.kurrent.io/clients/tcp/dotnet/21.2/appending.html#transactions), you should store both the commit and prepare positions together as your checkpoint. +If your database contains events created by the legacy TCP client using the [transaction feature](https://github.com/TrogonStack/TrogonEventStore), you should store both the commit and prepare positions together as your checkpoint. ::: ### Updating checkpoints at regular intervals @@ -376,7 +376,7 @@ By default, the checkpoint notification is sent after every 32 non-system events ### Configuring the checkpoint interval -You can adjust the checkpoint interval to change how often the client is notified. +You can adjust the checkpoint interval to change how often the client is notified. ```java String excludeSystemEventsRegex = "/^[^\\$].*/"; diff --git a/docs/package.json b/docs/package.json index 881a03f..e11a17c 100644 --- a/docs/package.json +++ b/docs/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "type": "module", - "author": "Kurrent Inc", + "author": "Straw Hat, LLC", "devDependencies": { "@babel/cli": "^7.24.8", "@babel/core": "^7.24.9", diff --git a/gradle.properties b/gradle.properties index 75a7079..b8117f3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,5 +11,5 @@ openTelemetrySemConvVersion=1.25.0-alpha # Test Dependencies slf4jNopVersion=1.7.29 -testcontainersVersion=1.20.6 +testcontainersVersion=1.21.4 jacksonVersion=2.18.3 diff --git a/settings.gradle b/settings.gradle index 6474180..817419e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,4 +7,4 @@ * in the user manual at https://docs.gradle.org/6.6.1/userguide/multi_project_builds.html */ -rootProject.name = 'kurrentdb-client' +rootProject.name = 'trogon-eventstore-client' diff --git a/src/main/java/io/kurrent/dbclient/AppendConsistencyViolationException.java b/src/main/java/io/kurrent/dbclient/AppendConsistencyViolationException.java deleted file mode 100644 index 176e530..0000000 --- a/src/main/java/io/kurrent/dbclient/AppendConsistencyViolationException.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.kurrent.dbclient; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * Exception thrown when one or more consistency checks fail during an AppendRecords operation. - * The entire transaction is aborted and no records are written. - */ -public class AppendConsistencyViolationException extends RuntimeException { - private final List violations; - - /** - * Creates a new AppendConsistencyViolationException. - * - * @param violations the consistency violations that caused the transaction to be aborted. - */ - public AppendConsistencyViolationException(List violations) { - super(formatMessage(violations)); - this.violations = violations; - } - - /** - * Returns the consistency violations that caused the transaction to be aborted. - */ - public List getViolations() { - return violations; - } - - private static String formatMessage(List violations) { - String details = violations.stream() - .map(v -> String.format("[Check %d: Stream '%s' expected state %s, actual state %s]", - v.getCheckIndex(), v.getStream(), v.getExpectedState(), v.getActualState())) - .collect(Collectors.joining(", ")); - return "Append failed due to consistency violation(s): " + details; - } -} diff --git a/src/main/java/io/kurrent/dbclient/AppendRecord.java b/src/main/java/io/kurrent/dbclient/AppendRecord.java deleted file mode 100644 index 1f94107..0000000 --- a/src/main/java/io/kurrent/dbclient/AppendRecord.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.kurrent.dbclient; - -/** - * Represents a record to be appended to a specific stream in an - * {@link KurrentDBClient#appendRecords} operation. - * Each record specifies its own target stream, allowing interleaved writes across multiple streams. - */ -public class AppendRecord { - private final String stream; - private final EventData record; - - /** - * Creates a new AppendRecord targeting the specified stream. - * - * @param stream the name of the target stream for this record. - * @param record the event data to append. - */ - public AppendRecord(String stream, EventData record) { - this.stream = stream; - this.record = record; - } - - /** - * Returns the name of the target stream. - */ - public String getStream() { - return stream; - } - - /** - * Returns the event data to append. - */ - public EventData getRecord() { - return record; - } -} diff --git a/src/main/java/io/kurrent/dbclient/AppendRecords.java b/src/main/java/io/kurrent/dbclient/AppendRecords.java deleted file mode 100644 index bc06440..0000000 --- a/src/main/java/io/kurrent/dbclient/AppendRecords.java +++ /dev/null @@ -1,201 +0,0 @@ -package io.kurrent.dbclient; - -import com.google.protobuf.Any; -import com.google.protobuf.ByteString; -import com.google.protobuf.Value; -import io.grpc.StatusRuntimeException; -import io.grpc.protobuf.StatusProto; -import io.grpc.stub.ClientCallStreamObserver; -import io.grpc.stub.ClientResponseObserver; -import io.kurrentdb.protocol.v2.streams.AppendRecordsRequest; -import io.kurrentdb.protocol.v2.streams.SchemaInfo; -import io.kurrentdb.protocol.v2.streams.StreamsServiceGrpc; - -import io.kurrentdb.protocol.v2.streams.errors.AppendConsistencyViolationErrorDetails; -import io.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails; -import io.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -class AppendRecords { - private final GrpcClient client; - private final List records; - private final List checks; - - public AppendRecords(GrpcClient client, List records, List checks) { - this.client = client; - this.records = records; - this.checks = checks; - } - - public CompletableFuture execute() { - if (records.isEmpty()) { - CompletableFuture result = new CompletableFuture<>(); - result.completeExceptionally(new IllegalArgumentException("At least one record is required.")); - return result; - } - - return this.client.runWithArgs(args -> ClientTelemetry.traceAppendRecords( - this::appendRecords, - args, - this.records, - this.client.getSettings())); - } - - private CompletableFuture appendRecords(WorkItemArgs args, List records) { - CompletableFuture result = new CompletableFuture<>(); - - if (!args.supportFeature(FeatureFlags.APPEND_RECORDS)) { - result.completeExceptionally(new UnsupportedOperationException( - "AppendRecords is not supported by the server. Requires KurrentDB 26.1 or later.")); - return result; - } - - StreamsServiceGrpc.StreamsServiceStub stub = GrpcUtils.configureStub( - StreamsServiceGrpc.newStub(args.getChannel()), - this.client.getSettings(), - new OptionsBase<>(), - null, - false); - - try { - AppendRecordsRequest.Builder requestBuilder = AppendRecordsRequest.newBuilder(); - - for (AppendRecord record : records) { - EventData event = record.getRecord(); - - io.kurrentdb.protocol.v2.streams.AppendRecord.Builder recordBuilder = - io.kurrentdb.protocol.v2.streams.AppendRecord.newBuilder() - .setStream(record.getStream()) - .setData(ByteString.copyFrom(event.getEventData())) - .setRecordId(event.getEventId().toString()) - .setSchema(SchemaInfo.newBuilder() - .setFormat(ContentTypeMapper.toSchemaDataFormat(event.getContentType())) - .setName(event.getEventType())); - - if (event.getUserMetadata() != null) { - Map properties = DynamicValueMapper.mapJsonToValueMap(event.getUserMetadata()); - recordBuilder.putAllProperties(properties); - } - - requestBuilder.addRecords(recordBuilder.build()); - } - - if (checks != null) { - for (ConsistencyCheck check : checks) { - if (check instanceof ConsistencyCheck.StreamStateCheck) { - ConsistencyCheck.StreamStateCheck stateCheck = (ConsistencyCheck.StreamStateCheck) check; - requestBuilder.addChecks( - io.kurrentdb.protocol.v2.streams.ConsistencyCheck.newBuilder() - .setStreamState( - io.kurrentdb.protocol.v2.streams.ConsistencyCheck.StreamStateCheck.newBuilder() - .setStream(stateCheck.getStream()) - .setExpectedState(stateCheck.getExpectedState().toRawLong()) - .build()) - .build()); - } - } - } - - stub.appendRecords(requestBuilder.build(), new AppendRecordsObserver(result)); - } catch (RuntimeException e) { - result.completeExceptionally(e); - } - - return result; - } - - private AppendRecordsResponse onResponse(io.kurrentdb.protocol.v2.streams.AppendRecordsResponse response) { - List results = new ArrayList<>(response.getRevisionsCount()); - - for (io.kurrentdb.protocol.v2.streams.StreamRevision revision : response.getRevisionsList()) { - results.add(new AppendResponse(revision.getStream(), revision.getRevision())); - } - - return new AppendRecordsResponse(response.getPosition(), results); - } - - private class AppendRecordsObserver implements ClientResponseObserver { - private final CompletableFuture result; - - public AppendRecordsObserver(CompletableFuture result) { - this.result = result; - } - - @Override - public void beforeStart(ClientCallStreamObserver requestStream) { - } - - @Override - public void onNext(io.kurrentdb.protocol.v2.streams.AppendRecordsResponse response) { - try { - AppendRecordsResponse converted = onResponse(response); - result.complete(converted); - } catch (Throwable e) { - result.completeExceptionally(e); - } - } - - @Override - public void onError(Throwable t) { - if (GrpcUtils.handleNotLeaderError(t, result)) return; - - if (t instanceof StatusRuntimeException) { - StatusRuntimeException e = (StatusRuntimeException) t; - com.google.rpc.Status status = StatusProto.fromThrowable(e); - - if (status != null && status.getDetailsCount() > 0) { - for (Any d : status.getDetailsList()) { - try { - if (d.is(AppendConsistencyViolationErrorDetails.class)) { - AppendConsistencyViolationErrorDetails details = - d.unpack(AppendConsistencyViolationErrorDetails.class); - List violations = new ArrayList<>(); - - for (io.kurrentdb.protocol.v2.streams.errors.ConsistencyViolation v : details.getViolationsList()) { - if (v.hasStreamState()) { - io.kurrentdb.protocol.v2.streams.errors.ConsistencyViolation.StreamStateViolation ss = - v.getStreamState(); - violations.add(new ConsistencyViolation( - v.getCheckIndex(), - ss.getStream(), - StreamState.fromRawLong(ss.getExpectedState()), - StreamState.fromRawLong(ss.getActualState()))); - } - } - - result.completeExceptionally(new AppendConsistencyViolationException(violations)); - return; - } else if (d.is(AppendRecordSizeExceededErrorDetails.class)) { - AppendRecordSizeExceededErrorDetails details = - d.unpack(AppendRecordSizeExceededErrorDetails.class); - result.completeExceptionally(new RecordSizeExceededException( - details.getStream(), details.getRecordId(), - details.getSize(), details.getMaxSize())); - return; - } else if (d.is(AppendTransactionSizeExceededErrorDetails.class)) { - AppendTransactionSizeExceededErrorDetails details = - d.unpack(AppendTransactionSizeExceededErrorDetails.class); - result.completeExceptionally(new TransactionMaxSizeExceededException( - details.getSize(), details.getMaxSize())); - return; - } - } catch (com.google.protobuf.InvalidProtocolBufferException ex) { - result.completeExceptionally(ex); - return; - } - } - } - } - - result.completeExceptionally(t); - } - - @Override - public void onCompleted() { - } - } -} diff --git a/src/main/java/io/kurrent/dbclient/AppendRecordsResponse.java b/src/main/java/io/kurrent/dbclient/AppendRecordsResponse.java deleted file mode 100644 index 4ca95bf..0000000 --- a/src/main/java/io/kurrent/dbclient/AppendRecordsResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.kurrent.dbclient; - -import java.util.List; - -public class AppendRecordsResponse { - private final long position; - private final List results; - - public AppendRecordsResponse(long position, List results) { - this.position = position; - this.results = results; - } - - public long getPosition() { - return position; - } - - public List getResults() { - return results; - } -} diff --git a/src/main/java/io/kurrent/dbclient/AppendStreamRequest.java b/src/main/java/io/kurrent/dbclient/AppendStreamRequest.java deleted file mode 100644 index d2c666b..0000000 --- a/src/main/java/io/kurrent/dbclient/AppendStreamRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.kurrent.dbclient; - -import java.util.Iterator; - -public class AppendStreamRequest { - private final String streamName; - private final Iterator events; - private final StreamState expectedState; - - public AppendStreamRequest(String streamName, Iterator events, StreamState expectedState) { - this.streamName = streamName; - this.events = events; - this.expectedState = expectedState; - } - - public String getStreamName() { - return streamName; - } - - public Iterator getEvents() { - return events; - } - - public StreamState getExpectedState() { - return expectedState; - } -} diff --git a/src/main/java/io/kurrent/dbclient/ConsistencyCheck.java b/src/main/java/io/kurrent/dbclient/ConsistencyCheck.java deleted file mode 100644 index afbd1a1..0000000 --- a/src/main/java/io/kurrent/dbclient/ConsistencyCheck.java +++ /dev/null @@ -1,45 +0,0 @@ -package io.kurrent.dbclient; - -/** - * Represents a consistency check to be evaluated before committing an - * {@link KurrentDBClient#appendRecords} operation. - * Checks are decoupled from writes: a check can reference any stream, - * whether or not the request writes to it. - */ -public abstract class ConsistencyCheck { - - ConsistencyCheck() {} - - /** - * A check that asserts a stream is at a specific revision or lifecycle state before commit. - */ - public static class StreamStateCheck extends ConsistencyCheck { - private final String stream; - private final StreamState expectedState; - - /** - * Creates a new StreamStateCheck. - * - * @param stream the stream name to check. - * @param expectedState the expected state of the stream (revision number or state constant). - */ - public StreamStateCheck(String stream, StreamState expectedState) { - this.stream = stream; - this.expectedState = expectedState; - } - - /** - * Returns the stream name to check. - */ - public String getStream() { - return stream; - } - - /** - * Returns the expected state of the stream. - */ - public StreamState getExpectedState() { - return expectedState; - } - } -} diff --git a/src/main/java/io/kurrent/dbclient/ConsistencyViolation.java b/src/main/java/io/kurrent/dbclient/ConsistencyViolation.java deleted file mode 100644 index 2250c31..0000000 --- a/src/main/java/io/kurrent/dbclient/ConsistencyViolation.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.kurrent.dbclient; - -/** - * Reports a single consistency check that was violated during an AppendRecords operation. - */ -public class ConsistencyViolation { - private final int checkIndex; - private final String stream; - private final StreamState expectedState; - private final StreamState actualState; - - /** - * Creates a new ConsistencyViolation. - * - * @param checkIndex index of the check in the original consistency checks list. - * @param stream the name of the stream whose state was checked. - * @param expectedState the expected state of the stream. - * @param actualState the actual state of the stream at the time the check was evaluated. - */ - public ConsistencyViolation(int checkIndex, String stream, StreamState expectedState, StreamState actualState) { - this.checkIndex = checkIndex; - this.stream = stream; - this.expectedState = expectedState; - this.actualState = actualState; - } - - /** - * Returns the index of the check in the original consistency checks list. - */ - public int getCheckIndex() { - return checkIndex; - } - - /** - * Returns the stream name whose state was checked. - */ - public String getStream() { - return stream; - } - - /** - * Returns the expected state of the stream. - */ - public StreamState getExpectedState() { - return expectedState; - } - - /** - * Returns the actual state of the stream at the time the check was evaluated. - */ - public StreamState getActualState() { - return actualState; - } -} diff --git a/src/main/java/io/kurrent/dbclient/ContentTypeMapper.java b/src/main/java/io/kurrent/dbclient/ContentTypeMapper.java deleted file mode 100644 index cd4b2db..0000000 --- a/src/main/java/io/kurrent/dbclient/ContentTypeMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.kurrent.dbclient; - -import io.kurrentdb.protocol.v2.streams.SchemaFormat; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class ContentTypeMapper { - private static final Map CONTENT_TYPE_MAP; - - static { - Map map = new HashMap<>(); - map.put("application/json", SchemaFormat.SCHEMA_FORMAT_JSON); - map.put("application/octet-stream", SchemaFormat.SCHEMA_FORMAT_BYTES); - CONTENT_TYPE_MAP = Collections.unmodifiableMap(map); - } - - public static SchemaFormat toSchemaDataFormat(String contentType) { - return CONTENT_TYPE_MAP.getOrDefault(contentType, SchemaFormat.SCHEMA_FORMAT_UNSPECIFIED); - } -} diff --git a/src/main/java/io/kurrent/dbclient/MultiStreamAppend.java b/src/main/java/io/kurrent/dbclient/MultiStreamAppend.java deleted file mode 100644 index e544eab..0000000 --- a/src/main/java/io/kurrent/dbclient/MultiStreamAppend.java +++ /dev/null @@ -1,170 +0,0 @@ -package io.kurrent.dbclient; - -import com.google.protobuf.ByteString; -import com.google.protobuf.Value; -import io.grpc.StatusRuntimeException; -import io.grpc.stub.StreamObserver; -import io.grpc.stub.ClientResponseObserver; -import io.grpc.stub.ClientCallStreamObserver; -import io.kurrentdb.protocol.v2.streams.AppendRecord; -import io.kurrentdb.protocol.v2.streams.AppendRequest; -import io.kurrentdb.protocol.v2.streams.AppendSessionResponse; -import io.kurrentdb.protocol.v2.streams.SchemaInfo; -import io.kurrentdb.protocol.v2.streams.StreamsServiceGrpc; - -import io.kurrentdb.protocol.v2.streams.errors.*; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -import com.google.protobuf.Any; -import io.grpc.protobuf.StatusProto; - -class MultiStreamAppend { - private final GrpcClient client; - private final Iterator requests; - - public MultiStreamAppend(GrpcClient client, Iterator requests) { - this.client = client; - this.requests = requests; - } - - public CompletableFuture execute() { - return this.client.runWithArgs(args -> ClientTelemetry.traceMultiStreamAppend( - this::append, - args, - this.requests, - this.client.getSettings())); - } - - private CompletableFuture append(WorkItemArgs args, Iterator requests) { - CompletableFuture result = new CompletableFuture<>(); - - if (!args.supportFeature(FeatureFlags.MULTI_STREAM_APPEND)) { - result.completeExceptionally(new UnsupportedOperationException("Multi-stream append is not supported by the server")); - return result; - } - - StreamsServiceGrpc.StreamsServiceStub client = GrpcUtils.configureStub(StreamsServiceGrpc.newStub(args.getChannel()), this.client.getSettings(), new OptionsBase<>(), null, false); - StreamObserver requestStream = client.appendSession(new MultiStreamAppendObserver(result)); - - try { - while (requests.hasNext()) { - AppendStreamRequest request = requests.next(); - AppendRequest.Builder builder = AppendRequest.newBuilder() - .setExpectedRevision(request.getExpectedState().toRawLong()) - .setStream(request.getStreamName()); - - while (request.getEvents().hasNext()) { - EventData event = request.getEvents().next(); - AppendRecord.Builder recordBuilder = AppendRecord.newBuilder() - .setData(ByteString.copyFrom(event.getEventData())) - .setRecordId(event.getEventId().toString()) - .setSchema( - SchemaInfo.newBuilder() - .setFormat(ContentTypeMapper.toSchemaDataFormat(event.getContentType())) - .setName(event.getEventType()) - ); - - if (event.getUserMetadata() != null) { - Map userMetadataProperties = DynamicValueMapper.mapJsonToValueMap(event.getUserMetadata()); - recordBuilder.putAllProperties(userMetadataProperties); - } - builder.addRecords(recordBuilder.build()); - } - - requestStream.onNext(builder.build()); - } - - requestStream.onCompleted(); - } catch (RuntimeException e) { - result.completeExceptionally(e); - } - - return result; - } - - private MultiStreamAppendResponse onResponse(AppendSessionResponse response) { - List results = new java.util.ArrayList<>(response.getOutputCount()); - - for (io.kurrentdb.protocol.v2.streams.AppendResponse output : response.getOutputList()) { - results.add(new AppendResponse(output.getStream(), output.getStreamRevision())); - } - - return new MultiStreamAppendResponse(response.getPosition(), results); - } - - private class MultiStreamAppendObserver implements ClientResponseObserver { - private final CompletableFuture result; - - public MultiStreamAppendObserver(CompletableFuture result) { - this.result = result; - } - - @Override - public void beforeStart(ClientCallStreamObserver requestStream) { - } - - @Override - public void onNext(AppendSessionResponse response) { - try { - MultiStreamAppendResponse converted = onResponse(response); - result.complete(converted); - } catch (Throwable e) { - result.completeExceptionally(e); - } - } - - @Override - public void onError(Throwable t) { - if (GrpcUtils.handleNotLeaderError(t, result)) return; - - if (t instanceof StatusRuntimeException) { - StatusRuntimeException e = (StatusRuntimeException) t; - com.google.rpc.Status status = StatusProto.fromThrowable(e); - - if (status != null && status.getDetailsCount() > 0) { - for (Any d : status.getDetailsList()) { - try { - if (d.is(StreamRevisionConflictErrorDetails.class)) { - StreamRevisionConflictErrorDetails details = d.unpack(StreamRevisionConflictErrorDetails.class); - StreamState expected = StreamState.fromRawLong(details.getExpectedRevision()); - StreamState actual = StreamState.fromRawLong(details.getActualRevision()); - String stream = details.getStream(); - result.completeExceptionally(new WrongExpectedVersionException(stream, expected, actual)); - return; - } else if (d.is(StreamDeletedErrorDetails.class)) { - StreamDeletedErrorDetails details = d.unpack(StreamDeletedErrorDetails.class); - result.completeExceptionally(new StreamDeletedException(details.getStream())); - return; - } else if (d.is(StreamTombstonedErrorDetails.class)) { - StreamTombstonedErrorDetails details = d.unpack(StreamTombstonedErrorDetails.class); - result.completeExceptionally(new StreamTombstonedException(details.getStream())); - return; - } else if (d.is(AppendRecordSizeExceededErrorDetails.class)) { - AppendRecordSizeExceededErrorDetails details = d.unpack(AppendRecordSizeExceededErrorDetails.class); - result.completeExceptionally(new RecordSizeExceededException(details.getStream(), details.getRecordId(), details.getSize(), details.getMaxSize())); - return; - } else if (d.is(AppendTransactionSizeExceededErrorDetails.class)) { - AppendTransactionSizeExceededErrorDetails details = d.unpack(AppendTransactionSizeExceededErrorDetails.class); - result.completeExceptionally(new TransactionMaxSizeExceededException(details.getSize(), details.getMaxSize())); - return; - } - } catch (com.google.protobuf.InvalidProtocolBufferException ex) { - result.completeExceptionally(ex); - return; - } - } - } - } - - result.completeExceptionally(t); - } - - @Override - public void onCompleted() { - } - } -} diff --git a/src/main/java/io/kurrent/dbclient/MultiStreamAppendResponse.java b/src/main/java/io/kurrent/dbclient/MultiStreamAppendResponse.java deleted file mode 100644 index a18f894..0000000 --- a/src/main/java/io/kurrent/dbclient/MultiStreamAppendResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.kurrent.dbclient; - -import java.util.List; - -// TODO: Deprecate this class in favor of AppendRecordsResponse -public class MultiStreamAppendResponse { - private final long position; - private final List results; - - public MultiStreamAppendResponse(long position, List results) { - this.position = position; - this.results = results; - } - - public long getPosition() { - return position; - } - - public List getResults() { - return results; - } -} diff --git a/src/main/java/io/kurrent/dbclient/RecordSizeExceededException.java b/src/main/java/io/kurrent/dbclient/RecordSizeExceededException.java deleted file mode 100644 index d4ea887..0000000 --- a/src/main/java/io/kurrent/dbclient/RecordSizeExceededException.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.kurrent.dbclient; - -/** - * Thrown when an append record exceeds the maximum allowed size. - */ -public class RecordSizeExceededException extends RuntimeException { - /** - * The name of the stream where the append was attempted. - */ - private final String stream; - - /** - * The identifier of the offending and oversized record. - */ - private final String recordId; - - /** - * The size of the huge record in bytes. - */ - private final int size; - - /** - * The maximum allowed size of a single record that can be appended in bytes. - */ - private final int maxSize; - - public RecordSizeExceededException(String stream, String recordId, int size, int maxSize) { - super(String.format("The size of record %s (%d bytes) exceeds the maximum allowed size of %d bytes by %d bytes", recordId, size, maxSize, size - maxSize)); - this.stream = stream; - this.recordId = recordId; - this.size = size; - this.maxSize = maxSize; - } - - public String getStream() { - return stream; - } - - public String getRecordId() { - return recordId; - } - - public int getSize() { - return size; - } - - public int getMaxSize() { - return maxSize; - } -} diff --git a/src/main/java/io/kurrent/dbclient/TransactionMaxSizeExceededException.java b/src/main/java/io/kurrent/dbclient/TransactionMaxSizeExceededException.java deleted file mode 100644 index 53bf1be..0000000 --- a/src/main/java/io/kurrent/dbclient/TransactionMaxSizeExceededException.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.kurrent.dbclient; - -/** - * Thrown when an append transaction exceeds the maximum allowed size. - */ -public class TransactionMaxSizeExceededException extends RuntimeException { - /** - * The size of the transaction in bytes. - */ - private final int size; - - /** - * The maximum allowed size of the append transaction in bytes. - */ - private final int maxSize; - - public TransactionMaxSizeExceededException(int size, int maxSize) { - super(String.format("The total size of the append transaction (%d bytes) exceeds the maximum allowed size of %d bytes by %d bytes", size, maxSize, size - maxSize)); - this.size = size; - this.maxSize = maxSize; - } - - public int getSize() { - return size; - } - - public int getMaxSize() { - return maxSize; - } -} diff --git a/src/main/java/io/kurrent/dbclient/AbortProjection.java b/src/main/java/io/trogonstack/eventstore/client/AbortProjection.java similarity index 87% rename from src/main/java/io/kurrent/dbclient/AbortProjection.java rename to src/main/java/io/trogonstack/eventstore/client/AbortProjection.java index e87b1b4..d304e95 100644 --- a/src/main/java/io/kurrent/dbclient/AbortProjection.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbortProjection.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/AbortProjectionOptions.java b/src/main/java/io/trogonstack/eventstore/client/AbortProjectionOptions.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/AbortProjectionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/AbortProjectionOptions.java index 357b64a..a2eb86d 100644 --- a/src/main/java/io/kurrent/dbclient/AbortProjectionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbortProjectionOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the abort projection request. diff --git a/src/main/java/io/kurrent/dbclient/AbstractCreatePersistentSubscription.java b/src/main/java/io/trogonstack/eventstore/client/AbstractCreatePersistentSubscription.java similarity index 84% rename from src/main/java/io/kurrent/dbclient/AbstractCreatePersistentSubscription.java rename to src/main/java/io/trogonstack/eventstore/client/AbstractCreatePersistentSubscription.java index 4e9b1dd..1d4ebff 100644 --- a/src/main/java/io/kurrent/dbclient/AbstractCreatePersistentSubscription.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbstractCreatePersistentSubscription.java @@ -1,11 +1,10 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Optional; import java.util.concurrent.CompletableFuture; abstract class AbstractCreatePersistentSubscription { @@ -32,8 +31,6 @@ protected Persistent.CreateReq.Settings.Builder createSettings(){ @SuppressWarnings({"unchecked", "deprecation"}) public CompletableFuture execute() { return this.client.runWithArgs(args -> { - Optional serverVersion = args.getServerVersion(); - CompletableFuture result = new CompletableFuture(); PersistentSubscriptionsGrpc.PersistentSubscriptionsStub client = GrpcUtils.configureStub(PersistentSubscriptionsGrpc.newStub(args.getChannel()), this.client.getSettings(), this.options); @@ -60,12 +57,7 @@ public CompletableFuture execute() { } else if (settings.getNamedConsumerStrategy().isPinned()) { settingsBuilder.setNamedConsumerStrategy(Persistent.CreateReq.ConsumerStrategy.Pinned); } else if (settings.getNamedConsumerStrategy().isPinnedByCorrelation()) { - if (serverVersion.get().isGreaterThan(21, 10, 0)) { - settingsBuilder.setConsumerStrategy(settings.getNamedConsumerStrategy().toString()); - } else { - logger.error("Consumer strategy: '{}' is only available on server 21.10.1 and above", NamedConsumerStrategy.PINNED_BY_CORRELATION); - throw new UnsupportedFeatureException(); - } + settingsBuilder.setConsumerStrategy(settings.getNamedConsumerStrategy().toString()); } else { logger.error("Unsupported named consumer strategy: '{}'", settings.getNamedConsumerStrategy().toString()); throw new UnsupportedFeatureException(); diff --git a/src/main/java/io/kurrent/dbclient/AbstractDeletePersistentSubscription.java b/src/main/java/io/trogonstack/eventstore/client/AbstractDeletePersistentSubscription.java similarity index 87% rename from src/main/java/io/kurrent/dbclient/AbstractDeletePersistentSubscription.java rename to src/main/java/io/trogonstack/eventstore/client/AbstractDeletePersistentSubscription.java index fff38d2..89e067e 100644 --- a/src/main/java/io/kurrent/dbclient/AbstractDeletePersistentSubscription.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbstractDeletePersistentSubscription.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/AbstractPersistentSubscriptionSettingsBuilder.java b/src/main/java/io/trogonstack/eventstore/client/AbstractPersistentSubscriptionSettingsBuilder.java similarity index 99% rename from src/main/java/io/kurrent/dbclient/AbstractPersistentSubscriptionSettingsBuilder.java rename to src/main/java/io/trogonstack/eventstore/client/AbstractPersistentSubscriptionSettingsBuilder.java index 869bfe5..a950f0c 100644 --- a/src/main/java/io/kurrent/dbclient/AbstractPersistentSubscriptionSettingsBuilder.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbstractPersistentSubscriptionSettingsBuilder.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.time.Duration; diff --git a/src/main/java/io/kurrent/dbclient/AbstractRead.java b/src/main/java/io/trogonstack/eventstore/client/AbstractRead.java similarity index 87% rename from src/main/java/io/kurrent/dbclient/AbstractRead.java rename to src/main/java/io/trogonstack/eventstore/client/AbstractRead.java index 55e0ba8..b93484a 100644 --- a/src/main/java/io/kurrent/dbclient/AbstractRead.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbstractRead.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsGrpc; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsGrpc; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; diff --git a/src/main/java/io/kurrent/dbclient/AbstractRegularSubscription.java b/src/main/java/io/trogonstack/eventstore/client/AbstractRegularSubscription.java similarity index 92% rename from src/main/java/io/kurrent/dbclient/AbstractRegularSubscription.java rename to src/main/java/io/trogonstack/eventstore/client/AbstractRegularSubscription.java index 9309929..308636a 100644 --- a/src/main/java/io/kurrent/dbclient/AbstractRegularSubscription.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbstractRegularSubscription.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsGrpc; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsGrpc; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import io.grpc.Metadata; import io.grpc.Status; import io.grpc.StatusRuntimeException; diff --git a/src/main/java/io/kurrent/dbclient/AbstractSubscribePersistentSubscription.java b/src/main/java/io/trogonstack/eventstore/client/AbstractSubscribePersistentSubscription.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/AbstractSubscribePersistentSubscription.java rename to src/main/java/io/trogonstack/eventstore/client/AbstractSubscribePersistentSubscription.java index 9324151..58657f0 100644 --- a/src/main/java/io/kurrent/dbclient/AbstractSubscribePersistentSubscription.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbstractSubscribePersistentSubscription.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; +import io.trogonstack.eventstore.client.proto.shared.Shared; import io.grpc.Metadata; import io.grpc.Status; import io.grpc.StatusRuntimeException; diff --git a/src/main/java/io/kurrent/dbclient/AbstractUpdatePersistentSubscription.java b/src/main/java/io/trogonstack/eventstore/client/AbstractUpdatePersistentSubscription.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/AbstractUpdatePersistentSubscription.java rename to src/main/java/io/trogonstack/eventstore/client/AbstractUpdatePersistentSubscription.java index 5d7c0e3..5218795 100644 --- a/src/main/java/io/kurrent/dbclient/AbstractUpdatePersistentSubscription.java +++ b/src/main/java/io/trogonstack/eventstore/client/AbstractUpdatePersistentSubscription.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,6 +55,8 @@ public CompletableFuture execute() { settingsBuilder.setNamedConsumerStrategy(Persistent.UpdateReq.ConsumerStrategy.RoundRobin); } else if (settings.getNamedConsumerStrategy().isPinned()) { settingsBuilder.setNamedConsumerStrategy(Persistent.UpdateReq.ConsumerStrategy.Pinned); + } else if (settings.getNamedConsumerStrategy().isPinnedByCorrelation()) { + settingsBuilder.setConsumerStrategy(settings.getNamedConsumerStrategy().toString()); } else { logger.error(String.format("Unsupported named consumer strategy: '%s'", settings.getNamedConsumerStrategy().toString())); throw new UnsupportedFeatureException(); diff --git a/src/main/java/io/kurrent/dbclient/Acl.java b/src/main/java/io/trogonstack/eventstore/client/Acl.java similarity index 65% rename from src/main/java/io/kurrent/dbclient/Acl.java rename to src/main/java/io/trogonstack/eventstore/client/Acl.java index cb24b96..029cc87 100644 --- a/src/main/java/io/kurrent/dbclient/Acl.java +++ b/src/main/java/io/trogonstack/eventstore/client/Acl.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Common access control list (ACL) interface. diff --git a/src/main/java/io/kurrent/dbclient/Acls.java b/src/main/java/io/trogonstack/eventstore/client/Acls.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/Acls.java rename to src/main/java/io/trogonstack/eventstore/client/Acls.java index cfe71ef..ee07896 100644 --- a/src/main/java/io/kurrent/dbclient/Acls.java +++ b/src/main/java/io/trogonstack/eventstore/client/Acls.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Access control list (ACL) utility class. diff --git a/src/main/java/io/kurrent/dbclient/AppendResponse.java b/src/main/java/io/trogonstack/eventstore/client/AppendResponse.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/AppendResponse.java rename to src/main/java/io/trogonstack/eventstore/client/AppendResponse.java index 0f702be..a720fe2 100644 --- a/src/main/java/io/kurrent/dbclient/AppendResponse.java +++ b/src/main/java/io/trogonstack/eventstore/client/AppendResponse.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; public class AppendResponse { private final String stream; diff --git a/src/main/java/io/kurrent/dbclient/AppendToStream.java b/src/main/java/io/trogonstack/eventstore/client/AppendToStream.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/AppendToStream.java rename to src/main/java/io/trogonstack/eventstore/client/AppendToStream.java index e483a7b..3b0845f 100644 --- a/src/main/java/io/kurrent/dbclient/AppendToStream.java +++ b/src/main/java/io/trogonstack/eventstore/client/AppendToStream.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsGrpc; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsGrpc; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import com.google.protobuf.ByteString; import io.grpc.ManagedChannel; import io.grpc.stub.StreamObserver; diff --git a/src/main/java/io/kurrent/dbclient/AppendToStreamOptions.java b/src/main/java/io/trogonstack/eventstore/client/AppendToStreamOptions.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/AppendToStreamOptions.java rename to src/main/java/io/trogonstack/eventstore/client/AppendToStreamOptions.java index 3dd3f2b..37b50b0 100644 --- a/src/main/java/io/kurrent/dbclient/AppendToStreamOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/AppendToStreamOptions.java @@ -1,16 +1,16 @@ -package io.kurrent.dbclient; - -/** - * Options of the append stream request. - */ -public class AppendToStreamOptions extends OptionsWithStreamStateBase { - private AppendToStreamOptions() { - } - - /** - * Returns options with default values. - */ - public static AppendToStreamOptions get() { - return new AppendToStreamOptions(); - } -} +package io.trogonstack.eventstore.client; + +/** + * Options of the append stream request. + */ +public class AppendToStreamOptions extends OptionsWithStreamStateBase { + private AppendToStreamOptions() { + } + + /** + * Returns options with default values. + */ + public static AppendToStreamOptions get() { + return new AppendToStreamOptions(); + } +} diff --git a/src/main/java/io/kurrent/dbclient/Checkpointer.java b/src/main/java/io/trogonstack/eventstore/client/Checkpointer.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/Checkpointer.java rename to src/main/java/io/trogonstack/eventstore/client/Checkpointer.java index 0bfc8fe..fff49a9 100644 --- a/src/main/java/io/kurrent/dbclient/Checkpointer.java +++ b/src/main/java/io/trogonstack/eventstore/client/Checkpointer.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/ClientCertificate.java b/src/main/java/io/trogonstack/eventstore/client/ClientCertificate.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/ClientCertificate.java rename to src/main/java/io/trogonstack/eventstore/client/ClientCertificate.java index bdc7327..3325b42 100644 --- a/src/main/java/io/kurrent/dbclient/ClientCertificate.java +++ b/src/main/java/io/trogonstack/eventstore/client/ClientCertificate.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Objects; diff --git a/src/main/java/io/kurrent/dbclient/ClientFeatureFlags.java b/src/main/java/io/trogonstack/eventstore/client/ClientFeatureFlags.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/ClientFeatureFlags.java rename to src/main/java/io/trogonstack/eventstore/client/ClientFeatureFlags.java index 8409fec..b577187 100644 --- a/src/main/java/io/kurrent/dbclient/ClientFeatureFlags.java +++ b/src/main/java/io/trogonstack/eventstore/client/ClientFeatureFlags.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; public final class ClientFeatureFlags { /** diff --git a/src/main/java/io/kurrent/dbclient/ClientTelemetry.java b/src/main/java/io/trogonstack/eventstore/client/ClientTelemetry.java similarity index 64% rename from src/main/java/io/kurrent/dbclient/ClientTelemetry.java rename to src/main/java/io/trogonstack/eventstore/client/ClientTelemetry.java index b4f1c4c..f50a08f 100644 --- a/src/main/java/io/kurrent/dbclient/ClientTelemetry.java +++ b/src/main/java/io/trogonstack/eventstore/client/ClientTelemetry.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -87,14 +87,14 @@ private static SpanContext tryExtractTracingContext(byte[] userMetadataBytes) { static CompletableFuture traceAppend( BiFunction, CompletableFuture> appendOperation, ManagedChannel channel, - List events, String streamId, KurrentDBClientSettings settings, + List events, String streamId, TrogonEventStoreClientSettings settings, UserCredentials optionalCallCredentials) { Span span = createSpan( ClientTelemetryConstants.Operations.APPEND, SpanKind.CLIENT, null, ClientTelemetryTags.builder() - .withRequiredTag(ClientTelemetryAttributes.KurrentDB.STREAM, streamId) + .withRequiredTag(ClientTelemetryAttributes.TrogonEventStore.STREAM, streamId) .withServerTagsFromGrpcChannel(channel) .withServerTagsFromClientSettings(settings) .withOptionalDatabaseUserTag(settings.getDefaultCredentials()) @@ -119,92 +119,8 @@ static CompletableFuture traceAppend( } } - static CompletableFuture traceMultiStreamAppend( - BiFunction, CompletableFuture> multiAppendOperation, - WorkItemArgs args, - Iterator requests, KurrentDBClientSettings settings) { - - List requestsWithTracing = new ArrayList<>(); - - Span span = createSpan( - ClientTelemetryConstants.Operations.MULTI_APPEND, - SpanKind.CLIENT, - null, - ClientTelemetryTags.builder() - .withServerTagsFromGrpcChannel(args.getChannel()) - .withServerTagsFromClientSettings(settings) - .withOptionalDatabaseUserTag(settings.getDefaultCredentials()) - .build()); - - while (requests.hasNext()) { - AppendStreamRequest request = requests.next(); - - List eventsWithTracing = new ArrayList<>(); - while (request.getEvents().hasNext()) - eventsWithTracing.add(request.getEvents().next()); - - List tracedEvents = tryInjectTracingContext(span, eventsWithTracing); - - requestsWithTracing.add(new AppendStreamRequest( - request.getStreamName(), - tracedEvents.iterator(), - request.getExpectedState() - )); - } - - return multiAppendOperation.apply(args, requestsWithTracing.iterator()) - .handle((result, throwable) -> { - if (throwable != null) { - span.setStatus(StatusCode.ERROR); - span.recordException(throwable); - span.end(); - throw new CompletionException(throwable); - } else { - span.setStatus(StatusCode.OK); - span.end(); - return result; - } - }); - } - - static CompletableFuture traceAppendRecords( - BiFunction, CompletableFuture> appendRecordsOperation, - WorkItemArgs args, - List records, KurrentDBClientSettings settings) { - - Span span = createSpan( - ClientTelemetryConstants.Operations.MULTI_APPEND, - SpanKind.CLIENT, - null, - ClientTelemetryTags.builder() - .withServerTagsFromGrpcChannel(args.getChannel()) - .withServerTagsFromClientSettings(settings) - .withOptionalDatabaseUserTag(settings.getDefaultCredentials()) - .build()); - - List recordsWithTracing = new ArrayList<>(); - for (AppendRecord record : records) { - List traced = tryInjectTracingContext(span, Collections.singletonList(record.getRecord())); - recordsWithTracing.add(new AppendRecord(record.getStream(), traced.get(0))); - } - - return appendRecordsOperation.apply(args, recordsWithTracing) - .handle((result, throwable) -> { - if (throwable != null) { - span.setStatus(StatusCode.ERROR); - span.recordException(throwable); - span.end(); - throw new CompletionException(throwable); - } else { - span.setStatus(StatusCode.OK); - span.end(); - return result; - } - }); - } - static void traceSubscribe(Runnable tracedOperation, String subscriptionId, ManagedChannel channel, - KurrentDBClientSettings settings, + TrogonEventStoreClientSettings settings, UserCredentials optionalCallCredentials, RecordedEvent event) { if (event == null) { tracedOperation.run(); @@ -223,10 +139,10 @@ static void traceSubscribe(Runnable tracedOperation, String subscriptionId, Mana SpanKind.CONSUMER, remoteParentContext, ClientTelemetryTags.builder() - .withRequiredTag(ClientTelemetryAttributes.KurrentDB.STREAM, event.getStreamId()) - .withRequiredTag(ClientTelemetryAttributes.KurrentDB.SUBSCRIPTION_ID, subscriptionId) - .withRequiredTag(ClientTelemetryAttributes.KurrentDB.EVENT_ID, event.getEventId().toString()) - .withRequiredTag(ClientTelemetryAttributes.KurrentDB.EVENT_TYPE, event.getEventType()) + .withRequiredTag(ClientTelemetryAttributes.TrogonEventStore.STREAM, event.getStreamId()) + .withRequiredTag(ClientTelemetryAttributes.TrogonEventStore.SUBSCRIPTION_ID, subscriptionId) + .withRequiredTag(ClientTelemetryAttributes.TrogonEventStore.EVENT_ID, event.getEventId().toString()) + .withRequiredTag(ClientTelemetryAttributes.TrogonEventStore.EVENT_TYPE, event.getEventType()) .withServerTagsFromGrpcChannel(channel) .withServerTagsFromClientSettings(settings) .withOptionalDatabaseUserTag(settings.getDefaultCredentials()) diff --git a/src/main/java/io/kurrent/dbclient/ClientTelemetryAttributes.java b/src/main/java/io/trogonstack/eventstore/client/ClientTelemetryAttributes.java similarity index 71% rename from src/main/java/io/kurrent/dbclient/ClientTelemetryAttributes.java rename to src/main/java/io/trogonstack/eventstore/client/ClientTelemetryAttributes.java index 8fc3074..3ddc9e2 100644 --- a/src/main/java/io/kurrent/dbclient/ClientTelemetryAttributes.java +++ b/src/main/java/io/trogonstack/eventstore/client/ClientTelemetryAttributes.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.opentelemetry.semconv.ExceptionAttributes; import io.opentelemetry.semconv.ServerAttributes; @@ -22,10 +22,10 @@ public static class Exceptions { public static final String STACK_TRACE = ExceptionAttributes.EXCEPTION_STACKTRACE.getKey(); } - public static class KurrentDB { - public static final String STREAM = "db.kurrentdb.stream"; - public static final String SUBSCRIPTION_ID = "db.kurrentdb.subscription.id"; - public static final String EVENT_ID = "db.kurrentdb.event.id"; - public static final String EVENT_TYPE = "db.kurrentdb.event.type"; + public static class TrogonEventStore { + public static final String STREAM = "db.trogon_eventstore.stream"; + public static final String SUBSCRIPTION_ID = "db.trogon_eventstore.subscription.id"; + public static final String EVENT_ID = "db.trogon_eventstore.event.id"; + public static final String EVENT_TYPE = "db.trogon_eventstore.event.type"; } } diff --git a/src/main/java/io/kurrent/dbclient/ClientTelemetryConstants.java b/src/main/java/io/trogonstack/eventstore/client/ClientTelemetryConstants.java similarity index 68% rename from src/main/java/io/kurrent/dbclient/ClientTelemetryConstants.java rename to src/main/java/io/trogonstack/eventstore/client/ClientTelemetryConstants.java index f4d77dc..31120c1 100644 --- a/src/main/java/io/kurrent/dbclient/ClientTelemetryConstants.java +++ b/src/main/java/io/trogonstack/eventstore/client/ClientTelemetryConstants.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; public class ClientTelemetryConstants { - public static final String INSTRUMENTATION_NAME = "kurrentdb"; + public static final String INSTRUMENTATION_NAME = "trogon_eventstore"; public static class Metadata { public static final String TRACE_ID = "$traceId"; @@ -10,7 +10,6 @@ public static class Metadata { public static class Operations { public static final String APPEND = "streams.append"; - public static final String MULTI_APPEND = "streams.multi-append"; public static final String SUBSCRIBE = "streams.subscribe"; } } diff --git a/src/main/java/io/kurrent/dbclient/ClientTelemetryTags.java b/src/main/java/io/trogonstack/eventstore/client/ClientTelemetryTags.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/ClientTelemetryTags.java rename to src/main/java/io/trogonstack/eventstore/client/ClientTelemetryTags.java index 49efc5a..2377413 100644 --- a/src/main/java/io/kurrent/dbclient/ClientTelemetryTags.java +++ b/src/main/java/io/trogonstack/eventstore/client/ClientTelemetryTags.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.ManagedChannel; @@ -33,7 +33,7 @@ Builder withServerTagsFromGrpcChannel(ManagedChannel channel) { return withServerTags(authorityParts[0], authorityParts[1]); } - Builder withServerTagsFromClientSettings(KurrentDBClientSettings settings) { + Builder withServerTagsFromClientSettings(TrogonEventStoreClientSettings settings) { if (settings == null || !settings.isDnsDiscover()) return this; Endpoint dns = settings.getHosts()[0]; diff --git a/src/main/java/io/kurrent/dbclient/ClusterDiscovery.java b/src/main/java/io/trogonstack/eventstore/client/ClusterDiscovery.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/ClusterDiscovery.java rename to src/main/java/io/trogonstack/eventstore/client/ClusterDiscovery.java index b645a36..a806b3f 100644 --- a/src/main/java/io/kurrent/dbclient/ClusterDiscovery.java +++ b/src/main/java/io/trogonstack/eventstore/client/ClusterDiscovery.java @@ -1,9 +1,9 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.resolution.DeferredNodeResolution; -import io.kurrent.dbclient.resolution.DeprecatedNodeResolution; -import io.kurrent.dbclient.resolution.FixedSeedsNodeResolution; -import io.kurrent.dbclient.resolution.NodeResolution; +import io.trogonstack.eventstore.client.resolution.DeferredNodeResolution; +import io.trogonstack.eventstore.client.resolution.DeprecatedNodeResolution; +import io.trogonstack.eventstore.client.resolution.FixedSeedsNodeResolution; +import io.trogonstack.eventstore.client.resolution.NodeResolution; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,7 +19,7 @@ class ClusterDiscovery implements Discovery { private final NodeSelector nodeSelector; private final NodeResolution resolution; - ClusterDiscovery(KurrentDBClientSettings settings) { + ClusterDiscovery(TrogonEventStoreClientSettings settings) { this.nodeSelector = new NodeSelector(settings.getNodePreference()); if (settings.isDnsDiscover()) { diff --git a/src/main/java/io/kurrent/dbclient/ClusterInfo.java b/src/main/java/io/trogonstack/eventstore/client/ClusterInfo.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/ClusterInfo.java rename to src/main/java/io/trogonstack/eventstore/client/ClusterInfo.java index 157e6b5..bb918a3 100644 --- a/src/main/java/io/kurrent/dbclient/ClusterInfo.java +++ b/src/main/java/io/trogonstack/eventstore/client/ClusterInfo.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.gossip.GossipOuterClass; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.gossip.GossipOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; import java.net.InetSocketAddress; import java.util.ArrayList; diff --git a/src/main/java/io/kurrent/dbclient/ConnectionMetadata.java b/src/main/java/io/trogonstack/eventstore/client/ConnectionMetadata.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/ConnectionMetadata.java rename to src/main/java/io/trogonstack/eventstore/client/ConnectionMetadata.java index 209df5f..5056ee1 100644 --- a/src/main/java/io/kurrent/dbclient/ConnectionMetadata.java +++ b/src/main/java/io/trogonstack/eventstore/client/ConnectionMetadata.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.Metadata; diff --git a/src/main/java/io/kurrent/dbclient/ConnectionService.java b/src/main/java/io/trogonstack/eventstore/client/ConnectionService.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/ConnectionService.java rename to src/main/java/io/trogonstack/eventstore/client/ConnectionService.java index cf6e2b9..7c6d833 100644 --- a/src/main/java/io/kurrent/dbclient/ConnectionService.java +++ b/src/main/java/io/trogonstack/eventstore/client/ConnectionService.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,12 +19,12 @@ class ConnectionService implements Runnable { private final AtomicBoolean closed; private final LinkedBlockingQueue queue; private final Discovery discovery; - private final KurrentDBClientSettings settings; + private final TrogonEventStoreClientSettings settings; private final ConnectionState connection; private UUID channelId = UUID.randomUUID(); private ServerInfo serverInfo = null; - ConnectionService(KurrentDBClientSettings settings, Discovery discovery) { + ConnectionService(TrogonEventStoreClientSettings settings, Discovery discovery) { this.settings = settings; this.discovery = discovery; this.connection = new ConnectionState(settings); diff --git a/src/main/java/io/kurrent/dbclient/ConnectionSettingsBuilder.java b/src/main/java/io/trogonstack/eventstore/client/ConnectionSettingsBuilder.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/ConnectionSettingsBuilder.java rename to src/main/java/io/trogonstack/eventstore/client/ConnectionSettingsBuilder.java index eb15951..bca5281 100644 --- a/src/main/java/io/kurrent/dbclient/ConnectionSettingsBuilder.java +++ b/src/main/java/io/trogonstack/eventstore/client/ConnectionSettingsBuilder.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.ClientInterceptor; @@ -17,7 +17,7 @@ public class ConnectionSettingsBuilder { private static final Logger logger = LoggerFactory.getLogger(ConnectionSettingsBuilder.class); private static final Set SUPPORTED_PROTOCOLS = new HashSet<>(Arrays.asList( - "esdb", "esdb+discover", "kurrentdb", "kurrent+discover", "kdb", "kdb+discover", "kurrentdb", "kurrentdb+discover" + "trogon-eventstore", "trogon-eventstore+discover" )); private boolean _dnsDiscover = false; @@ -41,11 +41,11 @@ public class ConnectionSettingsBuilder { /** * Returns configured connection settings. - * @see KurrentDBClientSettings + * @see TrogonEventStoreClientSettings * @return configured settings. */ - public KurrentDBClientSettings buildConnectionSettings() { - return new KurrentDBClientSettings(_dnsDiscover, + public TrogonEventStoreClientSettings buildConnectionSettings() { + return new TrogonEventStoreClientSettings(_dnsDiscover, _maxDiscoverAttempts, _discoveryInterval, _gossipTimeout, @@ -261,13 +261,10 @@ void parseGossipSeed(String host) { } } - static KurrentDBClientSettings parseFromUrl(ConnectionSettingsBuilder builder, URL url) { + static TrogonEventStoreClientSettings parseFromUrl(ConnectionSettingsBuilder builder, URL url) { if (!SUPPORTED_PROTOCOLS.contains(url.getProtocol())) throw new RuntimeException(String.format("Unknown URL scheme: %s", url.getProtocol())); - if (url.getProtocol().contains("esdb")) - logger.warn("The 'esdb' protocol is deprecated. Please use 'kurrentdb' instead."); - builder.dnsDiscover(url.getProtocol().endsWith("+discover")); if (url.getUserInfo() != null && !url.getUserInfo().isEmpty()) { diff --git a/src/main/java/io/kurrent/dbclient/ConnectionShutdownException.java b/src/main/java/io/trogonstack/eventstore/client/ConnectionShutdownException.java similarity index 82% rename from src/main/java/io/kurrent/dbclient/ConnectionShutdownException.java rename to src/main/java/io/trogonstack/eventstore/client/ConnectionShutdownException.java index aa6410a..d8ab215 100644 --- a/src/main/java/io/kurrent/dbclient/ConnectionShutdownException.java +++ b/src/main/java/io/trogonstack/eventstore/client/ConnectionShutdownException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * When a connection is already closed. diff --git a/src/main/java/io/kurrent/dbclient/ConnectionState.java b/src/main/java/io/trogonstack/eventstore/client/ConnectionState.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/ConnectionState.java rename to src/main/java/io/trogonstack/eventstore/client/ConnectionState.java index eac85ee..fabeed6 100644 --- a/src/main/java/io/kurrent/dbclient/ConnectionState.java +++ b/src/main/java/io/trogonstack/eventstore/client/ConnectionState.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.ManagedChannel; import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts; @@ -17,7 +17,7 @@ class ConnectionState { private final static Logger logger = LoggerFactory.getLogger(ConnectionState.class); private final static int MAX_INBOUND_MESSAGE_LENGTH = 17 * 1_024 * 1_024; // 17MiB - private final KurrentDBClientSettings settings; + private final TrogonEventStoreClientSettings settings; private final SslContext sslContext; private InetSocketAddress previous; private ManagedChannel currentChannel; @@ -28,7 +28,7 @@ class ConnectionState { // * If we managed to read the server features (if not, it was a not found error then it's not fatal, just old node version) private boolean confirmedChannel; - ConnectionState(KurrentDBClientSettings settings) { + ConnectionState(TrogonEventStoreClientSettings settings) { this.settings = settings; if (settings.isTls()) { @@ -68,7 +68,7 @@ ManagedChannel getCurrentChannel() { return this.currentChannel; } - KurrentDBClientSettings getSettings() { + TrogonEventStoreClientSettings getSettings() { return this.settings; } diff --git a/src/main/java/io/kurrent/dbclient/ConnectionStringParsingException.java b/src/main/java/io/trogonstack/eventstore/client/ConnectionStringParsingException.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/ConnectionStringParsingException.java rename to src/main/java/io/trogonstack/eventstore/client/ConnectionStringParsingException.java index 97c86af..a26803e 100644 --- a/src/main/java/io/kurrent/dbclient/ConnectionStringParsingException.java +++ b/src/main/java/io/trogonstack/eventstore/client/ConnectionStringParsingException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * When the provided connection string is malformed. diff --git a/src/main/java/io/kurrent/dbclient/Consts.java b/src/main/java/io/trogonstack/eventstore/client/Consts.java similarity index 80% rename from src/main/java/io/kurrent/dbclient/Consts.java rename to src/main/java/io/trogonstack/eventstore/client/Consts.java index b3bb819..647465d 100644 --- a/src/main/java/io/kurrent/dbclient/Consts.java +++ b/src/main/java/io/trogonstack/eventstore/client/Consts.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class Consts { public static long DEFAULT_KEEP_ALIVE_TIMEOUT_IN_MS = 10000; // 10secs diff --git a/src/main/java/io/kurrent/dbclient/ContentType.java b/src/main/java/io/trogonstack/eventstore/client/ContentType.java similarity index 77% rename from src/main/java/io/kurrent/dbclient/ContentType.java rename to src/main/java/io/trogonstack/eventstore/client/ContentType.java index 72874fb..43eae44 100644 --- a/src/main/java/io/kurrent/dbclient/ContentType.java +++ b/src/main/java/io/trogonstack/eventstore/client/ContentType.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class ContentType { public static final String JSON = "application/json"; diff --git a/src/main/java/io/kurrent/dbclient/CreateChannel.java b/src/main/java/io/trogonstack/eventstore/client/CreateChannel.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/CreateChannel.java rename to src/main/java/io/trogonstack/eventstore/client/CreateChannel.java index 919c36c..ec1542a 100644 --- a/src/main/java/io/kurrent/dbclient/CreateChannel.java +++ b/src/main/java/io/trogonstack/eventstore/client/CreateChannel.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.net.InetSocketAddress; import java.util.StringJoiner; diff --git a/src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToAll.java b/src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToAll.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToAll.java rename to src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToAll.java index 310a70f..43527df 100644 --- a/src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToAll.java +++ b/src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToAll.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; class CreatePersistentSubscriptionToAll extends AbstractCreatePersistentSubscription { private final CreatePersistentSubscriptionToAllOptions options; diff --git a/src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToAllOptions.java b/src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToAllOptions.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToAllOptions.java rename to src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToAllOptions.java index b20e6b2..8689955 100644 --- a/src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToAllOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToAllOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of create persistent subscription to $all request. diff --git a/src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToStream.java b/src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToStream.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToStream.java rename to src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToStream.java index 971a285..b870594 100644 --- a/src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToStream.java +++ b/src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToStream.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; import com.google.protobuf.ByteString; class CreatePersistentSubscriptionToStream extends AbstractCreatePersistentSubscription { diff --git a/src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToStreamOptions.java b/src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToStreamOptions.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToStreamOptions.java rename to src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToStreamOptions.java index dde50c8..628b907 100644 --- a/src/main/java/io/kurrent/dbclient/CreatePersistentSubscriptionToStreamOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/CreatePersistentSubscriptionToStreamOptions.java @@ -1,44 +1,44 @@ -package io.kurrent.dbclient; - -/** - * Options for the create persistent subscription to stream request. - */ -public class CreatePersistentSubscriptionToStreamOptions - extends AbstractPersistentSubscriptionSettingsBuilder { - CreatePersistentSubscriptionToStreamOptions() { - super(PersistentSubscriptionSettings.defaultRegular()); - } - - /** - * Returns options with default values. - */ - public static CreatePersistentSubscriptionToStreamOptions get() { - return new CreatePersistentSubscriptionToStreamOptions(); - } - - /** - * Starts the subscription from the beginning of the given stream. - - */ - public CreatePersistentSubscriptionToStreamOptions fromStart() { - getSettings().setStartFrom(StreamPosition.start()); - return this; - } - - /** - * Starts the subscription from the end of the given stream. - - */ - public CreatePersistentSubscriptionToStreamOptions fromEnd() { - getSettings().setStartFrom(StreamPosition.end()); - return this; - } - - /** - * Starts the subscription from the given stream revision. - */ - public CreatePersistentSubscriptionToStreamOptions startFrom(long revision) { - getSettings().setStartFrom(StreamPosition.position(revision)); - return this; - } -} +package io.trogonstack.eventstore.client; + +/** + * Options for the create persistent subscription to stream request. + */ +public class CreatePersistentSubscriptionToStreamOptions + extends AbstractPersistentSubscriptionSettingsBuilder { + CreatePersistentSubscriptionToStreamOptions() { + super(PersistentSubscriptionSettings.defaultRegular()); + } + + /** + * Returns options with default values. + */ + public static CreatePersistentSubscriptionToStreamOptions get() { + return new CreatePersistentSubscriptionToStreamOptions(); + } + + /** + * Starts the subscription from the beginning of the given stream. + + */ + public CreatePersistentSubscriptionToStreamOptions fromStart() { + getSettings().setStartFrom(StreamPosition.start()); + return this; + } + + /** + * Starts the subscription from the end of the given stream. + + */ + public CreatePersistentSubscriptionToStreamOptions fromEnd() { + getSettings().setStartFrom(StreamPosition.end()); + return this; + } + + /** + * Starts the subscription from the given stream revision. + */ + public CreatePersistentSubscriptionToStreamOptions startFrom(long revision) { + getSettings().setStartFrom(StreamPosition.position(revision)); + return this; + } +} diff --git a/src/main/java/io/kurrent/dbclient/CreateProjection.java b/src/main/java/io/trogonstack/eventstore/client/CreateProjection.java similarity index 64% rename from src/main/java/io/kurrent/dbclient/CreateProjection.java rename to src/main/java/io/trogonstack/eventstore/client/CreateProjection.java index d233fad..e2270ab 100644 --- a/src/main/java/io/kurrent/dbclient/CreateProjection.java +++ b/src/main/java/io/trogonstack/eventstore/client/CreateProjection.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import java.util.concurrent.CompletableFuture; @@ -12,7 +12,6 @@ class CreateProjection { private final String query; private final boolean trackEmittedStreams; private final boolean emitEnabled; - private final int engineVersion; private final CreateProjectionOptions options; public CreateProjection(final GrpcClient client, final String projectionName, final String query, @@ -23,29 +22,21 @@ public CreateProjection(final GrpcClient client, final String projectionName, fi this.query = query; this.trackEmittedStreams = options.isTrackingEmittedStreams(); this.emitEnabled = options.isEmitEnabled(); - this.engineVersion = options.getEngineVersion(); this.options = options; } @SuppressWarnings("unchecked") public CompletableFuture execute() { - if (engineVersion == 2 && trackEmittedStreams) { - CompletableFuture result = new CompletableFuture<>(); - result.completeExceptionally(new IllegalArgumentException( - "trackEmittedStreams is not supported when engineVersion is 2 (V2)")); - return result; - } - return this.client.run(channel -> { Projectionmanagement.CreateReq.Options.Continuous.Builder continuousBuilder = Projectionmanagement.CreateReq.Options.Continuous.newBuilder() .setName(projectionName) + .setEmitEnabled(emitEnabled) .setTrackEmittedStreams(trackEmittedStreams); Projectionmanagement.CreateReq.Options.Builder optionsBuilder = Projectionmanagement.CreateReq.Options.newBuilder() .setQuery(query) - .setEngineVersion(engineVersion) .setContinuous(continuousBuilder); Projectionmanagement.CreateReq request = Projectionmanagement.CreateReq.newBuilder() @@ -59,15 +50,6 @@ public CompletableFuture execute() { client.create(request, GrpcUtils.convertSingleResponse(result)); return result; - }).thenApplyAsync(result -> { - if (emitEnabled) { - UpdateProjectionOptions options = UpdateProjectionOptions.get().emitEnabled(true); - UpdateProjection update = new UpdateProjection(client, projectionName, query, options); - - return update.execute().thenApply(x -> result); - } - - return CompletableFuture.completedFuture(result); }); } } diff --git a/src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java b/src/main/java/io/trogonstack/eventstore/client/CreateProjectionOptions.java similarity index 51% rename from src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/CreateProjectionOptions.java index 1d3b2f0..39a5d6d 100644 --- a/src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/CreateProjectionOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options for create projection request. @@ -6,7 +6,6 @@ public class CreateProjectionOptions extends OptionsBase { private boolean trackEmittedStreams; private boolean emitEnabled; - private int engineVersion; private CreateProjectionOptions() { this.trackEmittedStreams = false; @@ -27,10 +26,6 @@ boolean isEmitEnabled() { return emitEnabled; } - int getEngineVersion() { - return engineVersion; - } - /** * If true, the projection tracks all streams it creates. */ @@ -47,22 +42,4 @@ public CreateProjectionOptions emitEnabled(boolean value) { return this; } - /** - * Selects the projection engine version. {@code 0} (default) or {@code 1} selects V1; - * {@code 2} selects the V2 engine, which provides partition-based parallel processing. - *

- * The engine version is pinned at create time and cannot be changed via update. - * V2 has limitations versus V1: {@code trackEmittedStreams} is rejected, - * result streams are not emitted, and bi-state projections are not supported. - * - * @throws IllegalArgumentException if {@code value} is not {@code 0}, {@code 1}, or {@code 2}. - */ - public CreateProjectionOptions engineVersion(int value) { - if (value < 0 || value > 2) { - throw new IllegalArgumentException( - "engineVersion must be 0, 1, or 2 (got " + value + ")"); - } - this.engineVersion = value; - return this; - } } diff --git a/src/main/java/io/kurrent/dbclient/CustomAclCodec.java b/src/main/java/io/trogonstack/eventstore/client/CustomAclCodec.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/CustomAclCodec.java rename to src/main/java/io/trogonstack/eventstore/client/CustomAclCodec.java index 4d25b6f..3b53a55 100644 --- a/src/main/java/io/kurrent/dbclient/CustomAclCodec.java +++ b/src/main/java/io/trogonstack/eventstore/client/CustomAclCodec.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; diff --git a/src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionOptions.java b/src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionOptions.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionOptions.java index 7cce208..87c5391 100644 --- a/src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionOptions.java @@ -1,16 +1,16 @@ -package io.kurrent.dbclient; - -/** - * Options of the delete persistent subscription request. - */ -public class DeletePersistentSubscriptionOptions extends OptionsBase { - private DeletePersistentSubscriptionOptions() { - } - - /** - * Returns options with default values. - */ - public static DeletePersistentSubscriptionOptions get() { - return new DeletePersistentSubscriptionOptions(); - } -} +package io.trogonstack.eventstore.client; + +/** + * Options of the delete persistent subscription request. + */ +public class DeletePersistentSubscriptionOptions extends OptionsBase { + private DeletePersistentSubscriptionOptions() { + } + + /** + * Returns options with default values. + */ + public static DeletePersistentSubscriptionOptions get() { + return new DeletePersistentSubscriptionOptions(); + } +} diff --git a/src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionToAll.java b/src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionToAll.java similarity index 73% rename from src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionToAll.java rename to src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionToAll.java index f5966b4..16b26ee 100644 --- a/src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionToAll.java +++ b/src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionToAll.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; class DeletePersistentSubscriptionToAll extends AbstractDeletePersistentSubscription { public DeletePersistentSubscriptionToAll(GrpcClient client, String group, diff --git a/src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionToStream.java b/src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionToStream.java similarity index 81% rename from src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionToStream.java rename to src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionToStream.java index 37a9265..43741ab 100644 --- a/src/main/java/io/kurrent/dbclient/DeletePersistentSubscriptionToStream.java +++ b/src/main/java/io/trogonstack/eventstore/client/DeletePersistentSubscriptionToStream.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; import com.google.protobuf.ByteString; class DeletePersistentSubscriptionToStream extends AbstractDeletePersistentSubscription { diff --git a/src/main/java/io/kurrent/dbclient/DeleteProjection.java b/src/main/java/io/trogonstack/eventstore/client/DeleteProjection.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/DeleteProjection.java rename to src/main/java/io/trogonstack/eventstore/client/DeleteProjection.java index 2a7ab8f..b18ca76 100644 --- a/src/main/java/io/kurrent/dbclient/DeleteProjection.java +++ b/src/main/java/io/trogonstack/eventstore/client/DeleteProjection.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/DeleteProjectionOptions.java b/src/main/java/io/trogonstack/eventstore/client/DeleteProjectionOptions.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/DeleteProjectionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/DeleteProjectionOptions.java index cd88e43..fe84a68 100644 --- a/src/main/java/io/kurrent/dbclient/DeleteProjectionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/DeleteProjectionOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the delete projection request. diff --git a/src/main/java/io/kurrent/dbclient/DeleteResult.java b/src/main/java/io/trogonstack/eventstore/client/DeleteResult.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/DeleteResult.java rename to src/main/java/io/trogonstack/eventstore/client/DeleteResult.java index 2765f74..6411345 100644 --- a/src/main/java/io/kurrent/dbclient/DeleteResult.java +++ b/src/main/java/io/trogonstack/eventstore/client/DeleteResult.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import javax.validation.constraints.NotNull; import java.util.Objects; diff --git a/src/main/java/io/kurrent/dbclient/DeleteStream.java b/src/main/java/io/trogonstack/eventstore/client/DeleteStream.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/DeleteStream.java rename to src/main/java/io/trogonstack/eventstore/client/DeleteStream.java index 05777c3..833f092 100644 --- a/src/main/java/io/kurrent/dbclient/DeleteStream.java +++ b/src/main/java/io/trogonstack/eventstore/client/DeleteStream.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsGrpc; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsGrpc; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import com.google.protobuf.ByteString; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/DeleteStreamOptions.java b/src/main/java/io/trogonstack/eventstore/client/DeleteStreamOptions.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/DeleteStreamOptions.java rename to src/main/java/io/trogonstack/eventstore/client/DeleteStreamOptions.java index 6ed6a8d..90fe9d6 100644 --- a/src/main/java/io/kurrent/dbclient/DeleteStreamOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/DeleteStreamOptions.java @@ -1,15 +1,15 @@ -package io.kurrent.dbclient; - -/** - * Options of the delete or tombstone stream request. - */ -public class DeleteStreamOptions extends OptionsWithStreamStateBase { - DeleteStreamOptions() {} - - /** - * Returns options with default values. - */ - public static DeleteStreamOptions get() { - return new DeleteStreamOptions(); - } -} +package io.trogonstack.eventstore.client; + +/** + * Options of the delete or tombstone stream request. + */ +public class DeleteStreamOptions extends OptionsWithStreamStateBase { + DeleteStreamOptions() {} + + /** + * Returns options with default values. + */ + public static DeleteStreamOptions get() { + return new DeleteStreamOptions(); + } +} diff --git a/src/main/java/io/kurrent/dbclient/Direction.java b/src/main/java/io/trogonstack/eventstore/client/Direction.java similarity index 83% rename from src/main/java/io/kurrent/dbclient/Direction.java rename to src/main/java/io/trogonstack/eventstore/client/Direction.java index 4147115..27e20fe 100644 --- a/src/main/java/io/kurrent/dbclient/Direction.java +++ b/src/main/java/io/trogonstack/eventstore/client/Direction.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Specifies the direction of a read operation. diff --git a/src/main/java/io/kurrent/dbclient/DisableProjection.java b/src/main/java/io/trogonstack/eventstore/client/DisableProjection.java similarity index 87% rename from src/main/java/io/kurrent/dbclient/DisableProjection.java rename to src/main/java/io/trogonstack/eventstore/client/DisableProjection.java index faa2a18..46793bd 100644 --- a/src/main/java/io/kurrent/dbclient/DisableProjection.java +++ b/src/main/java/io/trogonstack/eventstore/client/DisableProjection.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/DisableProjectionOptions.java b/src/main/java/io/trogonstack/eventstore/client/DisableProjectionOptions.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/DisableProjectionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/DisableProjectionOptions.java index 8f59ee9..69ed784 100644 --- a/src/main/java/io/kurrent/dbclient/DisableProjectionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/DisableProjectionOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the disable projection request. diff --git a/src/main/java/io/kurrent/dbclient/Discovery.java b/src/main/java/io/trogonstack/eventstore/client/Discovery.java similarity index 76% rename from src/main/java/io/kurrent/dbclient/Discovery.java rename to src/main/java/io/trogonstack/eventstore/client/Discovery.java index 5522c2f..0d43199 100644 --- a/src/main/java/io/kurrent/dbclient/Discovery.java +++ b/src/main/java/io/trogonstack/eventstore/client/Discovery.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/DynamicValueMapper.java b/src/main/java/io/trogonstack/eventstore/client/DynamicValueMapper.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/DynamicValueMapper.java rename to src/main/java/io/trogonstack/eventstore/client/DynamicValueMapper.java index 5da0227..c4422ed 100644 --- a/src/main/java/io/kurrent/dbclient/DynamicValueMapper.java +++ b/src/main/java/io/trogonstack/eventstore/client/DynamicValueMapper.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.json.JsonMapper; diff --git a/src/main/java/io/kurrent/dbclient/EnableProjection.java b/src/main/java/io/trogonstack/eventstore/client/EnableProjection.java similarity index 86% rename from src/main/java/io/kurrent/dbclient/EnableProjection.java rename to src/main/java/io/trogonstack/eventstore/client/EnableProjection.java index 402ea05..9ea9fef 100644 --- a/src/main/java/io/kurrent/dbclient/EnableProjection.java +++ b/src/main/java/io/trogonstack/eventstore/client/EnableProjection.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/EnableProjectionOptions.java b/src/main/java/io/trogonstack/eventstore/client/EnableProjectionOptions.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/EnableProjectionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/EnableProjectionOptions.java index 00f6f58..dbe6869 100644 --- a/src/main/java/io/kurrent/dbclient/EnableProjectionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/EnableProjectionOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the enable projection request. diff --git a/src/main/java/io/kurrent/dbclient/Endpoint.java b/src/main/java/io/trogonstack/eventstore/client/Endpoint.java similarity index 87% rename from src/main/java/io/kurrent/dbclient/Endpoint.java rename to src/main/java/io/trogonstack/eventstore/client/Endpoint.java index c1de3fb..72d0015 100644 --- a/src/main/java/io/kurrent/dbclient/Endpoint.java +++ b/src/main/java/io/trogonstack/eventstore/client/Endpoint.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; public class Endpoint { private final String host; diff --git a/src/main/java/io/kurrent/dbclient/EventData.java b/src/main/java/io/trogonstack/eventstore/client/EventData.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/EventData.java rename to src/main/java/io/trogonstack/eventstore/client/EventData.java index 864ce85..000db68 100644 --- a/src/main/java/io/kurrent/dbclient/EventData.java +++ b/src/main/java/io/trogonstack/eventstore/client/EventData.java @@ -1,9 +1,9 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.UUID; /** - * Represents an event that will be sent to KurrentDB. + * Represents an event that will be sent to TrogonEventStore. */ public final class EventData { private final UUID eventId; diff --git a/src/main/java/io/kurrent/dbclient/EventDataBuilder.java b/src/main/java/io/trogonstack/eventstore/client/EventDataBuilder.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/EventDataBuilder.java rename to src/main/java/io/trogonstack/eventstore/client/EventDataBuilder.java index 76bd05e..4ff8998 100644 --- a/src/main/java/io/kurrent/dbclient/EventDataBuilder.java +++ b/src/main/java/io/trogonstack/eventstore/client/EventDataBuilder.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.UUID; @@ -92,7 +92,7 @@ public EventDataBuilder metadataAsBytes(byte[] value) { } /** - * Builds an event ready to be sent to EventStoreDB. + * Builds an event ready to be sent to TrogonEventStore. * * @see EventData */ diff --git a/src/main/java/io/kurrent/dbclient/EventFilter.java b/src/main/java/io/trogonstack/eventstore/client/EventFilter.java similarity index 83% rename from src/main/java/io/kurrent/dbclient/EventFilter.java rename to src/main/java/io/trogonstack/eventstore/client/EventFilter.java index aebd9e9..817adb7 100644 --- a/src/main/java/io/kurrent/dbclient/EventFilter.java +++ b/src/main/java/io/trogonstack/eventstore/client/EventFilter.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Optional; diff --git a/src/main/java/io/kurrent/dbclient/EventTypeFilter.java b/src/main/java/io/trogonstack/eventstore/client/EventTypeFilter.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/EventTypeFilter.java rename to src/main/java/io/trogonstack/eventstore/client/EventTypeFilter.java index 7686ae7..42bda35 100644 --- a/src/main/java/io/kurrent/dbclient/EventTypeFilter.java +++ b/src/main/java/io/trogonstack/eventstore/client/EventTypeFilter.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import javax.validation.constraints.NotNull; import java.util.Arrays; diff --git a/src/main/java/io/kurrent/dbclient/FeatureFlags.java b/src/main/java/io/trogonstack/eventstore/client/FeatureFlags.java similarity index 83% rename from src/main/java/io/kurrent/dbclient/FeatureFlags.java rename to src/main/java/io/trogonstack/eventstore/client/FeatureFlags.java index 501bd30..11f7e6e 100644 --- a/src/main/java/io/kurrent/dbclient/FeatureFlags.java +++ b/src/main/java/io/trogonstack/eventstore/client/FeatureFlags.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class FeatureFlags { public final static int NOTHING = 0; public final static int BATCH_APPEND = 1; @@ -7,7 +7,5 @@ class FeatureFlags { public final static int PERSISTENT_SUBSCRIPTION_RESTART_SUBSYSTEM = 8; public final static int PERSISTENT_SUBSCRIPTION_GET_INFO = 16; public final static int PERSISTENT_SUBSCRIPTION_TO_ALL = 32; - public final static int MULTI_STREAM_APPEND = 64; - public final static int APPEND_RECORDS = 128; public final static int PERSISTENT_SUBSCRIPTION_MANAGEMENT = PERSISTENT_SUBSCRIPTION_LIST | PERSISTENT_SUBSCRIPTION_REPLAY | PERSISTENT_SUBSCRIPTION_GET_INFO | PERSISTENT_SUBSCRIPTION_RESTART_SUBSYSTEM; } diff --git a/src/main/java/io/kurrent/dbclient/GetPersistentSubscriptionInfo.java b/src/main/java/io/trogonstack/eventstore/client/GetPersistentSubscriptionInfo.java similarity index 92% rename from src/main/java/io/kurrent/dbclient/GetPersistentSubscriptionInfo.java rename to src/main/java/io/trogonstack/eventstore/client/GetPersistentSubscriptionInfo.java index 6a1ab8a..25b7898 100644 --- a/src/main/java/io/kurrent/dbclient/GetPersistentSubscriptionInfo.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetPersistentSubscriptionInfo.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; +import io.trogonstack.eventstore.client.proto.shared.Shared; import com.fasterxml.jackson.databind.JsonNode; import com.google.protobuf.ByteString; import io.grpc.Status; @@ -13,7 +13,7 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; -import static io.kurrent.dbclient.HttpUtils.*; +import static io.trogonstack.eventstore.client.HttpUtils.*; final class GetPersistentSubscriptionInfo { public static CompletableFuture> execute(GrpcClient client, GetPersistentSubscriptionInfoOptions options, String stream, String groupName) { diff --git a/src/main/java/io/kurrent/dbclient/GetPersistentSubscriptionInfoOptions.java b/src/main/java/io/trogonstack/eventstore/client/GetPersistentSubscriptionInfoOptions.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/GetPersistentSubscriptionInfoOptions.java rename to src/main/java/io/trogonstack/eventstore/client/GetPersistentSubscriptionInfoOptions.java index a878b18..0e49a7c 100644 --- a/src/main/java/io/kurrent/dbclient/GetPersistentSubscriptionInfoOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetPersistentSubscriptionInfoOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the get persistent subscription info request. diff --git a/src/main/java/io/kurrent/dbclient/GetProjectionResult.java b/src/main/java/io/trogonstack/eventstore/client/GetProjectionResult.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/GetProjectionResult.java rename to src/main/java/io/trogonstack/eventstore/client/GetProjectionResult.java index 3fcce2b..61202a6 100644 --- a/src/main/java/io/kurrent/dbclient/GetProjectionResult.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetProjectionResult.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.json.JsonMapper; diff --git a/src/main/java/io/kurrent/dbclient/GetProjectionResultOptions.java b/src/main/java/io/trogonstack/eventstore/client/GetProjectionResultOptions.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/GetProjectionResultOptions.java rename to src/main/java/io/trogonstack/eventstore/client/GetProjectionResultOptions.java index 14b5509..3756034 100644 --- a/src/main/java/io/kurrent/dbclient/GetProjectionResultOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetProjectionResultOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the get projection result request. diff --git a/src/main/java/io/kurrent/dbclient/GetProjectionState.java b/src/main/java/io/trogonstack/eventstore/client/GetProjectionState.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/GetProjectionState.java rename to src/main/java/io/trogonstack/eventstore/client/GetProjectionState.java index cf876e2..0233938 100644 --- a/src/main/java/io/kurrent/dbclient/GetProjectionState.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetProjectionState.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.json.JsonMapper; diff --git a/src/main/java/io/kurrent/dbclient/GetProjectionStateOptions.java b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStateOptions.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/GetProjectionStateOptions.java rename to src/main/java/io/trogonstack/eventstore/client/GetProjectionStateOptions.java index 90d307f..bd3e8ff 100644 --- a/src/main/java/io/kurrent/dbclient/GetProjectionStateOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStateOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the get projection state request. diff --git a/src/main/java/io/kurrent/dbclient/GetProjectionStatistics.java b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStatistics.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/GetProjectionStatistics.java rename to src/main/java/io/trogonstack/eventstore/client/GetProjectionStatistics.java index ebc2853..57140de 100644 --- a/src/main/java/io/kurrent/dbclient/GetProjectionStatistics.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStatistics.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/GetProjectionStatisticsOptions.java b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStatisticsOptions.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/GetProjectionStatisticsOptions.java rename to src/main/java/io/trogonstack/eventstore/client/GetProjectionStatisticsOptions.java index fddf4c6..20021da 100644 --- a/src/main/java/io/kurrent/dbclient/GetProjectionStatisticsOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStatisticsOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the get projection statistics request. diff --git a/src/main/java/io/kurrent/dbclient/GetProjectionStatus.java b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStatus.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/GetProjectionStatus.java rename to src/main/java/io/trogonstack/eventstore/client/GetProjectionStatus.java index 7c8260f..ee2db0a 100644 --- a/src/main/java/io/kurrent/dbclient/GetProjectionStatus.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStatus.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/GetProjectionStatusOptions.java b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStatusOptions.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/GetProjectionStatusOptions.java rename to src/main/java/io/trogonstack/eventstore/client/GetProjectionStatusOptions.java index 6de16da..c8a0b99 100644 --- a/src/main/java/io/kurrent/dbclient/GetProjectionStatusOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/GetProjectionStatusOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the get projection status request. diff --git a/src/main/java/io/kurrent/dbclient/GossipClient.java b/src/main/java/io/trogonstack/eventstore/client/GossipClient.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/GossipClient.java rename to src/main/java/io/trogonstack/eventstore/client/GossipClient.java index cd84e5a..8ed5a12 100644 --- a/src/main/java/io/kurrent/dbclient/GossipClient.java +++ b/src/main/java/io/trogonstack/eventstore/client/GossipClient.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.gossip.GossipGrpc; -import io.kurrent.dbclient.proto.gossip.GossipOuterClass; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.gossip.GossipGrpc; +import io.trogonstack.eventstore.client.proto.gossip.GossipOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; import io.grpc.ManagedChannel; import io.grpc.stub.ClientCallStreamObserver; import io.grpc.stub.ClientResponseObserver; @@ -19,7 +19,7 @@ class GossipClient { private final ManagedChannel _channel; private final GossipGrpc.GossipStub _stub; - public GossipClient(KurrentDBClientSettings settings, ManagedChannel channel) { + public GossipClient(TrogonEventStoreClientSettings settings, ManagedChannel channel) { _channel = channel; _stub = GrpcUtils.configureStub(GossipGrpc.newStub(_channel), settings, new GossipOption(), settings.getGossipTimeout()); } diff --git a/src/main/java/io/kurrent/dbclient/GrpcClient.java b/src/main/java/io/trogonstack/eventstore/client/GrpcClient.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/GrpcClient.java rename to src/main/java/io/trogonstack/eventstore/client/GrpcClient.java index 0cce2e0..e6a790d 100644 --- a/src/main/java/io/kurrent/dbclient/GrpcClient.java +++ b/src/main/java/io/trogonstack/eventstore/client/GrpcClient.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.ManagedChannel; import io.grpc.Status; @@ -18,9 +18,9 @@ class GrpcClient { private static final Logger logger = LoggerFactory.getLogger(GrpcClient.class); private final AtomicBoolean closed; private final LinkedBlockingQueue queue; - private final KurrentDBClientSettings settings; + private final TrogonEventStoreClientSettings settings; - GrpcClient(KurrentDBClientSettings settings, AtomicBoolean closed, LinkedBlockingQueue queue) { + GrpcClient(TrogonEventStoreClientSettings settings, AtomicBoolean closed, LinkedBlockingQueue queue) { this.settings = settings; this.closed = closed; this.queue = queue; @@ -117,7 +117,7 @@ public CompletableFuture shutdown() { return completion; } - public KurrentDBClientSettings getSettings() { + public TrogonEventStoreClientSettings getSettings() { return this.settings; } } \ No newline at end of file diff --git a/src/main/java/io/kurrent/dbclient/GrpcUtils.java b/src/main/java/io/trogonstack/eventstore/client/GrpcUtils.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/GrpcUtils.java rename to src/main/java/io/trogonstack/eventstore/client/GrpcUtils.java index 60f5b8c..99933af 100644 --- a/src/main/java/io/kurrent/dbclient/GrpcUtils.java +++ b/src/main/java/io/trogonstack/eventstore/client/GrpcUtils.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import com.google.protobuf.ByteString; import io.grpc.Metadata; import io.grpc.Status; @@ -127,15 +127,15 @@ static public StreamsOuterClass.ReadReq.Options.StreamOptions toStreamOptions(St .build(); } - static public , O> S configureStub(S stub, KurrentDBClientSettings settings, OptionsBase options) { + static public , O> S configureStub(S stub, TrogonEventStoreClientSettings settings, OptionsBase options) { return configureStub(stub, settings, options, null, true); } - static public , O> S configureStub(S stub, KurrentDBClientSettings settings, OptionsBase options, long forceDeadlineInMs) { + static public , O> S configureStub(S stub, TrogonEventStoreClientSettings settings, OptionsBase options, long forceDeadlineInMs) { return configureStub(stub, settings, options, forceDeadlineInMs, true); } - static public , O> S configureStub(S stub, KurrentDBClientSettings settings, OptionsBase options, Long forceDeadlineInMs, boolean forwardRequiresLeader) { + static public , O> S configureStub(S stub, TrogonEventStoreClientSettings settings, OptionsBase options, Long forceDeadlineInMs, boolean forwardRequiresLeader) { S finalStub = stub; ConnectionMetadata metadata = new ConnectionMetadata(); diff --git a/src/main/java/io/kurrent/dbclient/HttpUtils.java b/src/main/java/io/trogonstack/eventstore/client/HttpUtils.java similarity index 99% rename from src/main/java/io/kurrent/dbclient/HttpUtils.java rename to src/main/java/io/trogonstack/eventstore/client/HttpUtils.java index 8127a5c..a635238 100644 --- a/src/main/java/io/kurrent/dbclient/HttpUtils.java +++ b/src/main/java/io/trogonstack/eventstore/client/HttpUtils.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/src/main/java/io/kurrent/dbclient/ListPersistentSubscriptions.java b/src/main/java/io/trogonstack/eventstore/client/ListPersistentSubscriptions.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/ListPersistentSubscriptions.java rename to src/main/java/io/trogonstack/eventstore/client/ListPersistentSubscriptions.java index 07d5b9d..8bc9179 100644 --- a/src/main/java/io/kurrent/dbclient/ListPersistentSubscriptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/ListPersistentSubscriptions.java @@ -1,9 +1,9 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; +import io.trogonstack.eventstore.client.proto.shared.Shared; import com.fasterxml.jackson.databind.JsonNode; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; import com.google.protobuf.ByteString; import java.io.IOException; @@ -13,7 +13,7 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import static io.kurrent.dbclient.HttpUtils.*; +import static io.trogonstack.eventstore.client.HttpUtils.*; final class ListPersistentSubscriptions { public static CompletableFuture> execute(GrpcClient client, ListPersistentSubscriptionsOptions options, String stream, Function func) { diff --git a/src/main/java/io/kurrent/dbclient/ListPersistentSubscriptionsOptions.java b/src/main/java/io/trogonstack/eventstore/client/ListPersistentSubscriptionsOptions.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/ListPersistentSubscriptionsOptions.java rename to src/main/java/io/trogonstack/eventstore/client/ListPersistentSubscriptionsOptions.java index ed37beb..477202d 100644 --- a/src/main/java/io/kurrent/dbclient/ListPersistentSubscriptionsOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/ListPersistentSubscriptionsOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the list persistent subscriptions request. diff --git a/src/main/java/io/kurrent/dbclient/ListProjections.java b/src/main/java/io/trogonstack/eventstore/client/ListProjections.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/ListProjections.java rename to src/main/java/io/trogonstack/eventstore/client/ListProjections.java index d845337..420009c 100644 --- a/src/main/java/io/kurrent/dbclient/ListProjections.java +++ b/src/main/java/io/trogonstack/eventstore/client/ListProjections.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.shared.Shared; import io.grpc.stub.StreamObserver; import java.util.ArrayList; diff --git a/src/main/java/io/kurrent/dbclient/ListProjectionsOptions.java b/src/main/java/io/trogonstack/eventstore/client/ListProjectionsOptions.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/ListProjectionsOptions.java rename to src/main/java/io/trogonstack/eventstore/client/ListProjectionsOptions.java index 1afb1fb..813194b 100644 --- a/src/main/java/io/kurrent/dbclient/ListProjectionsOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/ListProjectionsOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the list projections options. diff --git a/src/main/java/io/kurrent/dbclient/ListProjectionsResult.java b/src/main/java/io/trogonstack/eventstore/client/ListProjectionsResult.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/ListProjectionsResult.java rename to src/main/java/io/trogonstack/eventstore/client/ListProjectionsResult.java index b4a0fc0..bd4f4a3 100644 --- a/src/main/java/io/kurrent/dbclient/ListProjectionsResult.java +++ b/src/main/java/io/trogonstack/eventstore/client/ListProjectionsResult.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.List; diff --git a/src/main/java/io/kurrent/dbclient/Msg.java b/src/main/java/io/trogonstack/eventstore/client/Msg.java similarity index 60% rename from src/main/java/io/kurrent/dbclient/Msg.java rename to src/main/java/io/trogonstack/eventstore/client/Msg.java index 25cd750..118a11f 100644 --- a/src/main/java/io/kurrent/dbclient/Msg.java +++ b/src/main/java/io/trogonstack/eventstore/client/Msg.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; interface Msg { void accept(ConnectionService handler); diff --git a/src/main/java/io/kurrent/dbclient/NackAction.java b/src/main/java/io/trogonstack/eventstore/client/NackAction.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/NackAction.java rename to src/main/java/io/trogonstack/eventstore/client/NackAction.java index a6e1587..64289a9 100644 --- a/src/main/java/io/kurrent/dbclient/NackAction.java +++ b/src/main/java/io/trogonstack/eventstore/client/NackAction.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Gathers every possible Nak actions. diff --git a/src/main/java/io/kurrent/dbclient/NamedConsumerStrategy.java b/src/main/java/io/trogonstack/eventstore/client/NamedConsumerStrategy.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/NamedConsumerStrategy.java rename to src/main/java/io/trogonstack/eventstore/client/NamedConsumerStrategy.java index 38f8aaa..e8d0248 100644 --- a/src/main/java/io/kurrent/dbclient/NamedConsumerStrategy.java +++ b/src/main/java/io/trogonstack/eventstore/client/NamedConsumerStrategy.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Named consumer strategies for use with persistent subscriptions. @@ -19,7 +19,7 @@ public class NamedConsumerStrategy { public static final NamedConsumerStrategy ROUND_ROBIN = new NamedConsumerStrategy("RoundRobin"); /** - * For use with an indexing projection such as the system $by_category projection. KurrentDB inspects event for + * For use with an indexing projection such as the system $by_category projection. TrogonEventStore inspects event for * its source stream id, hashing the id to one of 1024 buckets assigned to individual clients. When a client * disconnects, its buckets are assigned to other clients. When a client connects, it is assigned some existing * buckets. This naively attempts to maintain a balanced workload. The main goal of this strategy is to decrease the diff --git a/src/main/java/io/kurrent/dbclient/NoClusterNodeFoundException.java b/src/main/java/io/trogonstack/eventstore/client/NoClusterNodeFoundException.java similarity index 81% rename from src/main/java/io/kurrent/dbclient/NoClusterNodeFoundException.java rename to src/main/java/io/trogonstack/eventstore/client/NoClusterNodeFoundException.java index 8feaacd..8136929 100644 --- a/src/main/java/io/kurrent/dbclient/NoClusterNodeFoundException.java +++ b/src/main/java/io/trogonstack/eventstore/client/NoClusterNodeFoundException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * When no node was found based on the connection string provided. diff --git a/src/main/java/io/kurrent/dbclient/NodePreference.java b/src/main/java/io/trogonstack/eventstore/client/NodePreference.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/NodePreference.java rename to src/main/java/io/trogonstack/eventstore/client/NodePreference.java index 293f7ae..30ba3fc 100644 --- a/src/main/java/io/kurrent/dbclient/NodePreference.java +++ b/src/main/java/io/trogonstack/eventstore/client/NodePreference.java @@ -1,5 +1,5 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Indicates which order of preferred nodes for connecting to. diff --git a/src/main/java/io/kurrent/dbclient/NodeSelector.java b/src/main/java/io/trogonstack/eventstore/client/NodeSelector.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/NodeSelector.java rename to src/main/java/io/trogonstack/eventstore/client/NodeSelector.java index 8eb1677..977e4fa 100644 --- a/src/main/java/io/kurrent/dbclient/NodeSelector.java +++ b/src/main/java/io/trogonstack/eventstore/client/NodeSelector.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.*; diff --git a/src/main/java/io/kurrent/dbclient/NotLeaderException.java b/src/main/java/io/trogonstack/eventstore/client/NotLeaderException.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/NotLeaderException.java rename to src/main/java/io/trogonstack/eventstore/client/NotLeaderException.java index 0e52a38..232afcf 100644 --- a/src/main/java/io/kurrent/dbclient/NotLeaderException.java +++ b/src/main/java/io/trogonstack/eventstore/client/NotLeaderException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.net.InetSocketAddress; diff --git a/src/main/java/io/kurrent/dbclient/OperationKind.java b/src/main/java/io/trogonstack/eventstore/client/OperationKind.java similarity index 55% rename from src/main/java/io/kurrent/dbclient/OperationKind.java rename to src/main/java/io/trogonstack/eventstore/client/OperationKind.java index 27aa2a4..e559833 100644 --- a/src/main/java/io/kurrent/dbclient/OperationKind.java +++ b/src/main/java/io/trogonstack/eventstore/client/OperationKind.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; enum OperationKind { Regular, diff --git a/src/main/java/io/kurrent/dbclient/OptionsBase.java b/src/main/java/io/trogonstack/eventstore/client/OptionsBase.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/OptionsBase.java rename to src/main/java/io/trogonstack/eventstore/client/OptionsBase.java index f7199a8..cff8e75 100644 --- a/src/main/java/io/kurrent/dbclient/OptionsBase.java +++ b/src/main/java/io/trogonstack/eventstore/client/OptionsBase.java @@ -1,118 +1,118 @@ -package io.kurrent.dbclient; - -import java.util.HashMap; -import java.util.Map; - -class OptionsBase { - private Long deadline; - private final OperationKind kind; - private UserCredentials credentials; - private boolean requiresLeader; - private Map headers = new HashMap<>(); - - protected OptionsBase() { - this(OperationKind.Regular); - } - - protected OptionsBase(OperationKind kind) { - this.kind = kind; - } - - boolean hasUserCredentials() { - return this.credentials != null; - } - - String getHttpCredentialString() { - return this.credentials.basicAuthHeader(); - } - - /** - * Sets user credentials for the request - * @param credentials - * @see UserCredentials - * @return updated options - */ - @SuppressWarnings("unchecked") - public T authenticated(UserCredentials credentials) { - this.credentials = credentials; - return (T) this; - } - - /** - * Sets user credentials for the request - * @param login - * @param password - * @return updated options - */ - public T authenticated(String login, String password) { - return authenticated(new UserCredentials(login, password)); - } - - /** - * Requires the request to be performed by the leader of the cluster. - * @return updated options - */ - public T requiresLeader() { - return requiresLeader(true); - } - - /** - * Do not require the request to be performed by the leader of the cluster. - * @return updated options - */ - public T notRequireLeader() { - return requiresLeader(false); - } - - /** - * If true, requires the request to be performed by the leader of the cluster. - * @param value - * @return updated options - */ - @SuppressWarnings("unchecked") - public T requiresLeader(boolean value) { - this.requiresLeader = value; - return (T) this; - } - - /** - * A length of time (in milliseconds) to use for gRPC deadlines. - * @param durationInMs - * @return - */ - @SuppressWarnings("unchecked") - public T deadline(long durationInMs) { - deadline = durationInMs; - - return (T)this; - } - - /** - * Adds a custom HTTP header that will be added to the request. - */ - @SuppressWarnings("unchecked") - public T header(String key, String value) { - headers.put(key, value); - return (T)this; - } - - Long getDeadline() { - return deadline; - } - - OperationKind getKind() { - return kind; - } - - boolean isLeaderRequired() { - return this.requiresLeader; - } - - UserCredentials getCredentials() { - return this.credentials; - } - - Map getHeaders() { - return this.headers; - } +package io.trogonstack.eventstore.client; + +import java.util.HashMap; +import java.util.Map; + +class OptionsBase { + private Long deadline; + private final OperationKind kind; + private UserCredentials credentials; + private boolean requiresLeader; + private Map headers = new HashMap<>(); + + protected OptionsBase() { + this(OperationKind.Regular); + } + + protected OptionsBase(OperationKind kind) { + this.kind = kind; + } + + boolean hasUserCredentials() { + return this.credentials != null; + } + + String getHttpCredentialString() { + return this.credentials.basicAuthHeader(); + } + + /** + * Sets user credentials for the request + * @param credentials + * @see UserCredentials + * @return updated options + */ + @SuppressWarnings("unchecked") + public T authenticated(UserCredentials credentials) { + this.credentials = credentials; + return (T) this; + } + + /** + * Sets user credentials for the request + * @param login + * @param password + * @return updated options + */ + public T authenticated(String login, String password) { + return authenticated(new UserCredentials(login, password)); + } + + /** + * Requires the request to be performed by the leader of the cluster. + * @return updated options + */ + public T requiresLeader() { + return requiresLeader(true); + } + + /** + * Do not require the request to be performed by the leader of the cluster. + * @return updated options + */ + public T notRequireLeader() { + return requiresLeader(false); + } + + /** + * If true, requires the request to be performed by the leader of the cluster. + * @param value + * @return updated options + */ + @SuppressWarnings("unchecked") + public T requiresLeader(boolean value) { + this.requiresLeader = value; + return (T) this; + } + + /** + * A length of time (in milliseconds) to use for gRPC deadlines. + * @param durationInMs + * @return + */ + @SuppressWarnings("unchecked") + public T deadline(long durationInMs) { + deadline = durationInMs; + + return (T)this; + } + + /** + * Adds a custom HTTP header that will be added to the request. + */ + @SuppressWarnings("unchecked") + public T header(String key, String value) { + headers.put(key, value); + return (T)this; + } + + Long getDeadline() { + return deadline; + } + + OperationKind getKind() { + return kind; + } + + boolean isLeaderRequired() { + return this.requiresLeader; + } + + UserCredentials getCredentials() { + return this.credentials; + } + + Map getHeaders() { + return this.headers; + } } \ No newline at end of file diff --git a/src/main/java/io/kurrent/dbclient/OptionsWithBackPressure.java b/src/main/java/io/trogonstack/eventstore/client/OptionsWithBackPressure.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/OptionsWithBackPressure.java rename to src/main/java/io/trogonstack/eventstore/client/OptionsWithBackPressure.java index 5a8369a..961ac13 100644 --- a/src/main/java/io/kurrent/dbclient/OptionsWithBackPressure.java +++ b/src/main/java/io/trogonstack/eventstore/client/OptionsWithBackPressure.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class OptionsWithBackPressure extends OptionsWithResolveLinkTosBase { private int batchSize; diff --git a/src/main/java/io/kurrent/dbclient/OptionsWithPositionAndResolveLinkTosBase.java b/src/main/java/io/trogonstack/eventstore/client/OptionsWithPositionAndResolveLinkTosBase.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/OptionsWithPositionAndResolveLinkTosBase.java rename to src/main/java/io/trogonstack/eventstore/client/OptionsWithPositionAndResolveLinkTosBase.java index 543126a..9a3d4b6 100644 --- a/src/main/java/io/kurrent/dbclient/OptionsWithPositionAndResolveLinkTosBase.java +++ b/src/main/java/io/trogonstack/eventstore/client/OptionsWithPositionAndResolveLinkTosBase.java @@ -1,46 +1,46 @@ -package io.kurrent.dbclient; - -class OptionsWithPositionAndResolveLinkTosBase extends OptionsWithBackPressure { - private StreamPosition position; - - protected OptionsWithPositionAndResolveLinkTosBase(OperationKind kind) { - super(kind); - this.position = StreamPosition.start(); - } - - protected OptionsWithPositionAndResolveLinkTosBase() { - this(OperationKind.Regular); - } - - StreamPosition getPosition() { - return position; - } - - /** - * Starts from the beginning of the $all stream. - */ - @SuppressWarnings("unchecked") - public T fromStart() { - this.position = StreamPosition.start(); - return (T)this; - } - - /** - * Starts from the end of the $all stream. - */ - @SuppressWarnings("unchecked") - public T fromEnd() { - this.position = StreamPosition.end(); - return (T)this; - } - - /** - * Starts from the given transaction log position. - * @param position transaction log position. - */ - @SuppressWarnings("unchecked") - public T fromPosition(Position position) { - this.position = StreamPosition.position(position); - return (T)this; - } -} +package io.trogonstack.eventstore.client; + +class OptionsWithPositionAndResolveLinkTosBase extends OptionsWithBackPressure { + private StreamPosition position; + + protected OptionsWithPositionAndResolveLinkTosBase(OperationKind kind) { + super(kind); + this.position = StreamPosition.start(); + } + + protected OptionsWithPositionAndResolveLinkTosBase() { + this(OperationKind.Regular); + } + + StreamPosition getPosition() { + return position; + } + + /** + * Starts from the beginning of the $all stream. + */ + @SuppressWarnings("unchecked") + public T fromStart() { + this.position = StreamPosition.start(); + return (T)this; + } + + /** + * Starts from the end of the $all stream. + */ + @SuppressWarnings("unchecked") + public T fromEnd() { + this.position = StreamPosition.end(); + return (T)this; + } + + /** + * Starts from the given transaction log position. + * @param position transaction log position. + */ + @SuppressWarnings("unchecked") + public T fromPosition(Position position) { + this.position = StreamPosition.position(position); + return (T)this; + } +} diff --git a/src/main/java/io/kurrent/dbclient/OptionsWithResolveLinkTosBase.java b/src/main/java/io/trogonstack/eventstore/client/OptionsWithResolveLinkTosBase.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/OptionsWithResolveLinkTosBase.java rename to src/main/java/io/trogonstack/eventstore/client/OptionsWithResolveLinkTosBase.java index ce10487..6d3552a 100644 --- a/src/main/java/io/kurrent/dbclient/OptionsWithResolveLinkTosBase.java +++ b/src/main/java/io/trogonstack/eventstore/client/OptionsWithResolveLinkTosBase.java @@ -1,41 +1,41 @@ -package io.kurrent.dbclient; - -class OptionsWithResolveLinkTosBase extends OptionsBase { - private boolean resolveLinkTos; - - protected OptionsWithResolveLinkTosBase(OperationKind kind) { - super(kind); - this.resolveLinkTos = false; - } - - protected OptionsWithResolveLinkTosBase() { - this(OperationKind.Regular); - } - - boolean shouldResolveLinkTos() { - return this.resolveLinkTos; - } - - /** - * Whether the subscription should resolve linkTo events to their linked events. Default: false. - */ - @SuppressWarnings("unchecked") - public T resolveLinkTos(boolean value) { - this.resolveLinkTos = value; - return (T)this; - } - - /** - * Resolve linkTo events to their linked events. - */ - public T resolveLinkTos() { - return this.resolveLinkTos(true); - } - - /** - * Don't resolve linkTo events to their linked events. - */ - public T notResolveLinkTos() { - return this.resolveLinkTos(false); - } -} +package io.trogonstack.eventstore.client; + +class OptionsWithResolveLinkTosBase extends OptionsBase { + private boolean resolveLinkTos; + + protected OptionsWithResolveLinkTosBase(OperationKind kind) { + super(kind); + this.resolveLinkTos = false; + } + + protected OptionsWithResolveLinkTosBase() { + this(OperationKind.Regular); + } + + boolean shouldResolveLinkTos() { + return this.resolveLinkTos; + } + + /** + * Whether the subscription should resolve linkTo events to their linked events. Default: false. + */ + @SuppressWarnings("unchecked") + public T resolveLinkTos(boolean value) { + this.resolveLinkTos = value; + return (T)this; + } + + /** + * Resolve linkTo events to their linked events. + */ + public T resolveLinkTos() { + return this.resolveLinkTos(true); + } + + /** + * Don't resolve linkTo events to their linked events. + */ + public T notResolveLinkTos() { + return this.resolveLinkTos(false); + } +} diff --git a/src/main/java/io/kurrent/dbclient/OptionsWithStartRevisionAndResolveLinkTosBase.java b/src/main/java/io/trogonstack/eventstore/client/OptionsWithStartRevisionAndResolveLinkTosBase.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/OptionsWithStartRevisionAndResolveLinkTosBase.java rename to src/main/java/io/trogonstack/eventstore/client/OptionsWithStartRevisionAndResolveLinkTosBase.java index 9b97897..af3f5c1 100644 --- a/src/main/java/io/kurrent/dbclient/OptionsWithStartRevisionAndResolveLinkTosBase.java +++ b/src/main/java/io/trogonstack/eventstore/client/OptionsWithStartRevisionAndResolveLinkTosBase.java @@ -1,48 +1,48 @@ -package io.kurrent.dbclient; - -class OptionsWithStartRevisionAndResolveLinkTosBase extends OptionsWithBackPressure { - private StreamPosition startRevision; - - protected OptionsWithStartRevisionAndResolveLinkTosBase(OperationKind kind) { - super(kind); - this.startRevision = StreamPosition.start(); - } - - protected OptionsWithStartRevisionAndResolveLinkTosBase() { - this(OperationKind.Regular); - } - - StreamPosition getStartingRevision() { - return this.startRevision; - } - - /** - * Starts from a stream position. - */ - @SuppressWarnings("unchecked") - public T fromRevision(StreamPosition startRevision) { - this.startRevision = startRevision; - return (T)this; - } - - /** - * Starts from the beginning of the stream. - */ - public T fromStart() { - return this.fromRevision(StreamPosition.start()); - } - - /** - * Starts from the end of the stream. - */ - public T fromEnd() { - return this.fromRevision(StreamPosition.end()); - } - - /** - * Starts from the given event revision. - */ - public T fromRevision(long revision) { - return this.fromRevision(StreamPosition.position(revision)); - } -} +package io.trogonstack.eventstore.client; + +class OptionsWithStartRevisionAndResolveLinkTosBase extends OptionsWithBackPressure { + private StreamPosition startRevision; + + protected OptionsWithStartRevisionAndResolveLinkTosBase(OperationKind kind) { + super(kind); + this.startRevision = StreamPosition.start(); + } + + protected OptionsWithStartRevisionAndResolveLinkTosBase() { + this(OperationKind.Regular); + } + + StreamPosition getStartingRevision() { + return this.startRevision; + } + + /** + * Starts from a stream position. + */ + @SuppressWarnings("unchecked") + public T fromRevision(StreamPosition startRevision) { + this.startRevision = startRevision; + return (T)this; + } + + /** + * Starts from the beginning of the stream. + */ + public T fromStart() { + return this.fromRevision(StreamPosition.start()); + } + + /** + * Starts from the end of the stream. + */ + public T fromEnd() { + return this.fromRevision(StreamPosition.end()); + } + + /** + * Starts from the given event revision. + */ + public T fromRevision(long revision) { + return this.fromRevision(StreamPosition.position(revision)); + } +} diff --git a/src/main/java/io/kurrent/dbclient/OptionsWithStreamStateBase.java b/src/main/java/io/trogonstack/eventstore/client/OptionsWithStreamStateBase.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/OptionsWithStreamStateBase.java rename to src/main/java/io/trogonstack/eventstore/client/OptionsWithStreamStateBase.java index 48eef35..3b6b852 100644 --- a/src/main/java/io/kurrent/dbclient/OptionsWithStreamStateBase.java +++ b/src/main/java/io/trogonstack/eventstore/client/OptionsWithStreamStateBase.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class OptionsWithStreamStateBase extends OptionsBase { private StreamState streamState; diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscription.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscription.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/PersistentSubscription.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscription.java index 3fdb012..6fde324 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscription.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscription.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; import com.google.protobuf.ByteString; import io.grpc.stub.ClientCallStreamObserver; diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionConnectionInfo.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionConnectionInfo.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionConnectionInfo.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionConnectionInfo.java index d041ccd..e7eeb5f 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionConnectionInfo.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionConnectionInfo.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Map; diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionInfo.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionInfo.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionInfo.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionInfo.java index 0872c3a..d9cffe8 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionInfo.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionInfo.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.List; diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionListener.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionListener.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionListener.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionListener.java index e779568..f884f8e 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionListener.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionListener.java @@ -1,11 +1,11 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Listener used to handle persistent subscription notifications raised throughout its lifecycle. */ public abstract class PersistentSubscriptionListener { /** - * Called when KurrentDB sends an event to the persistent subscription. + * Called when TrogonEventStore sends an event to the persistent subscription. * @param subscription handle to the persistent subscription. * @param retryCount how many times the event was retried. * @param event a resolved event. diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionSettings.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionSettings.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionSettings.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionSettings.java index 8aff429..6a3b738 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionSettings.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionSettings.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.time.Duration; @@ -96,7 +96,7 @@ public boolean isExtraStatistics() { * * The best way to explain link resolution is when using system projections. When reading the stream $streams * , each event is actually a link pointing to the first event of a stream. By enabling link resolution feature, - * KurrentDB will also return the event targeted by the link. + * TrogonEventStore will also return the event targeted by the link. */ public boolean shouldResolveLinkTos() { return resolveLinkTos; @@ -191,7 +191,7 @@ void setExtraStatistics(boolean extraStatistics) { * * The best way to explain link resolution is when using system projections. When reading the stream $streams * , each event is actually a link pointing to the first event of a stream. By enabling link resolution feature, - * KurrentDB will also return the event targeted by the link. + * TrogonEventStore will also return the event targeted by the link. */ public boolean isResolveLinkTos() { return resolveLinkTos; @@ -202,7 +202,7 @@ public boolean isResolveLinkTos() { * * The best way to explain link resolution is when using system projections. When reading the stream $streams * , each event is actually a link pointing to the first event of a stream. By enabling link resolution feature, - * KurrentDB will also return the event targeted by the link. + * TrogonEventStore will also return the event targeted by the link. */ void setResolveLinkTos(boolean resolveLinkTos) { this.resolveLinkTos = resolveLinkTos; diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionStats.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionStats.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionStats.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionStats.java index 3785ac2..c650891 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionStats.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionStats.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Processing-related persistent subscription statistics. diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllInfo.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllInfo.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllInfo.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllInfo.java index a8e14c6..160ddee 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllInfo.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllInfo.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Persistent subscription to $all info. diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllSettings.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllSettings.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllSettings.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllSettings.java index 4c453cd..c2a524d 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllSettings.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllSettings.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Persistent subscription to $all settings. diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllStats.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllStats.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllStats.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllStats.java index 3da383f..44894f7 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToAllStats.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToAllStats.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Optional; diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamInfo.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamInfo.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamInfo.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamInfo.java index ccf2ba5..0907652 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamInfo.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamInfo.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Persistent subscription to stream info. diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamSettings.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamSettings.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamSettings.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamSettings.java index 7960b4e..205b62d 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamSettings.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamSettings.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Persistent subscription to stream settings. diff --git a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamStats.java b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamStats.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamStats.java rename to src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamStats.java index d16f69a..3b686b5 100644 --- a/src/main/java/io/kurrent/dbclient/PersistentSubscriptionToStreamStats.java +++ b/src/main/java/io/trogonstack/eventstore/client/PersistentSubscriptionToStreamStats.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Optional; diff --git a/src/main/java/io/kurrent/dbclient/Position.java b/src/main/java/io/trogonstack/eventstore/client/Position.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/Position.java rename to src/main/java/io/trogonstack/eventstore/client/Position.java index cb290c9..1191415 100644 --- a/src/main/java/io/kurrent/dbclient/Position.java +++ b/src/main/java/io/trogonstack/eventstore/client/Position.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import javax.validation.constraints.NotNull; diff --git a/src/main/java/io/kurrent/dbclient/PrefixFilterExpression.java b/src/main/java/io/trogonstack/eventstore/client/PrefixFilterExpression.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/PrefixFilterExpression.java rename to src/main/java/io/trogonstack/eventstore/client/PrefixFilterExpression.java index 5873020..2b1610a 100644 --- a/src/main/java/io/kurrent/dbclient/PrefixFilterExpression.java +++ b/src/main/java/io/trogonstack/eventstore/client/PrefixFilterExpression.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import javax.validation.constraints.NotNull; import java.util.Objects; diff --git a/src/main/java/io/kurrent/dbclient/ProjectionDetails.java b/src/main/java/io/trogonstack/eventstore/client/ProjectionDetails.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/ProjectionDetails.java rename to src/main/java/io/trogonstack/eventstore/client/ProjectionDetails.java index 53f2613..9c5f6da 100644 --- a/src/main/java/io/kurrent/dbclient/ProjectionDetails.java +++ b/src/main/java/io/trogonstack/eventstore/client/ProjectionDetails.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; /** * Provides the details for a projection. diff --git a/src/main/java/io/kurrent/dbclient/ReadAll.java b/src/main/java/io/trogonstack/eventstore/client/ReadAll.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/ReadAll.java rename to src/main/java/io/trogonstack/eventstore/client/ReadAll.java index 252fc07..640909b 100644 --- a/src/main/java/io/kurrent/dbclient/ReadAll.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadAll.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; class ReadAll extends AbstractRead { private final ReadAllOptions options; diff --git a/src/main/java/io/kurrent/dbclient/ReadAllOptions.java b/src/main/java/io/trogonstack/eventstore/client/ReadAllOptions.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/ReadAllOptions.java rename to src/main/java/io/trogonstack/eventstore/client/ReadAllOptions.java index 4d06a94..08f18b6 100644 --- a/src/main/java/io/kurrent/dbclient/ReadAllOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadAllOptions.java @@ -1,59 +1,59 @@ -package io.kurrent.dbclient; - -/** - * Options of the read $all stream request. - */ -public class ReadAllOptions extends OptionsWithPositionAndResolveLinkTosBase { - private Direction direction; - private long maxCount; - - private ReadAllOptions() { - this.direction = Direction.Forwards; - this.maxCount = Long.MAX_VALUE; - } - - /** - * Returns options with default values. - */ - public static ReadAllOptions get() { - return new ReadAllOptions(); - } - - Direction getDirection() { - return this.direction; - } - - long getMaxCount() { - return this.maxCount; - } - - /** - * Reads stream in the given direction. - */ - public ReadAllOptions direction(Direction direction) { - this.direction = direction; - return this; - } - - /** - * Reads stream in revision-ascending order. - */ - public ReadAllOptions forwards() { - return direction(Direction.Forwards); - } - - /** - * Reads stream in revision-descending order. - */ - public ReadAllOptions backwards() { - return direction(Direction.Backwards); - } - - /** - * The maximum event count KurrentDB will return. - */ - public ReadAllOptions maxCount(long maxCount) { - this.maxCount = maxCount; - return this; - } -} +package io.trogonstack.eventstore.client; + +/** + * Options of the read $all stream request. + */ +public class ReadAllOptions extends OptionsWithPositionAndResolveLinkTosBase { + private Direction direction; + private long maxCount; + + private ReadAllOptions() { + this.direction = Direction.Forwards; + this.maxCount = Long.MAX_VALUE; + } + + /** + * Returns options with default values. + */ + public static ReadAllOptions get() { + return new ReadAllOptions(); + } + + Direction getDirection() { + return this.direction; + } + + long getMaxCount() { + return this.maxCount; + } + + /** + * Reads stream in the given direction. + */ + public ReadAllOptions direction(Direction direction) { + this.direction = direction; + return this; + } + + /** + * Reads stream in revision-ascending order. + */ + public ReadAllOptions forwards() { + return direction(Direction.Forwards); + } + + /** + * Reads stream in revision-descending order. + */ + public ReadAllOptions backwards() { + return direction(Direction.Backwards); + } + + /** + * The maximum event count TrogonEventStore will return. + */ + public ReadAllOptions maxCount(long maxCount) { + this.maxCount = maxCount; + return this; + } +} diff --git a/src/main/java/io/kurrent/dbclient/ReadMessage.java b/src/main/java/io/trogonstack/eventstore/client/ReadMessage.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/ReadMessage.java rename to src/main/java/io/trogonstack/eventstore/client/ReadMessage.java index 04aad9d..c72a7d7 100644 --- a/src/main/java/io/kurrent/dbclient/ReadMessage.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadMessage.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; /** * Received when performing a regular read operation (not a subscription). diff --git a/src/main/java/io/kurrent/dbclient/ReadResponseObserver.java b/src/main/java/io/trogonstack/eventstore/client/ReadResponseObserver.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/ReadResponseObserver.java rename to src/main/java/io/trogonstack/eventstore/client/ReadResponseObserver.java index 328c896..5e63a90 100644 --- a/src/main/java/io/kurrent/dbclient/ReadResponseObserver.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadResponseObserver.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import io.grpc.Metadata; import io.grpc.Status; import io.grpc.StatusRuntimeException; diff --git a/src/main/java/io/kurrent/dbclient/ReadResult.java b/src/main/java/io/trogonstack/eventstore/client/ReadResult.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/ReadResult.java rename to src/main/java/io/trogonstack/eventstore/client/ReadResult.java index 7e92839..e99ecdc 100644 --- a/src/main/java/io/kurrent/dbclient/ReadResult.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadResult.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.List; diff --git a/src/main/java/io/kurrent/dbclient/ReadStream.java b/src/main/java/io/trogonstack/eventstore/client/ReadStream.java similarity index 86% rename from src/main/java/io/kurrent/dbclient/ReadStream.java rename to src/main/java/io/trogonstack/eventstore/client/ReadStream.java index 37f208d..e00443f 100644 --- a/src/main/java/io/kurrent/dbclient/ReadStream.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadStream.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; class ReadStream extends AbstractRead { private final String streamName; diff --git a/src/main/java/io/kurrent/dbclient/ReadStreamConsumer.java b/src/main/java/io/trogonstack/eventstore/client/ReadStreamConsumer.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/ReadStreamConsumer.java rename to src/main/java/io/trogonstack/eventstore/client/ReadStreamConsumer.java index a4c30aa..285294c 100644 --- a/src/main/java/io/kurrent/dbclient/ReadStreamConsumer.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadStreamConsumer.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import org.reactivestreams.Subscriber; diff --git a/src/main/java/io/kurrent/dbclient/ReadStreamOptions.java b/src/main/java/io/trogonstack/eventstore/client/ReadStreamOptions.java similarity index 89% rename from src/main/java/io/kurrent/dbclient/ReadStreamOptions.java rename to src/main/java/io/trogonstack/eventstore/client/ReadStreamOptions.java index 6856360..b687a65 100644 --- a/src/main/java/io/kurrent/dbclient/ReadStreamOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadStreamOptions.java @@ -1,62 +1,62 @@ -package io.kurrent.dbclient; - -/** - * Options of the read stream request. - */ -public class ReadStreamOptions extends OptionsWithStartRevisionAndResolveLinkTosBase { - private Direction direction; - private long maxCount; - - private ReadStreamOptions() { - this.direction = Direction.Forwards; - this.maxCount = Long.MAX_VALUE; - } - - /** - * Returns options with default values. - */ - public static ReadStreamOptions get() { - return new ReadStreamOptions(); - } - - Direction getDirection() { - return this.direction; - } - - long getMaxCount() { - return this.maxCount; - } - - /** - * Reads stream in the given direction. - - */ - public ReadStreamOptions direction(Direction direction) { - this.direction = direction; - return this; - } - - /** - * Reads stream in revision-ascending order. - - */ - public ReadStreamOptions forwards() { - return direction(Direction.Forwards); - } - - /** - * Reads stream in revision-descending order. - - */ - public ReadStreamOptions backwards() { - return direction(Direction.Backwards); - } - - /** - * The maximum event count EventStoreDB will return. - */ - public ReadStreamOptions maxCount(long maxCount) { - this.maxCount = maxCount; - return this; - } -} +package io.trogonstack.eventstore.client; + +/** + * Options of the read stream request. + */ +public class ReadStreamOptions extends OptionsWithStartRevisionAndResolveLinkTosBase { + private Direction direction; + private long maxCount; + + private ReadStreamOptions() { + this.direction = Direction.Forwards; + this.maxCount = Long.MAX_VALUE; + } + + /** + * Returns options with default values. + */ + public static ReadStreamOptions get() { + return new ReadStreamOptions(); + } + + Direction getDirection() { + return this.direction; + } + + long getMaxCount() { + return this.maxCount; + } + + /** + * Reads stream in the given direction. + + */ + public ReadStreamOptions direction(Direction direction) { + this.direction = direction; + return this; + } + + /** + * Reads stream in revision-ascending order. + + */ + public ReadStreamOptions forwards() { + return direction(Direction.Forwards); + } + + /** + * Reads stream in revision-descending order. + + */ + public ReadStreamOptions backwards() { + return direction(Direction.Backwards); + } + + /** + * The maximum event count TrogonEventStore will return. + */ + public ReadStreamOptions maxCount(long maxCount) { + this.maxCount = maxCount; + return this; + } +} diff --git a/src/main/java/io/kurrent/dbclient/ReadSubscriber.java b/src/main/java/io/trogonstack/eventstore/client/ReadSubscriber.java similarity index 92% rename from src/main/java/io/kurrent/dbclient/ReadSubscriber.java rename to src/main/java/io/trogonstack/eventstore/client/ReadSubscriber.java index ba031ab..8a2e751 100644 --- a/src/main/java/io/kurrent/dbclient/ReadSubscriber.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReadSubscriber.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; diff --git a/src/main/java/io/kurrent/dbclient/RecordedEvent.java b/src/main/java/io/trogonstack/eventstore/client/RecordedEvent.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/RecordedEvent.java rename to src/main/java/io/trogonstack/eventstore/client/RecordedEvent.java index d46a8df..3f6c9a4 100644 --- a/src/main/java/io/kurrent/dbclient/RecordedEvent.java +++ b/src/main/java/io/trogonstack/eventstore/client/RecordedEvent.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import com.fasterxml.jackson.databind.json.JsonMapper; import javax.validation.constraints.NotNull; diff --git a/src/main/java/io/kurrent/dbclient/RegularFilterExpression.java b/src/main/java/io/trogonstack/eventstore/client/RegularFilterExpression.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/RegularFilterExpression.java rename to src/main/java/io/trogonstack/eventstore/client/RegularFilterExpression.java index c766676..88ec750 100644 --- a/src/main/java/io/kurrent/dbclient/RegularFilterExpression.java +++ b/src/main/java/io/trogonstack/eventstore/client/RegularFilterExpression.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import javax.validation.constraints.NotNull; import java.util.Objects; diff --git a/src/main/java/io/kurrent/dbclient/ReplayParkedMessages.java b/src/main/java/io/trogonstack/eventstore/client/ReplayParkedMessages.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/ReplayParkedMessages.java rename to src/main/java/io/trogonstack/eventstore/client/ReplayParkedMessages.java index f74aeb7..c2defe0 100644 --- a/src/main/java/io/kurrent/dbclient/ReplayParkedMessages.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReplayParkedMessages.java @@ -1,15 +1,15 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; +import io.trogonstack.eventstore.client.proto.shared.Shared; import com.google.protobuf.ByteString; import java.io.IOException; import java.net.HttpURLConnection; import java.util.concurrent.CompletableFuture; -import static io.kurrent.dbclient.HttpUtils.*; +import static io.trogonstack.eventstore.client.HttpUtils.*; final class ReplayParkedMessages { @SuppressWarnings("unchecked") diff --git a/src/main/java/io/kurrent/dbclient/ReplayParkedMessagesOptions.java b/src/main/java/io/trogonstack/eventstore/client/ReplayParkedMessagesOptions.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/ReplayParkedMessagesOptions.java rename to src/main/java/io/trogonstack/eventstore/client/ReplayParkedMessagesOptions.java index f15a9bf..caf037b 100644 --- a/src/main/java/io/kurrent/dbclient/ReplayParkedMessagesOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/ReplayParkedMessagesOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the replay parked messages request. diff --git a/src/main/java/io/kurrent/dbclient/ResetProjection.java b/src/main/java/io/trogonstack/eventstore/client/ResetProjection.java similarity index 86% rename from src/main/java/io/kurrent/dbclient/ResetProjection.java rename to src/main/java/io/trogonstack/eventstore/client/ResetProjection.java index 7d16ce9..c887ee4 100644 --- a/src/main/java/io/kurrent/dbclient/ResetProjection.java +++ b/src/main/java/io/trogonstack/eventstore/client/ResetProjection.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/ResetProjectionOptions.java b/src/main/java/io/trogonstack/eventstore/client/ResetProjectionOptions.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/ResetProjectionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/ResetProjectionOptions.java index 95faece..828d2e1 100644 --- a/src/main/java/io/kurrent/dbclient/ResetProjectionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/ResetProjectionOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the reset projection request. diff --git a/src/main/java/io/kurrent/dbclient/ResolvedEvent.java b/src/main/java/io/trogonstack/eventstore/client/ResolvedEvent.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/ResolvedEvent.java rename to src/main/java/io/trogonstack/eventstore/client/ResolvedEvent.java index 8f5a8e3..d7e8a84 100644 --- a/src/main/java/io/kurrent/dbclient/ResolvedEvent.java +++ b/src/main/java/io/trogonstack/eventstore/client/ResolvedEvent.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import java.util.Objects; import java.util.Optional; diff --git a/src/main/java/io/kurrent/dbclient/ResourceNotFoundException.java b/src/main/java/io/trogonstack/eventstore/client/ResourceNotFoundException.java similarity index 87% rename from src/main/java/io/kurrent/dbclient/ResourceNotFoundException.java rename to src/main/java/io/trogonstack/eventstore/client/ResourceNotFoundException.java index cfa5c44..7711867 100644 --- a/src/main/java/io/kurrent/dbclient/ResourceNotFoundException.java +++ b/src/main/java/io/trogonstack/eventstore/client/ResourceNotFoundException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * A remote resource was not found or because its access was denied. Could only happen when a request was performed diff --git a/src/main/java/io/kurrent/dbclient/RestartPersistentSubscriptionSubsystem.java b/src/main/java/io/trogonstack/eventstore/client/RestartPersistentSubscriptionSubsystem.java similarity index 86% rename from src/main/java/io/kurrent/dbclient/RestartPersistentSubscriptionSubsystem.java rename to src/main/java/io/trogonstack/eventstore/client/RestartPersistentSubscriptionSubsystem.java index 1a2588a..002f69d 100644 --- a/src/main/java/io/kurrent/dbclient/RestartPersistentSubscriptionSubsystem.java +++ b/src/main/java/io/trogonstack/eventstore/client/RestartPersistentSubscriptionSubsystem.java @@ -1,13 +1,13 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.PersistentSubscriptionsGrpc; +import io.trogonstack.eventstore.client.proto.shared.Shared; import java.io.IOException; import java.net.HttpURLConnection; import java.util.concurrent.CompletableFuture; -import static io.kurrent.dbclient.HttpUtils.checkForError; +import static io.trogonstack.eventstore.client.HttpUtils.checkForError; class RestartPersistentSubscriptionSubsystem { @SuppressWarnings("unchecked") diff --git a/src/main/java/io/kurrent/dbclient/RestartPersistentSubscriptionSubsystemOptions.java b/src/main/java/io/trogonstack/eventstore/client/RestartPersistentSubscriptionSubsystemOptions.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/RestartPersistentSubscriptionSubsystemOptions.java rename to src/main/java/io/trogonstack/eventstore/client/RestartPersistentSubscriptionSubsystemOptions.java index 59d9da0..06526c6 100644 --- a/src/main/java/io/kurrent/dbclient/RestartPersistentSubscriptionSubsystemOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/RestartPersistentSubscriptionSubsystemOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the restart persistent subscription subsystem request. diff --git a/src/main/java/io/kurrent/dbclient/RestartProjectionSubsystem.java b/src/main/java/io/trogonstack/eventstore/client/RestartProjectionSubsystem.java similarity index 83% rename from src/main/java/io/kurrent/dbclient/RestartProjectionSubsystem.java rename to src/main/java/io/trogonstack/eventstore/client/RestartProjectionSubsystem.java index 41d2081..a72a792 100644 --- a/src/main/java/io/kurrent/dbclient/RestartProjectionSubsystem.java +++ b/src/main/java/io/trogonstack/eventstore/client/RestartProjectionSubsystem.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.shared.Shared; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/RestartProjectionSubsystemOptions.java b/src/main/java/io/trogonstack/eventstore/client/RestartProjectionSubsystemOptions.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/RestartProjectionSubsystemOptions.java rename to src/main/java/io/trogonstack/eventstore/client/RestartProjectionSubsystemOptions.java index b81d592..d4c8edc 100644 --- a/src/main/java/io/kurrent/dbclient/RestartProjectionSubsystemOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/RestartProjectionSubsystemOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the restart projection subsystem request. diff --git a/src/main/java/io/kurrent/dbclient/RevisionOrPosition.java b/src/main/java/io/trogonstack/eventstore/client/RevisionOrPosition.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/RevisionOrPosition.java rename to src/main/java/io/trogonstack/eventstore/client/RevisionOrPosition.java index bb4cb22..bcd7645 100644 --- a/src/main/java/io/kurrent/dbclient/RevisionOrPosition.java +++ b/src/main/java/io/trogonstack/eventstore/client/RevisionOrPosition.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Optional; diff --git a/src/main/java/io/kurrent/dbclient/RunWorkItem.java b/src/main/java/io/trogonstack/eventstore/client/RunWorkItem.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/RunWorkItem.java rename to src/main/java/io/trogonstack/eventstore/client/RunWorkItem.java index a3970bb..98cd32e 100644 --- a/src/main/java/io/kurrent/dbclient/RunWorkItem.java +++ b/src/main/java/io/trogonstack/eventstore/client/RunWorkItem.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.UUID; diff --git a/src/main/java/io/kurrent/dbclient/ServerFeatures.java b/src/main/java/io/trogonstack/eventstore/client/ServerFeatures.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/ServerFeatures.java rename to src/main/java/io/trogonstack/eventstore/client/ServerFeatures.java index 55aa40b..482d100 100644 --- a/src/main/java/io/kurrent/dbclient/ServerFeatures.java +++ b/src/main/java/io/trogonstack/eventstore/client/ServerFeatures.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.serverfeatures.ServerFeaturesGrpc; -import io.kurrent.dbclient.proto.serverfeatures.Serverfeatures; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.serverfeatures.ServerFeaturesGrpc; +import io.trogonstack.eventstore.client.proto.serverfeatures.Serverfeatures; +import io.trogonstack.eventstore.client.proto.shared.Shared; import io.grpc.ManagedChannel; import io.grpc.Status; import io.grpc.StatusRuntimeException; @@ -17,7 +17,7 @@ import java.util.function.Function; class ServerFeatures { - public static Optional getSupportedFeatures(KurrentDBClientSettings settings, ManagedChannel channel) { + public static Optional getSupportedFeatures(TrogonEventStoreClientSettings settings, ManagedChannel channel) { final ServerFeaturesGrpc.ServerFeaturesStub stub = ServerFeaturesGrpc.newStub(channel); try { return Optional.ofNullable(getSupportedFeaturesInternal(stub).get(settings.getGossipTimeout(), TimeUnit.MILLISECONDS)); @@ -95,10 +95,6 @@ private static CompletableFuture getSupportedFeaturesInternal(Server default: break; } - } else if (method.getMethodName().equals("appendsession")) { - features |= FeatureFlags.MULTI_STREAM_APPEND; - } else if (method.getMethodName().equals("appendrecords") && method.getServiceName().equals("kurrentdb.protocol.v2.streams.streamsservice")) { - features |= FeatureFlags.APPEND_RECORDS; } } @@ -141,4 +137,4 @@ public RetryableException(Throwable cause) { super(cause); } } -} \ No newline at end of file +} diff --git a/src/main/java/io/kurrent/dbclient/ServerInfo.java b/src/main/java/io/trogonstack/eventstore/client/ServerInfo.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/ServerInfo.java rename to src/main/java/io/trogonstack/eventstore/client/ServerInfo.java index a5a7260..ae8d1bb 100644 --- a/src/main/java/io/kurrent/dbclient/ServerInfo.java +++ b/src/main/java/io/trogonstack/eventstore/client/ServerInfo.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class ServerInfo { private final ServerVersion version; diff --git a/src/main/java/io/kurrent/dbclient/ServerVersion.java b/src/main/java/io/trogonstack/eventstore/client/ServerVersion.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/ServerVersion.java rename to src/main/java/io/trogonstack/eventstore/client/ServerVersion.java index 64c16d6..4936a0a 100644 --- a/src/main/java/io/kurrent/dbclient/ServerVersion.java +++ b/src/main/java/io/trogonstack/eventstore/client/ServerVersion.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; public class ServerVersion { private final int major; private final int minor; diff --git a/src/main/java/io/kurrent/dbclient/Shutdown.java b/src/main/java/io/trogonstack/eventstore/client/Shutdown.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/Shutdown.java rename to src/main/java/io/trogonstack/eventstore/client/Shutdown.java index 2422bca..edb140b 100644 --- a/src/main/java/io/kurrent/dbclient/Shutdown.java +++ b/src/main/java/io/trogonstack/eventstore/client/Shutdown.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.function.Consumer; diff --git a/src/main/java/io/kurrent/dbclient/SingleNodeDiscovery.java b/src/main/java/io/trogonstack/eventstore/client/SingleNodeDiscovery.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/SingleNodeDiscovery.java rename to src/main/java/io/trogonstack/eventstore/client/SingleNodeDiscovery.java index 3e28055..c1f991e 100644 --- a/src/main/java/io/kurrent/dbclient/SingleNodeDiscovery.java +++ b/src/main/java/io/trogonstack/eventstore/client/SingleNodeDiscovery.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.net.InetSocketAddress; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/StreamAcl.java b/src/main/java/io/trogonstack/eventstore/client/StreamAcl.java similarity index 99% rename from src/main/java/io/kurrent/dbclient/StreamAcl.java rename to src/main/java/io/trogonstack/eventstore/client/StreamAcl.java index f0642bf..3848101 100644 --- a/src/main/java/io/kurrent/dbclient/StreamAcl.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamAcl.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/io/kurrent/dbclient/StreamConsumer.java b/src/main/java/io/trogonstack/eventstore/client/StreamConsumer.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/StreamConsumer.java rename to src/main/java/io/trogonstack/eventstore/client/StreamConsumer.java index 8bd4c8e..7393576 100644 --- a/src/main/java/io/kurrent/dbclient/StreamConsumer.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamConsumer.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.time.Instant; diff --git a/src/main/java/io/kurrent/dbclient/StreamDeletedException.java b/src/main/java/io/trogonstack/eventstore/client/StreamDeletedException.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/StreamDeletedException.java rename to src/main/java/io/trogonstack/eventstore/client/StreamDeletedException.java index fb978bc..f501916 100644 --- a/src/main/java/io/kurrent/dbclient/StreamDeletedException.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamDeletedException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * When a read or write operation was performed on a deleted stream. diff --git a/src/main/java/io/kurrent/dbclient/StreamFilter.java b/src/main/java/io/trogonstack/eventstore/client/StreamFilter.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/StreamFilter.java rename to src/main/java/io/trogonstack/eventstore/client/StreamFilter.java index 62b4a2e..cb9e8dc 100644 --- a/src/main/java/io/kurrent/dbclient/StreamFilter.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamFilter.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import javax.validation.constraints.NotNull; import java.util.Arrays; diff --git a/src/main/java/io/kurrent/dbclient/StreamMetadata.java b/src/main/java/io/trogonstack/eventstore/client/StreamMetadata.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/StreamMetadata.java rename to src/main/java/io/trogonstack/eventstore/client/StreamMetadata.java index f9b6405..860a0d1 100644 --- a/src/main/java/io/kurrent/dbclient/StreamMetadata.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamMetadata.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; diff --git a/src/main/java/io/kurrent/dbclient/StreamNotFoundException.java b/src/main/java/io/trogonstack/eventstore/client/StreamNotFoundException.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/StreamNotFoundException.java rename to src/main/java/io/trogonstack/eventstore/client/StreamNotFoundException.java index 2a12350..17fa297 100644 --- a/src/main/java/io/kurrent/dbclient/StreamNotFoundException.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamNotFoundException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * When a stream is not found. diff --git a/src/main/java/io/kurrent/dbclient/StreamPosition.java b/src/main/java/io/trogonstack/eventstore/client/StreamPosition.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/StreamPosition.java rename to src/main/java/io/trogonstack/eventstore/client/StreamPosition.java index dfe2e29..86ebd3d 100644 --- a/src/main/java/io/kurrent/dbclient/StreamPosition.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamPosition.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Optional; diff --git a/src/main/java/io/kurrent/dbclient/StreamState.java b/src/main/java/io/trogonstack/eventstore/client/StreamState.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/StreamState.java rename to src/main/java/io/trogonstack/eventstore/client/StreamState.java index 71831b8..d393eb0 100644 --- a/src/main/java/io/kurrent/dbclient/StreamState.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamState.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import java.util.Objects; @@ -9,8 +9,8 @@ * Constants used for expected revision control. *

* - * The KurrentDB server will assure idempotency for all requests using any value in ExpectedRevision except - * ANY. When using ANY, the EventStoreDB server will do its best to assure idempotency but will not + * The TrogonEventStore server will assure idempotency for all requests using any value in ExpectedRevision except + * ANY. When using ANY, TrogonEventStore will do its best to assure idempotency but will not * guarantee it. Any other ExpectedRevision instances are meant for optimistic concurrency checks. *

*/ diff --git a/src/main/java/io/kurrent/dbclient/StreamTombstonedException.java b/src/main/java/io/trogonstack/eventstore/client/StreamTombstonedException.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/StreamTombstonedException.java rename to src/main/java/io/trogonstack/eventstore/client/StreamTombstonedException.java index ecc93e9..0a7b23a 100644 --- a/src/main/java/io/kurrent/dbclient/StreamTombstonedException.java +++ b/src/main/java/io/trogonstack/eventstore/client/StreamTombstonedException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * When a read or write operation was performed on a deleted stream. diff --git a/src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionOptions.java b/src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionOptions.java similarity index 92% rename from src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionOptions.java index 70cfa70..2ecd1de 100644 --- a/src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionOptions.java @@ -1,32 +1,32 @@ -package io.kurrent.dbclient; - -/** - * Options of the subscribe persistent subscription request. - */ -public class SubscribePersistentSubscriptionOptions extends OptionsBase { - private int bufferSize; - - private SubscribePersistentSubscriptionOptions() { - super(OperationKind.Streaming); - this.bufferSize = 10; - } - - /** - * Returns options with default values. - */ - public static SubscribePersistentSubscriptionOptions get() { - return new SubscribePersistentSubscriptionOptions(); - } - - int getBufferSize() { - return bufferSize; - } - - /** - * Persistent subscription's buffer size. - */ - public SubscribePersistentSubscriptionOptions bufferSize(int value) { - bufferSize = value; - return this; - } -} +package io.trogonstack.eventstore.client; + +/** + * Options of the subscribe persistent subscription request. + */ +public class SubscribePersistentSubscriptionOptions extends OptionsBase { + private int bufferSize; + + private SubscribePersistentSubscriptionOptions() { + super(OperationKind.Streaming); + this.bufferSize = 10; + } + + /** + * Returns options with default values. + */ + public static SubscribePersistentSubscriptionOptions get() { + return new SubscribePersistentSubscriptionOptions(); + } + + int getBufferSize() { + return bufferSize; + } + + /** + * Persistent subscription's buffer size. + */ + public SubscribePersistentSubscriptionOptions bufferSize(int value) { + bufferSize = value; + return this; + } +} diff --git a/src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionToAll.java b/src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionToAll.java similarity index 76% rename from src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionToAll.java rename to src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionToAll.java index ba1abbb..160f943 100644 --- a/src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionToAll.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionToAll.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; class SubscribePersistentSubscriptionToAll extends AbstractSubscribePersistentSubscription { public SubscribePersistentSubscriptionToAll(GrpcClient connection, String group, diff --git a/src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionToStream.java b/src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionToStream.java similarity index 83% rename from src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionToStream.java rename to src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionToStream.java index 7be619c..dd92447 100644 --- a/src/main/java/io/kurrent/dbclient/SubscribePersistentSubscriptionToStream.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscribePersistentSubscriptionToStream.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; import com.google.protobuf.ByteString; class SubscribePersistentSubscriptionToStream extends AbstractSubscribePersistentSubscription { diff --git a/src/main/java/io/kurrent/dbclient/SubscribeToAll.java b/src/main/java/io/trogonstack/eventstore/client/SubscribeToAll.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/SubscribeToAll.java rename to src/main/java/io/trogonstack/eventstore/client/SubscribeToAll.java index 684eb14..3b6b0d9 100644 --- a/src/main/java/io/kurrent/dbclient/SubscribeToAll.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscribeToAll.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; class SubscribeToAll extends AbstractRegularSubscription { private final SubscribeToAllOptions options; diff --git a/src/main/java/io/kurrent/dbclient/SubscribeToAllOptions.java b/src/main/java/io/trogonstack/eventstore/client/SubscribeToAllOptions.java similarity index 92% rename from src/main/java/io/kurrent/dbclient/SubscribeToAllOptions.java rename to src/main/java/io/trogonstack/eventstore/client/SubscribeToAllOptions.java index b49d27f..669f43f 100644 --- a/src/main/java/io/kurrent/dbclient/SubscribeToAllOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscribeToAllOptions.java @@ -1,31 +1,31 @@ -package io.kurrent.dbclient; - -/** - * Options of a subscription to $all request. - */ -public class SubscribeToAllOptions extends OptionsWithPositionAndResolveLinkTosBase { - private SubscriptionFilter filter; - - private SubscribeToAllOptions() { - super(OperationKind.Streaming); - } - - /** - * Returns options with default values. - */ - public static SubscribeToAllOptions get() { - return new SubscribeToAllOptions(); - } - - SubscriptionFilter getFilter() { - return filter; - } - - /** - * Applies a server-side filter to determine if an event of the subscription should be yielded. - */ - public SubscribeToAllOptions filter(SubscriptionFilter filter) { - this.filter = filter; - return this; - } -} +package io.trogonstack.eventstore.client; + +/** + * Options of a subscription to $all request. + */ +public class SubscribeToAllOptions extends OptionsWithPositionAndResolveLinkTosBase { + private SubscriptionFilter filter; + + private SubscribeToAllOptions() { + super(OperationKind.Streaming); + } + + /** + * Returns options with default values. + */ + public static SubscribeToAllOptions get() { + return new SubscribeToAllOptions(); + } + + SubscriptionFilter getFilter() { + return filter; + } + + /** + * Applies a server-side filter to determine if an event of the subscription should be yielded. + */ + public SubscribeToAllOptions filter(SubscriptionFilter filter) { + this.filter = filter; + return this; + } +} diff --git a/src/main/java/io/kurrent/dbclient/SubscribeToStream.java b/src/main/java/io/trogonstack/eventstore/client/SubscribeToStream.java similarity index 82% rename from src/main/java/io/kurrent/dbclient/SubscribeToStream.java rename to src/main/java/io/trogonstack/eventstore/client/SubscribeToStream.java index 1529dc7..b9c4fca 100644 --- a/src/main/java/io/kurrent/dbclient/SubscribeToStream.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscribeToStream.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; class SubscribeToStream extends AbstractRegularSubscription { private final SubscribeToStreamOptions options; diff --git a/src/main/java/io/kurrent/dbclient/SubscribeToStreamOptions.java b/src/main/java/io/trogonstack/eventstore/client/SubscribeToStreamOptions.java similarity index 90% rename from src/main/java/io/kurrent/dbclient/SubscribeToStreamOptions.java rename to src/main/java/io/trogonstack/eventstore/client/SubscribeToStreamOptions.java index 6cb8bad..5185353 100644 --- a/src/main/java/io/kurrent/dbclient/SubscribeToStreamOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscribeToStreamOptions.java @@ -1,17 +1,17 @@ -package io.kurrent.dbclient; - -/** - * Options of the subscribe to stream request. - */ -public class SubscribeToStreamOptions extends OptionsWithStartRevisionAndResolveLinkTosBase { - private SubscribeToStreamOptions() { - super(OperationKind.Streaming); - } - - /** - * Returns options with default values. - */ - public static SubscribeToStreamOptions get() { - return new SubscribeToStreamOptions(); - } -} +package io.trogonstack.eventstore.client; + +/** + * Options of the subscribe to stream request. + */ +public class SubscribeToStreamOptions extends OptionsWithStartRevisionAndResolveLinkTosBase { + private SubscribeToStreamOptions() { + super(OperationKind.Streaming); + } + + /** + * Returns options with default values. + */ + public static SubscribeToStreamOptions get() { + return new SubscribeToStreamOptions(); + } +} diff --git a/src/main/java/io/kurrent/dbclient/Subscription.java b/src/main/java/io/trogonstack/eventstore/client/Subscription.java similarity index 87% rename from src/main/java/io/kurrent/dbclient/Subscription.java rename to src/main/java/io/trogonstack/eventstore/client/Subscription.java index 2ee5108..de9848a 100644 --- a/src/main/java/io/kurrent/dbclient/Subscription.java +++ b/src/main/java/io/trogonstack/eventstore/client/Subscription.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import io.grpc.stub.ClientCallStreamObserver; /** diff --git a/src/main/java/io/kurrent/dbclient/SubscriptionFilter.java b/src/main/java/io/trogonstack/eventstore/client/SubscriptionFilter.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/SubscriptionFilter.java rename to src/main/java/io/trogonstack/eventstore/client/SubscriptionFilter.java index 6c8c3a7..d8ce2ac 100644 --- a/src/main/java/io/kurrent/dbclient/SubscriptionFilter.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscriptionFilter.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; -import io.kurrent.dbclient.proto.streams.StreamsOuterClass; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.streams.StreamsOuterClass; import javax.validation.constraints.NotNull; import java.util.Objects; diff --git a/src/main/java/io/kurrent/dbclient/SubscriptionFilterBuilder.java b/src/main/java/io/trogonstack/eventstore/client/SubscriptionFilterBuilder.java similarity index 99% rename from src/main/java/io/kurrent/dbclient/SubscriptionFilterBuilder.java rename to src/main/java/io/trogonstack/eventstore/client/SubscriptionFilterBuilder.java index a0c650f..dfd32c4 100644 --- a/src/main/java/io/kurrent/dbclient/SubscriptionFilterBuilder.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscriptionFilterBuilder.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import javax.validation.constraints.NotNull; import java.util.ArrayList; diff --git a/src/main/java/io/kurrent/dbclient/SubscriptionListener.java b/src/main/java/io/trogonstack/eventstore/client/SubscriptionListener.java similarity index 92% rename from src/main/java/io/kurrent/dbclient/SubscriptionListener.java rename to src/main/java/io/trogonstack/eventstore/client/SubscriptionListener.java index 5fc4398..d68c5bb 100644 --- a/src/main/java/io/kurrent/dbclient/SubscriptionListener.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscriptionListener.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.time.Instant; @@ -7,7 +7,7 @@ */ public abstract class SubscriptionListener { /** - * Called when EventStoreDB sends an event to the subscription. + * Called when TrogonEventStore sends an event to the subscription. * @param subscription handle to the subscription. * @param event a resolved event. */ diff --git a/src/main/java/io/kurrent/dbclient/SubscriptionStreamConsumer.java b/src/main/java/io/trogonstack/eventstore/client/SubscriptionStreamConsumer.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/SubscriptionStreamConsumer.java rename to src/main/java/io/trogonstack/eventstore/client/SubscriptionStreamConsumer.java index bd51540..79efbb2 100644 --- a/src/main/java/io/kurrent/dbclient/SubscriptionStreamConsumer.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscriptionStreamConsumer.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.time.Instant; diff --git a/src/main/java/io/kurrent/dbclient/SubscriptionTracingCallback.java b/src/main/java/io/trogonstack/eventstore/client/SubscriptionTracingCallback.java similarity index 77% rename from src/main/java/io/kurrent/dbclient/SubscriptionTracingCallback.java rename to src/main/java/io/trogonstack/eventstore/client/SubscriptionTracingCallback.java index b86f4a2..2076687 100644 --- a/src/main/java/io/kurrent/dbclient/SubscriptionTracingCallback.java +++ b/src/main/java/io/trogonstack/eventstore/client/SubscriptionTracingCallback.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; @FunctionalInterface public interface SubscriptionTracingCallback { diff --git a/src/main/java/io/kurrent/dbclient/SystemMetadataKeys.java b/src/main/java/io/trogonstack/eventstore/client/SystemMetadataKeys.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/SystemMetadataKeys.java rename to src/main/java/io/trogonstack/eventstore/client/SystemMetadataKeys.java index d46a02d..edbfce9 100644 --- a/src/main/java/io/kurrent/dbclient/SystemMetadataKeys.java +++ b/src/main/java/io/trogonstack/eventstore/client/SystemMetadataKeys.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class SystemMetadataKeys { static final String CONTENT_TYPE = "content-type"; diff --git a/src/main/java/io/kurrent/dbclient/SystemStreamAcl.java b/src/main/java/io/trogonstack/eventstore/client/SystemStreamAcl.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/SystemStreamAcl.java rename to src/main/java/io/trogonstack/eventstore/client/SystemStreamAcl.java index 16e81ee..5f601da 100644 --- a/src/main/java/io/kurrent/dbclient/SystemStreamAcl.java +++ b/src/main/java/io/trogonstack/eventstore/client/SystemStreamAcl.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Admin stream access control list (ACL). diff --git a/src/main/java/io/kurrent/dbclient/SystemStreams.java b/src/main/java/io/trogonstack/eventstore/client/SystemStreams.java similarity index 82% rename from src/main/java/io/kurrent/dbclient/SystemStreams.java rename to src/main/java/io/trogonstack/eventstore/client/SystemStreams.java index a51ae25..904908f 100644 --- a/src/main/java/io/kurrent/dbclient/SystemStreams.java +++ b/src/main/java/io/trogonstack/eventstore/client/SystemStreams.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class SystemStreams { public static final String ALL_STREAM = "$all"; diff --git a/src/main/java/io/kurrent/dbclient/ThrowingBiFunction.java b/src/main/java/io/trogonstack/eventstore/client/ThrowingBiFunction.java similarity index 80% rename from src/main/java/io/kurrent/dbclient/ThrowingBiFunction.java rename to src/main/java/io/trogonstack/eventstore/client/ThrowingBiFunction.java index ae17ab6..b89736e 100644 --- a/src/main/java/io/kurrent/dbclient/ThrowingBiFunction.java +++ b/src/main/java/io/trogonstack/eventstore/client/ThrowingBiFunction.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; @FunctionalInterface interface ThrowingBiFunction { diff --git a/src/main/java/io/kurrent/dbclient/ThrowingFunction.java b/src/main/java/io/trogonstack/eventstore/client/ThrowingFunction.java similarity index 78% rename from src/main/java/io/kurrent/dbclient/ThrowingFunction.java rename to src/main/java/io/trogonstack/eventstore/client/ThrowingFunction.java index abb8c6e..5888f32 100644 --- a/src/main/java/io/kurrent/dbclient/ThrowingFunction.java +++ b/src/main/java/io/trogonstack/eventstore/client/ThrowingFunction.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; @FunctionalInterface interface ThrowingFunction { diff --git a/src/main/java/io/kurrent/dbclient/KurrentDBClient.java b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClient.java similarity index 78% rename from src/main/java/io/kurrent/dbclient/KurrentDBClient.java rename to src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClient.java index c818494..652fb24 100644 --- a/src/main/java/io/kurrent/dbclient/KurrentDBClient.java +++ b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClient.java @@ -1,31 +1,29 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.json.JsonMapper; import org.reactivestreams.Publisher; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.concurrent.CompletableFuture; /** - * Represents EventStoreDB client for stream operations. A client instance maintains a two-way communication to EventStoreDB. - * Many threads can use the EventStoreDB client simultaneously, or a single thread can make many asynchronous requests. + * Represents a TrogonEventStore client for stream operations. A client instance maintains two-way communication with TrogonEventStore. + * Many threads can use the TrogonEventStore client simultaneously, or a single thread can make many asynchronous requests. */ -public class KurrentDBClient extends KurrentDBClientBase { - private KurrentDBClient(KurrentDBClientSettings settings) { +public class TrogonEventStoreClient extends TrogonEventStoreClientBase { + private TrogonEventStoreClient(TrogonEventStoreClientSettings settings) { super(settings); } /** - * Creates a gRPC client to KurrentDB database. + * Creates a gRPC client to TrogonEventStore database. */ - public static KurrentDBClient create(KurrentDBClientSettings settings) { - return new KurrentDBClient(settings); + public static TrogonEventStoreClient create(TrogonEventStoreClientSettings settings) { + return new TrogonEventStoreClient(settings); } /** @@ -77,82 +75,6 @@ public CompletableFuture appendToStream(String streamName, AppendTo return new AppendToStream(this.getGrpcClient(), streamName, events, options).execute(); } - public CompletableFuture multiStreamAppend(Iterator requests) { - return new MultiStreamAppend(this.getGrpcClient(), requests).execute(); - } - - /** - * Appends records to one or more streams atomically with cross-stream consistency checks. - * Records can be interleaved across streams in any order and the global log preserves - * the exact sequence from the request. - * - * @param records the records to append, each specifying its target stream. - * @return a response with per-stream revisions and the global commit position. - */ - public CompletableFuture appendRecords(List records) { - return appendRecords(records, null); - } - - /** - * Appends records to one or more streams atomically with cross-stream consistency checks. - * Records can be interleaved across streams in any order and the global log preserves - * the exact sequence from the request. - * - *

Consistency checks are decoupled from writes: a check can reference any stream, - * whether or not the request writes to it. This enables Dynamic Consistency Boundary - * (DCB) patterns.

- * - * @param records the records to append, each specifying its target stream. - * @param checks optional consistency checks evaluated before commit. - * @return a response with per-stream revisions and the global commit position. - */ - public CompletableFuture appendRecords(List records, List checks) { - return new AppendRecords(this.getGrpcClient(), records, checks).execute(); - } - - /** - * Appends records to one or more streams atomically. - * - * @param records the records to append, each specifying its target stream. - * @return a response with per-stream revisions and the global commit position. - */ - public CompletableFuture appendRecords(AppendRecord... records) { - return appendRecords(Arrays.asList(records), null); - } - - /** - * Appends events to a single stream atomically. - * - * @param stream the target stream name. - * @param events the events to append. - * @return a response with per-stream revisions and the global commit position. - */ - public CompletableFuture appendRecords(String stream, List events) { - return appendRecords(stream, null, events); - } - - /** - * Appends events to a single stream atomically with a consistency check. - * - * @param stream the target stream name. - * @param expectedState the expected state of the stream, or null for no check. - * @param events the events to append. - * @return a response with per-stream revisions and the global commit position. - */ - public CompletableFuture appendRecords(String stream, StreamState expectedState, List events) { - List records = new ArrayList<>(events.size()); - for (EventData event : events) { - records.add(new AppendRecord(stream, event)); - } - - List checks = null; - if (expectedState != null) { - checks = Collections.singletonList(new ConsistencyCheck.StreamStateCheck(stream, expectedState)); - } - - return appendRecords(records, checks); - } - /** * Sets a stream's metadata. * @param streamName stream's name. diff --git a/src/main/java/io/kurrent/dbclient/KurrentDBClientBase.java b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClientBase.java similarity index 84% rename from src/main/java/io/kurrent/dbclient/KurrentDBClientBase.java rename to src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClientBase.java index c552c3e..8fd1db8 100644 --- a/src/main/java/io/kurrent/dbclient/KurrentDBClientBase.java +++ b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClientBase.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.slf4j.Logger; @@ -11,11 +11,11 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; -public class KurrentDBClientBase { - final Logger logger = LoggerFactory.getLogger(KurrentDBClientBase.class); +public class TrogonEventStoreClientBase { + final Logger logger = LoggerFactory.getLogger(TrogonEventStoreClientBase.class); final private GrpcClient client; - KurrentDBClientBase(KurrentDBClientSettings settings) { + TrogonEventStoreClientBase(TrogonEventStoreClientSettings settings) { Discovery discovery; if (settings.getHosts().length == 1 && !settings.isDnsDiscover()) { @@ -33,7 +33,7 @@ public class KurrentDBClientBase { } private Executor createConnectionLoopExecutor() { return Executors.newSingleThreadExecutor(r -> { - Thread thread = new Thread(r, "esdb-client-" + UUID.randomUUID()); + Thread thread = new Thread(r, "trogon-eventstore-client-" + UUID.randomUUID()); thread.setDaemon(true); return thread; }); diff --git a/src/main/java/io/kurrent/dbclient/KurrentDBClientSettings.java b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClientSettings.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/KurrentDBClientSettings.java rename to src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClientSettings.java index fc3c983..bc04057 100644 --- a/src/main/java/io/kurrent/dbclient/KurrentDBClientSettings.java +++ b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreClientSettings.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.ClientInterceptor; @@ -7,10 +7,10 @@ import java.util.Set; /** - * Gathers all the settings related to a gRPC client with a KurrentDB database. - * EventStoreDBClientSettings} can only be created when parsing a connection string. + * Gathers all the settings related to a gRPC client with a TrogonEventStore database. + * TrogonEventStoreClientSettings can only be created when parsing a connection string. * - * KurrentDBClientSettings supports a wide range of settings. If a setting is not mentioned in the connection + * TrogonEventStoreClientSettings supports a wide range of settings. If a setting is not mentioned in the connection * string, that setting default value is used. * *
    @@ -24,7 +24,7 @@ *
  • keepAliveInterval: 10000
  • *
*/ -public class KurrentDBClientSettings { +public class TrogonEventStoreClientSettings { private final boolean dnsDiscover; private final int maxDiscoverAttempts; private final int discoveryInterval; @@ -167,7 +167,7 @@ public String getTlsCaFile() { */ public Set getFeatures() { return features; } - KurrentDBClientSettings( + TrogonEventStoreClientSettings( boolean dnsDiscover, int maxDiscoverAttempts, int discoveryInterval, diff --git a/src/main/java/io/kurrent/dbclient/KurrentDBConnectionString.java b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreConnectionString.java similarity index 74% rename from src/main/java/io/kurrent/dbclient/KurrentDBConnectionString.java rename to src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreConnectionString.java index e90668c..278ac01 100644 --- a/src/main/java/io/kurrent/dbclient/KurrentDBConnectionString.java +++ b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreConnectionString.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.io.IOException; import java.net.*; @@ -6,19 +6,19 @@ /** * Utility class to parse a connection string. */ -public final class KurrentDBConnectionString { - KurrentDBConnectionString() {} +public final class TrogonEventStoreConnectionString { + TrogonEventStoreConnectionString() {} /** * Parses a string representation of a client settings. Throws a runtime exception if the connection string is * malformed. * @return a client settings. */ - public static KurrentDBClientSettings parseOrThrow(String connectionString) { - ConnectionSettingsBuilder builder = KurrentDBClientSettings.builder(); + public static TrogonEventStoreClientSettings parseOrThrow(String connectionString) { + ConnectionSettingsBuilder builder = TrogonEventStoreClientSettings.builder(); try { - URL url = new URL(null, connectionString, new EsdbUrlHandler()); + URL url = new URL(null, connectionString, new TrogonEventStoreUrlHandler()); return ConnectionSettingsBuilder.parseFromUrl(builder, url); } catch (MalformedURLException e) { if (!connectionString.contains(",")) @@ -31,7 +31,7 @@ public static KurrentDBClientSettings parseOrThrow(String connectionString) { URL url = new URL( null, connectionString.replaceAll(",", "/"), - new EsdbUrlHandler()); + new TrogonEventStoreUrlHandler()); if (url.getHost().isEmpty()) throw new RuntimeException("Connection string doesn't have an host"); @@ -54,9 +54,9 @@ public static KurrentDBClientSettings parseOrThrow(String connectionString) { } /** - * Used to support 'esdb' and 'esdb+discover' URL protocol/scheme + * Supports TrogonEventStore connection string URL schemes. */ - public static class EsdbUrlHandler extends URLStreamHandler { + public static class TrogonEventStoreUrlHandler extends URLStreamHandler { @Override protected URLConnection openConnection(URL u) throws IOException { return null; diff --git a/src/main/java/io/kurrent/dbclient/KurrentDBPersistentSubscriptionsClient.java b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStorePersistentSubscriptionsClient.java similarity index 92% rename from src/main/java/io/kurrent/dbclient/KurrentDBPersistentSubscriptionsClient.java rename to src/main/java/io/trogonstack/eventstore/client/TrogonEventStorePersistentSubscriptionsClient.java index d9e5179..3b1d1ba 100644 --- a/src/main/java/io/kurrent/dbclient/KurrentDBPersistentSubscriptionsClient.java +++ b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStorePersistentSubscriptionsClient.java @@ -1,416 +1,416 @@ -package io.kurrent.dbclient; - -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.function.Function; - -/** - * Represents EventStoreDB client for persistent subscriptions management. A client instance maintains a two-way communication to EventStoreDB. - * Many threads can use the KurrentDB client simultaneously, or a single thread can make many asynchronous requests. - */ -public class KurrentDBPersistentSubscriptionsClient { - private final KurrentDBClientBase inner; - - private KurrentDBPersistentSubscriptionsClient(KurrentDBClientSettings settings) { - inner = new KurrentDBClientBase(settings); - } - - private KurrentDBPersistentSubscriptionsClient(KurrentDBClientBase inner) { - this.inner = inner; - } - - /** - * Creates a persistent subscription client instance. - */ - public static KurrentDBPersistentSubscriptionsClient create(KurrentDBClientSettings settings) { - return new KurrentDBPersistentSubscriptionsClient(settings); - } - - /** - * Returns a Persistent Subscription Management client based on existing client. - * @param existingClient Existing client. - */ - public static KurrentDBPersistentSubscriptionsClient from(KurrentDBClientBase existingClient) { - return new KurrentDBPersistentSubscriptionsClient(existingClient); - } - /** - * Creates a persistent subscription group on a stream. - * - *

- * Persistent subscriptions are special kind of subscription where the server remembers the state of the - * subscription. This allows for many different modes of operations compared to a regular or catchup subscription - * where the client holds the subscription state. Persistent subscriptions don't guarantee ordering and unlike - * catchup-subscriptions, they start from the end of stream by default. - *

- * @param stream stream's name. - * @param group group's name - */ - public CompletableFuture createToStream(String stream, String group) { - return this.createToStream(stream, group, CreatePersistentSubscriptionToStreamOptions.get()); - } - - /** - * Creates a persistent subscription group on the $all stream. - * - *

- * Persistent subscriptions are special kind of subscription where the server remembers the state of the - * subscription. This allows for many different modes of operations compared to a regular or catchup subscription - * where the client holds the subscription state. Persistent subscriptions don't guarantee ordering and unlike - * catchup-subscriptions, they start from the end of stream by default. - *

- * @param group group's name - */ - public CompletableFuture createToAll(String group) { - return this.createToAll(group, CreatePersistentSubscriptionToAllOptions.get()); - } - - /** - * Creates a persistent subscription group on a stream. - * - *

- * Persistent subscriptions are special kind of subscription where the server remembers the state of the - * subscription. This allows for many different modes of operations compared to a regular or catchup subscription - * where the client holds the subscription state. Persistent subscriptions don't guarantee ordering and unlike - * catchup-subscriptions, they start from the end of stream by default. - *

- * @param stream stream's name. - * @param group group's name - * @param options create persistent subscription request's options. - */ - public CompletableFuture createToStream(String stream, String group, CreatePersistentSubscriptionToStreamOptions options) { - if (options == null) { - options = CreatePersistentSubscriptionToStreamOptions.get(); - } - - return new CreatePersistentSubscriptionToStream(inner.getGrpcClient(), stream, group, options).execute(); - } - - /** - * Creates a persistent subscription group on the $all stream. - * - *

- * Persistent subscriptions are special kind of subscription where the server remembers the state of the - * subscription. This allows for many different modes of operations compared to a regular or catchup subscription - * where the client holds the subscription state. Persistent subscriptions don't guarantee ordering and unlike - * catchup-subscriptions, they start from the end of stream by default. - *

- * @param group group's name - * @param options create persistent subscription request's options. - */ - public CompletableFuture createToAll(String group, CreatePersistentSubscriptionToAllOptions options) { - if (options == null) { - options = CreatePersistentSubscriptionToAllOptions.get(); - } - - return new CreatePersistentSubscriptionToAll(inner.getGrpcClient(), group, options).execute(); - } - - /** - * Updates a persistent subscription group on a stream. - * @param stream stream's name. - * @param group group's name. - */ - public CompletableFuture updateToStream(String stream, String group) { - return this.updateToStream(stream, group, UpdatePersistentSubscriptionToStreamOptions.get()); - } - - /** - * Updates a persistent subscription group on the $all stream. - * @param group group's name. - */ - public CompletableFuture updateToAll(String group) { - return this.updateToAll(group, UpdatePersistentSubscriptionToAllOptions.get()); - } - - /** - * Updates a persistent subscription group on a stream. - * @param stream stream's name. - * @param group group's name. - * @param options update persistent subscription request's options. - */ - public CompletableFuture updateToStream(String stream, String group, UpdatePersistentSubscriptionToStreamOptions options) { - if (options == null) { - options = UpdatePersistentSubscriptionToStreamOptions.get(); - } - - return new UpdatePersistentSubscriptionToStream(inner.getGrpcClient(), stream, group, options).execute(); - } - - /** - * Updates a persistent subscription group on the $all stream. - * @param group group's name. - * @param options update persistent subscription request's options. - */ - public CompletableFuture updateToAll(String group, UpdatePersistentSubscriptionToAllOptions options) { - if (options == null) { - options = UpdatePersistentSubscriptionToAllOptions.get(); - } - - return new UpdatePersistentSubscriptionToAll(inner.getGrpcClient(), group, options).execute(); - } - - /** - * Deletes a persistent subscription group on a stream. - * @param stream stream's name. - * @param group group's name. - */ - public CompletableFuture deleteToStream(String stream, String group) { - return this.deleteToStream(stream, group, DeletePersistentSubscriptionOptions.get()); - } - - /** - * Deletes a persistent subscription group on the $all stream. - * @param group group's name. - */ - public CompletableFuture deleteToAll(String group) { - return this.deleteToAll(group, DeletePersistentSubscriptionOptions.get()); - } - - /** - * Deletes a persistent subscription group on a stream. - * @param stream stream's name. - * @param group group's name. - * @param options the delete persistent subscription request's options. - */ - public CompletableFuture deleteToStream(String stream, String group, DeletePersistentSubscriptionOptions options) { - if (options == null) { - options = DeletePersistentSubscriptionOptions.get(); - } - - return new DeletePersistentSubscriptionToStream(inner.getGrpcClient(), stream, group, options).execute(); - } - - /** - * Deletes a persistent subscription group on the $all stream. - * @param group group's name. - * @param options the delete persistent subscription request's options. - */ - public CompletableFuture deleteToAll(String group, DeletePersistentSubscriptionOptions options) { - if (options == null) { - options = DeletePersistentSubscriptionOptions.get(); - } - - return new DeletePersistentSubscriptionToAll(inner.getGrpcClient(), group, options).execute(); - } - - /** - * Connects to a persistent subscription group on a stream. - * @param stream stream's name. - * @param group group's name. - * @param listener persistent subscription event listener. - * @return a persistent subscription handle. - */ - public CompletableFuture subscribeToStream(String stream, String group, PersistentSubscriptionListener listener) { - return this.subscribeToStream(stream, group, SubscribePersistentSubscriptionOptions.get(), listener); - } - - /** - * Connects to a persistent subscription group on the $all stream. - * @param group group's name. - * @param listener persistent subscription event listener. - * @return a persistent subscription handle. - */ - public CompletableFuture subscribeToAll(String group, PersistentSubscriptionListener listener) { - return this.subscribeToAll(group, SubscribePersistentSubscriptionOptions.get(), listener); - } - - /** - * Connects to a persistent subscription group on a stream. - * @param stream stream's name. - * @param group group's name. - * @param options a persistent subscription subscribe's request. - * @param listener persistent subscription event listener. - * @return a persistent subscription handle. - */ - public CompletableFuture subscribeToStream(String stream, String group, SubscribePersistentSubscriptionOptions options, PersistentSubscriptionListener listener) { - if (options == null) { - options = SubscribePersistentSubscriptionOptions.get(); - } - - return new SubscribePersistentSubscriptionToStream(inner.getGrpcClient(), stream, group, options, listener).execute(); - } - - /** - * Connects to a persistent subscription group on the $all stream. - * @param group group's name. - * @param options a persistent subscription subscribe's request. - * @param listener persistent subscription event listener. - * @return a persistent subscription handle. - */ - public CompletableFuture subscribeToAll(String group, SubscribePersistentSubscriptionOptions options, PersistentSubscriptionListener listener) { - if (options == null) { - options = SubscribePersistentSubscriptionOptions.get(); - } - - return new SubscribePersistentSubscriptionToAll(inner.getGrpcClient(), group, options, listener).execute(); - } - - /** - * Lists all existing persistent subscriptions. - - * @param options list persistent subscriptions request's options. - * @see PersistentSubscriptionInfo - */ - public CompletableFuture> listAll(ListPersistentSubscriptionsOptions options) { - return ListPersistentSubscriptions.execute(inner.getGrpcClient(), options, "", Function.identity()); - } - - /** - * Lists all existing persistent subscriptions. - - * @see PersistentSubscriptionInfo - */ - public CompletableFuture> listAll() { - return listAll(ListPersistentSubscriptionsOptions.get()); - } - - /** - * Lists all persistent subscriptions of a specific stream. - * @param stream stream's name. - * @param options list persistent subscriptions request's options. - */ - public CompletableFuture> listToStream(String stream, ListPersistentSubscriptionsOptions options) { - return ListPersistentSubscriptions.execute(inner.getGrpcClient(), options, stream, info -> (PersistentSubscriptionToStreamInfo) info); - } - - /** - * Lists all persistent subscriptions of a specific stream. - * @param stream stream's name. - * @see PersistentSubscriptionToStreamInfo - */ - public CompletableFuture> listToStream(String stream) { - return listToStream(stream, ListPersistentSubscriptionsOptions.get()); - } - - /** - * Lists all persistent subscriptions of a specific to the $all stream. - * @see PersistentSubscriptionToAllInfo - */ - public CompletableFuture> listToAll() { - return listToAll(ListPersistentSubscriptionsOptions.get()); - } - - /** - * Lists all persistent subscriptions of a specific to the $all stream. - * @param options list persistent subscriptions request's options. - * @see PersistentSubscriptionToAllInfo - */ - public CompletableFuture> listToAll(ListPersistentSubscriptionsOptions options) { - return ListPersistentSubscriptions.execute(inner.getGrpcClient(), options, "$all", info -> (PersistentSubscriptionToAllInfo) info); - } - - /** - * Gets a specific persistent subscription info. - * @param stream stream's name. - * @param groupName group's name. - * @param options get persistent subscription info request's options. - * @see PersistentSubscriptionInfo - */ - public CompletableFuture> getInfoToStream(String stream, String groupName, GetPersistentSubscriptionInfoOptions options) { - return GetPersistentSubscriptionInfo.execute(inner.getGrpcClient(), options, stream, groupName).thenApply(res -> - res.map(PersistentSubscriptionToStreamInfo.class::cast) - ); - } - - /** - * Gets a specific persistent subscription info to a stream. - * @param stream stream's name. - * @param groupName group's name. - * @see PersistentSubscriptionInfo - */ - public CompletableFuture> getInfoToStream(String stream, String groupName) { - return getInfoToStream(stream, groupName, GetPersistentSubscriptionInfoOptions.get()); - } - - /** - * Gets a specific persistent subscription info to the $all stream. - * @param groupName group's name. - * @param options get persistent subscription info request's options. - * @see PersistentSubscriptionToAllInfo - */ - public CompletableFuture> getInfoToAll(String groupName, GetPersistentSubscriptionInfoOptions options) { - return GetPersistentSubscriptionInfo.execute(inner.getGrpcClient(), options, "$all", groupName).thenApply(res -> - res.map(PersistentSubscriptionToAllInfo.class::cast) - ); - } - - /** - * Gets a specific persistent subscription info to the $all stream. - * @param groupName group's name. - * @see PersistentSubscriptionToAllInfo - */ - public CompletableFuture> getInfoToAll(String groupName) { - return getInfoToAll(groupName, GetPersistentSubscriptionInfoOptions.get()); - } - - /** - * Replays a persistent subscription to a stream parked events. - * @param stream stream's name. - * @param groupName group's name. - * @param options replay parked messages to stream request's options. - */ - public CompletableFuture replayParkedMessagesToStream(String stream, String groupName, ReplayParkedMessagesOptions options) { - return ReplayParkedMessages.execute(inner.getGrpcClient(), options, stream, groupName); - } - - /** - * Replays a persistent subscription to a stream parked events. - * @param stream stream's name. - * @param groupName group's name. - */ - public CompletableFuture replayParkedMessagesToStream(String stream, String groupName) { - return replayParkedMessagesToStream(stream, groupName, ReplayParkedMessagesOptions.get()); - } - - /** - * Replays a persistent subscription to the $all stream parked events. - * @param groupName group's name. - * @param options replay parked messages to stream request's options. - */ - public CompletableFuture replayParkedMessagesToAll(String groupName, ReplayParkedMessagesOptions options) { - return replayParkedMessagesToStream("$all", groupName, options); - } - - /** - * Replays a persistent subscription to the $all stream parked events. - * @param groupName group's name. - */ - public CompletableFuture replayParkedMessagesToAll(String groupName) throws ExecutionException, InterruptedException { - return replayParkedMessagesToAll(groupName, ReplayParkedMessagesOptions.get()); - } - - /** - * Restarts the server persistent subscription subsystem. - */ - public CompletableFuture restartSubsystem() { - return restartSubsystem(RestartPersistentSubscriptionSubsystemOptions.get()); - } - - /** - * Restarts the server persistent subscription subsystem. - * @param options restart persistent subscription subsystem request's options. - - */ - public CompletableFuture restartSubsystem(RestartPersistentSubscriptionSubsystemOptions options) { - return RestartPersistentSubscriptionSubsystem.execute(inner.getGrpcClient(), options); - } - - /** - * Closes a connection and cleans all its allocated resources. - */ - public CompletableFuture shutdown() { - return inner.shutdown(); - } - - /** - * Checks if this client instance has been shutdown. - * After shutdown a client instance can no longer process new operations and - * a new client instance has to be created. - * @return {@code true} if client instance has been shutdown. - */ - public boolean isShutdown() { - return inner.isShutdown(); - } -} +package io.trogonstack.eventstore.client; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.function.Function; + +/** + * Represents a TrogonEventStore client for persistent subscription management. A client instance maintains two-way communication with TrogonEventStore. + * Many threads can use the TrogonEventStore client simultaneously, or a single thread can make many asynchronous requests. + */ +public class TrogonEventStorePersistentSubscriptionsClient { + private final TrogonEventStoreClientBase inner; + + private TrogonEventStorePersistentSubscriptionsClient(TrogonEventStoreClientSettings settings) { + inner = new TrogonEventStoreClientBase(settings); + } + + private TrogonEventStorePersistentSubscriptionsClient(TrogonEventStoreClientBase inner) { + this.inner = inner; + } + + /** + * Creates a persistent subscription client instance. + */ + public static TrogonEventStorePersistentSubscriptionsClient create(TrogonEventStoreClientSettings settings) { + return new TrogonEventStorePersistentSubscriptionsClient(settings); + } + + /** + * Returns a Persistent Subscription Management client based on existing client. + * @param existingClient Existing client. + */ + public static TrogonEventStorePersistentSubscriptionsClient from(TrogonEventStoreClientBase existingClient) { + return new TrogonEventStorePersistentSubscriptionsClient(existingClient); + } + /** + * Creates a persistent subscription group on a stream. + * + *

+ * Persistent subscriptions are special kind of subscription where the server remembers the state of the + * subscription. This allows for many different modes of operations compared to a regular or catchup subscription + * where the client holds the subscription state. Persistent subscriptions don't guarantee ordering and unlike + * catchup-subscriptions, they start from the end of stream by default. + *

+ * @param stream stream's name. + * @param group group's name + */ + public CompletableFuture createToStream(String stream, String group) { + return this.createToStream(stream, group, CreatePersistentSubscriptionToStreamOptions.get()); + } + + /** + * Creates a persistent subscription group on the $all stream. + * + *

+ * Persistent subscriptions are special kind of subscription where the server remembers the state of the + * subscription. This allows for many different modes of operations compared to a regular or catchup subscription + * where the client holds the subscription state. Persistent subscriptions don't guarantee ordering and unlike + * catchup-subscriptions, they start from the end of stream by default. + *

+ * @param group group's name + */ + public CompletableFuture createToAll(String group) { + return this.createToAll(group, CreatePersistentSubscriptionToAllOptions.get()); + } + + /** + * Creates a persistent subscription group on a stream. + * + *

+ * Persistent subscriptions are special kind of subscription where the server remembers the state of the + * subscription. This allows for many different modes of operations compared to a regular or catchup subscription + * where the client holds the subscription state. Persistent subscriptions don't guarantee ordering and unlike + * catchup-subscriptions, they start from the end of stream by default. + *

+ * @param stream stream's name. + * @param group group's name + * @param options create persistent subscription request's options. + */ + public CompletableFuture createToStream(String stream, String group, CreatePersistentSubscriptionToStreamOptions options) { + if (options == null) { + options = CreatePersistentSubscriptionToStreamOptions.get(); + } + + return new CreatePersistentSubscriptionToStream(inner.getGrpcClient(), stream, group, options).execute(); + } + + /** + * Creates a persistent subscription group on the $all stream. + * + *

+ * Persistent subscriptions are special kind of subscription where the server remembers the state of the + * subscription. This allows for many different modes of operations compared to a regular or catchup subscription + * where the client holds the subscription state. Persistent subscriptions don't guarantee ordering and unlike + * catchup-subscriptions, they start from the end of stream by default. + *

+ * @param group group's name + * @param options create persistent subscription request's options. + */ + public CompletableFuture createToAll(String group, CreatePersistentSubscriptionToAllOptions options) { + if (options == null) { + options = CreatePersistentSubscriptionToAllOptions.get(); + } + + return new CreatePersistentSubscriptionToAll(inner.getGrpcClient(), group, options).execute(); + } + + /** + * Updates a persistent subscription group on a stream. + * @param stream stream's name. + * @param group group's name. + */ + public CompletableFuture updateToStream(String stream, String group) { + return this.updateToStream(stream, group, UpdatePersistentSubscriptionToStreamOptions.get()); + } + + /** + * Updates a persistent subscription group on the $all stream. + * @param group group's name. + */ + public CompletableFuture updateToAll(String group) { + return this.updateToAll(group, UpdatePersistentSubscriptionToAllOptions.get()); + } + + /** + * Updates a persistent subscription group on a stream. + * @param stream stream's name. + * @param group group's name. + * @param options update persistent subscription request's options. + */ + public CompletableFuture updateToStream(String stream, String group, UpdatePersistentSubscriptionToStreamOptions options) { + if (options == null) { + options = UpdatePersistentSubscriptionToStreamOptions.get(); + } + + return new UpdatePersistentSubscriptionToStream(inner.getGrpcClient(), stream, group, options).execute(); + } + + /** + * Updates a persistent subscription group on the $all stream. + * @param group group's name. + * @param options update persistent subscription request's options. + */ + public CompletableFuture updateToAll(String group, UpdatePersistentSubscriptionToAllOptions options) { + if (options == null) { + options = UpdatePersistentSubscriptionToAllOptions.get(); + } + + return new UpdatePersistentSubscriptionToAll(inner.getGrpcClient(), group, options).execute(); + } + + /** + * Deletes a persistent subscription group on a stream. + * @param stream stream's name. + * @param group group's name. + */ + public CompletableFuture deleteToStream(String stream, String group) { + return this.deleteToStream(stream, group, DeletePersistentSubscriptionOptions.get()); + } + + /** + * Deletes a persistent subscription group on the $all stream. + * @param group group's name. + */ + public CompletableFuture deleteToAll(String group) { + return this.deleteToAll(group, DeletePersistentSubscriptionOptions.get()); + } + + /** + * Deletes a persistent subscription group on a stream. + * @param stream stream's name. + * @param group group's name. + * @param options the delete persistent subscription request's options. + */ + public CompletableFuture deleteToStream(String stream, String group, DeletePersistentSubscriptionOptions options) { + if (options == null) { + options = DeletePersistentSubscriptionOptions.get(); + } + + return new DeletePersistentSubscriptionToStream(inner.getGrpcClient(), stream, group, options).execute(); + } + + /** + * Deletes a persistent subscription group on the $all stream. + * @param group group's name. + * @param options the delete persistent subscription request's options. + */ + public CompletableFuture deleteToAll(String group, DeletePersistentSubscriptionOptions options) { + if (options == null) { + options = DeletePersistentSubscriptionOptions.get(); + } + + return new DeletePersistentSubscriptionToAll(inner.getGrpcClient(), group, options).execute(); + } + + /** + * Connects to a persistent subscription group on a stream. + * @param stream stream's name. + * @param group group's name. + * @param listener persistent subscription event listener. + * @return a persistent subscription handle. + */ + public CompletableFuture subscribeToStream(String stream, String group, PersistentSubscriptionListener listener) { + return this.subscribeToStream(stream, group, SubscribePersistentSubscriptionOptions.get(), listener); + } + + /** + * Connects to a persistent subscription group on the $all stream. + * @param group group's name. + * @param listener persistent subscription event listener. + * @return a persistent subscription handle. + */ + public CompletableFuture subscribeToAll(String group, PersistentSubscriptionListener listener) { + return this.subscribeToAll(group, SubscribePersistentSubscriptionOptions.get(), listener); + } + + /** + * Connects to a persistent subscription group on a stream. + * @param stream stream's name. + * @param group group's name. + * @param options a persistent subscription subscribe's request. + * @param listener persistent subscription event listener. + * @return a persistent subscription handle. + */ + public CompletableFuture subscribeToStream(String stream, String group, SubscribePersistentSubscriptionOptions options, PersistentSubscriptionListener listener) { + if (options == null) { + options = SubscribePersistentSubscriptionOptions.get(); + } + + return new SubscribePersistentSubscriptionToStream(inner.getGrpcClient(), stream, group, options, listener).execute(); + } + + /** + * Connects to a persistent subscription group on the $all stream. + * @param group group's name. + * @param options a persistent subscription subscribe's request. + * @param listener persistent subscription event listener. + * @return a persistent subscription handle. + */ + public CompletableFuture subscribeToAll(String group, SubscribePersistentSubscriptionOptions options, PersistentSubscriptionListener listener) { + if (options == null) { + options = SubscribePersistentSubscriptionOptions.get(); + } + + return new SubscribePersistentSubscriptionToAll(inner.getGrpcClient(), group, options, listener).execute(); + } + + /** + * Lists all existing persistent subscriptions. + + * @param options list persistent subscriptions request's options. + * @see PersistentSubscriptionInfo + */ + public CompletableFuture> listAll(ListPersistentSubscriptionsOptions options) { + return ListPersistentSubscriptions.execute(inner.getGrpcClient(), options, "", Function.identity()); + } + + /** + * Lists all existing persistent subscriptions. + + * @see PersistentSubscriptionInfo + */ + public CompletableFuture> listAll() { + return listAll(ListPersistentSubscriptionsOptions.get()); + } + + /** + * Lists all persistent subscriptions of a specific stream. + * @param stream stream's name. + * @param options list persistent subscriptions request's options. + */ + public CompletableFuture> listToStream(String stream, ListPersistentSubscriptionsOptions options) { + return ListPersistentSubscriptions.execute(inner.getGrpcClient(), options, stream, info -> (PersistentSubscriptionToStreamInfo) info); + } + + /** + * Lists all persistent subscriptions of a specific stream. + * @param stream stream's name. + * @see PersistentSubscriptionToStreamInfo + */ + public CompletableFuture> listToStream(String stream) { + return listToStream(stream, ListPersistentSubscriptionsOptions.get()); + } + + /** + * Lists all persistent subscriptions of a specific to the $all stream. + * @see PersistentSubscriptionToAllInfo + */ + public CompletableFuture> listToAll() { + return listToAll(ListPersistentSubscriptionsOptions.get()); + } + + /** + * Lists all persistent subscriptions of a specific to the $all stream. + * @param options list persistent subscriptions request's options. + * @see PersistentSubscriptionToAllInfo + */ + public CompletableFuture> listToAll(ListPersistentSubscriptionsOptions options) { + return ListPersistentSubscriptions.execute(inner.getGrpcClient(), options, "$all", info -> (PersistentSubscriptionToAllInfo) info); + } + + /** + * Gets a specific persistent subscription info. + * @param stream stream's name. + * @param groupName group's name. + * @param options get persistent subscription info request's options. + * @see PersistentSubscriptionInfo + */ + public CompletableFuture> getInfoToStream(String stream, String groupName, GetPersistentSubscriptionInfoOptions options) { + return GetPersistentSubscriptionInfo.execute(inner.getGrpcClient(), options, stream, groupName).thenApply(res -> + res.map(PersistentSubscriptionToStreamInfo.class::cast) + ); + } + + /** + * Gets a specific persistent subscription info to a stream. + * @param stream stream's name. + * @param groupName group's name. + * @see PersistentSubscriptionInfo + */ + public CompletableFuture> getInfoToStream(String stream, String groupName) { + return getInfoToStream(stream, groupName, GetPersistentSubscriptionInfoOptions.get()); + } + + /** + * Gets a specific persistent subscription info to the $all stream. + * @param groupName group's name. + * @param options get persistent subscription info request's options. + * @see PersistentSubscriptionToAllInfo + */ + public CompletableFuture> getInfoToAll(String groupName, GetPersistentSubscriptionInfoOptions options) { + return GetPersistentSubscriptionInfo.execute(inner.getGrpcClient(), options, "$all", groupName).thenApply(res -> + res.map(PersistentSubscriptionToAllInfo.class::cast) + ); + } + + /** + * Gets a specific persistent subscription info to the $all stream. + * @param groupName group's name. + * @see PersistentSubscriptionToAllInfo + */ + public CompletableFuture> getInfoToAll(String groupName) { + return getInfoToAll(groupName, GetPersistentSubscriptionInfoOptions.get()); + } + + /** + * Replays a persistent subscription to a stream parked events. + * @param stream stream's name. + * @param groupName group's name. + * @param options replay parked messages to stream request's options. + */ + public CompletableFuture replayParkedMessagesToStream(String stream, String groupName, ReplayParkedMessagesOptions options) { + return ReplayParkedMessages.execute(inner.getGrpcClient(), options, stream, groupName); + } + + /** + * Replays a persistent subscription to a stream parked events. + * @param stream stream's name. + * @param groupName group's name. + */ + public CompletableFuture replayParkedMessagesToStream(String stream, String groupName) { + return replayParkedMessagesToStream(stream, groupName, ReplayParkedMessagesOptions.get()); + } + + /** + * Replays a persistent subscription to the $all stream parked events. + * @param groupName group's name. + * @param options replay parked messages to stream request's options. + */ + public CompletableFuture replayParkedMessagesToAll(String groupName, ReplayParkedMessagesOptions options) { + return replayParkedMessagesToStream("$all", groupName, options); + } + + /** + * Replays a persistent subscription to the $all stream parked events. + * @param groupName group's name. + */ + public CompletableFuture replayParkedMessagesToAll(String groupName) throws ExecutionException, InterruptedException { + return replayParkedMessagesToAll(groupName, ReplayParkedMessagesOptions.get()); + } + + /** + * Restarts the server persistent subscription subsystem. + */ + public CompletableFuture restartSubsystem() { + return restartSubsystem(RestartPersistentSubscriptionSubsystemOptions.get()); + } + + /** + * Restarts the server persistent subscription subsystem. + * @param options restart persistent subscription subsystem request's options. + + */ + public CompletableFuture restartSubsystem(RestartPersistentSubscriptionSubsystemOptions options) { + return RestartPersistentSubscriptionSubsystem.execute(inner.getGrpcClient(), options); + } + + /** + * Closes a connection and cleans all its allocated resources. + */ + public CompletableFuture shutdown() { + return inner.shutdown(); + } + + /** + * Checks if this client instance has been shutdown. + * After shutdown a client instance can no longer process new operations and + * a new client instance has to be created. + * @return {@code true} if client instance has been shutdown. + */ + public boolean isShutdown() { + return inner.isShutdown(); + } +} diff --git a/src/main/java/io/kurrent/dbclient/KurrentDBProjectionManagementClient.java b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreProjectionManagementClient.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/KurrentDBProjectionManagementClient.java rename to src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreProjectionManagementClient.java index 8ecceac..0382a13 100644 --- a/src/main/java/io/kurrent/dbclient/KurrentDBProjectionManagementClient.java +++ b/src/main/java/io/trogonstack/eventstore/client/TrogonEventStoreProjectionManagementClient.java @@ -1,334 +1,334 @@ -package io.kurrent.dbclient; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.type.TypeFactory; - -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; - -/** - * Represents KurrentDB client for projections management. A client instance maintains a two-way communication to EventStoreDB. - * Many threads can use the EventStoreDB client simultaneously, or a single thread can make many asynchronous requests. - */ -public class KurrentDBProjectionManagementClient { - final KurrentDBClientBase inner; - private KurrentDBProjectionManagementClient(KurrentDBClientSettings settings) { - inner = new KurrentDBClientBase(settings); - } - - private KurrentDBProjectionManagementClient(KurrentDBClientBase inner) { - this.inner = inner; - } - - /** - * Returns the Projection Management client based on the settings. - * @param settings The settings to use for constructing the client. - */ - public static KurrentDBProjectionManagementClient create(KurrentDBClientSettings settings) { - return new KurrentDBProjectionManagementClient(settings); - } - - /** - * Returns a Projection Management client based on existing client. - * @param existingClient Existing client. - */ - public static KurrentDBProjectionManagementClient from(KurrentDBClientBase existingClient) { - return new KurrentDBProjectionManagementClient(existingClient); - } - - /** - * Stops the projection without writing a checkpoint. - * This can be used to disable a projection that has been faulted. - * @param projectionName Name of the projection. - */ - public CompletableFuture abort(final String projectionName) { - return this.abort(projectionName, AbortProjectionOptions.get()); - } - - /** - * Stops the projection without writing a checkpoint. - * This can be used to disable a projection that has been faulted. - * @param projectionName Name of the projection. - * @param options Additional options. - */ - public CompletableFuture abort(final String projectionName, AbortProjectionOptions options) { - return new AbortProjection(inner.getGrpcClient(), projectionName, options).execute(); - } - - /** - * Creates a new projection in the stopped state. Enable needs to be called separately to start the projection. - * @param projectionName Name of the projection. - * @param query The JavaScript projection. - */ - public CompletableFuture create(final String projectionName, final String query) { - return this.create(projectionName, query, CreateProjectionOptions.get()); - } - - /** - * Creates a new projection in the stopped state. Enable needs to be called separately to start the projection. - * @param projectionName Name of the projection. - * @param query The JavaScript projection. - * @param options Additional options. - */ - public CompletableFuture create(final String projectionName, final String query, CreateProjectionOptions options) { - if (options == null) - options = CreateProjectionOptions.get(); - - return new CreateProjection(inner.getGrpcClient(), projectionName, query, options).execute(); - } - - /** - * Enables the projection. - * @param projectionName Name of the projection. - */ - public CompletableFuture enable(final String projectionName) { - return this.enable(projectionName, EnableProjectionOptions.get()); - } - - /** - * Enables the projection. - * @param projectionName Name of the projection. - * @param options Additional options. - */ - public CompletableFuture enable(final String projectionName, EnableProjectionOptions options) { - return new EnableProjection(inner.getGrpcClient(), projectionName, options).execute(); - } - - /** - * Deletes the projection. - * @param projectionName Name of the projection. - */ - public CompletableFuture delete(final String projectionName) { - return this.delete(projectionName, DeleteProjectionOptions.get()); - } - - /** - * Deletes the projection. - * @param projectionName Name of the projection. - * @param options Additional options. - */ - public CompletableFuture delete(final String projectionName, DeleteProjectionOptions options) { - return new DeleteProjection(inner.getGrpcClient(), projectionName, options).execute(); - } - - /** - * Disables the projection. - * @param projectionName Name of the projection. - */ - public CompletableFuture disable(final String projectionName) { - return this.disable(projectionName, DisableProjectionOptions.get()); - } - - /** - * Disables the projection. - * @param projectionName Name of the projection. - * @param options Additional options. - */ - public CompletableFuture disable(final String projectionName, DisableProjectionOptions options) { - return new DisableProjection(inner.getGrpcClient(), projectionName, options).execute(); - } - - /** - * Gets the projection's result. - * @param projectionName Name of the projection. - * @param type Type of the class to construct for the result. - * @param The result type to return. - */ - public CompletableFuture getResult(final String projectionName, Class type) { - return getResult(projectionName, type, GetProjectionResultOptions.get()); - } - - /** - * Gets the projection's result. - * @param projectionName Name of the projection. - * @param type Type of the class to construct for the result. - * @param The result type to return. - */ - public CompletableFuture getResult(final String projectionName, Class type, GetProjectionResultOptions options) { - return new GetProjectionResult<>(inner.getGrpcClient(), projectionName, options, type).execute(); - } - - /** - * Gets the projection's result. - * @param projectionName Name of the projection. - * @param javaTypeFunction Factory method for constructing the return type. - * @param The result type to return. - */ - public CompletableFuture getResult(final String projectionName, - Function javaTypeFunction) { - return getResult(projectionName, javaTypeFunction, GetProjectionResultOptions.get()); - } - - /** - * Gets the projection's result. - * @param projectionName Name of the projection. - * @param javaTypeFunction Factory method for constructing the return type. - * @param The result type to return. - */ - public CompletableFuture getResult(final String projectionName, - Function javaTypeFunction, GetProjectionResultOptions options) { - return new GetProjectionResult(inner.getGrpcClient(), projectionName, options, javaTypeFunction).execute(); - } - - /** - * Gets the state of the projection. - * @param projectionName Name of the projection. - * @param type Type of the class to construct for the result. - * @param The result type to return. - */ - public CompletableFuture getState(final String projectionName, Class type) { - return getState(projectionName, type, GetProjectionStateOptions.get()); - } - - /** - * Gets the state of the projection. - * @param projectionName Name of the projection. - * @param type Type of the class to construct for the result. - * @param The result type to return. - */ - public CompletableFuture getState(final String projectionName, Class type, GetProjectionStateOptions options) { - return new GetProjectionState<>(inner.getGrpcClient(), projectionName, options, type).execute(); - } - - /** - * Gets the state of the projection. - * @param projectionName Name of the projection. - * @param javaTypeFunction Factory method for constructing the return type. - * @param The result type to return. - */ - public CompletableFuture getState(final String projectionName, - Function javaTypeFunction) { - return getState(projectionName, javaTypeFunction, GetProjectionStateOptions.get()); - } - - /** - * Gets the state of the projection. - * @param projectionName Name of the projection. - * @param javaTypeFunction Factory method for constructing the return type. - * @param The result type to return. - */ - public CompletableFuture getState(final String projectionName, - Function javaTypeFunction, GetProjectionStateOptions options) { - return new GetProjectionState(inner.getGrpcClient(), projectionName, options, javaTypeFunction).execute(); - } - - /** - * Gets the statistics for the projection. - * @param projectionName Name of the projection. - */ - public CompletableFuture getStatistics(final String projectionName) { - return this.getStatistics(projectionName, GetProjectionStatisticsOptions.get()); - } - - /** - * Gets the statistics for the projection. - * @param projectionName Name of the projection. - * @param options Additional options. - */ - public CompletableFuture getStatistics(final String projectionName, GetProjectionStatisticsOptions options) { - return new GetProjectionStatistics(inner.getGrpcClient(), projectionName, options).execute(); - } - - /** - * Gets the projection's current status. - * @param projectionName Name of the projection. - */ - public CompletableFuture getStatus(final String projectionName) { - return this.getStatus(projectionName, GetProjectionStatusOptions.get()); - } - - /** - * Gets the projection's current status. - * @param projectionName Name of the projection. - * @param options Additional options. - */ - public CompletableFuture getStatus(final String projectionName, final GetProjectionStatusOptions options) { - return new GetProjectionStatus(inner.getGrpcClient(), projectionName, options).execute(); - } - - /** - * Lists all continuous projections. - */ - public CompletableFuture> list() { - return list(ListProjectionsOptions.get()); - } - - /** - * Lists all continuous projections. - * @param options Additional options. - */ - public CompletableFuture> list(ListProjectionsOptions options) { - return new ListProjections(inner.getGrpcClient(), options).execute().thenApply(ListProjectionsResult::getProjections); - } - - /** - * Resets the projection, causing it to start again from the beginning of the stream/s it selects from. - * Resetting a projection will truncate all emitted streams and re-emit all events. - * @param projectionName Name of the projection. - */ - public CompletableFuture reset(final String projectionName) { - return this.reset(projectionName, ResetProjectionOptions.get()); - } - - /** - * Resets the projection, causing it to start again from the beginning of the stream/s it selects from. - * Resetting a projection will truncate all emitted streams and re-emit all events. - * @param projectionName Name of the projection. - * @param options Additional options. - */ - public CompletableFuture reset(final String projectionName, ResetProjectionOptions options) { - return new ResetProjection(inner.getGrpcClient(), projectionName, options).execute(); - } - - /** - * Restarts the projection subsystem. This can be used to recover from certain kinds of errors. - */ - public CompletableFuture restartSubsystem() { - return this.restartSubsystem(RestartProjectionSubsystemOptions.get()); - } - - /** - * Restarts the projection subsystem. This can be used to recover from certain kinds of errors. - * @param options Additional options. - */ - public CompletableFuture restartSubsystem(RestartProjectionSubsystemOptions options) { - return new RestartProjectionSubsystem(inner.getGrpcClient(), options).execute(); - } - - /** - * Updates the projection's query and emit options. - * @param projectionName Name of the projection. - * @param query The JavaScript projection. - */ - public CompletableFuture update(final String projectionName, final String query) { - return this.update(projectionName, query, UpdateProjectionOptions.get()); - } - - /** - * Updates the projection's query and emit options. - * @param projectionName Name of the projection. - * @param query The JavaScript projection. - * @param options Additional options. - */ - public CompletableFuture update(final String projectionName, final String query, UpdateProjectionOptions options) { - return new UpdateProjection(inner.getGrpcClient(), projectionName, query, options).execute(); - } - - /** - * Closes a connection and cleans all its allocated resources. - */ - public CompletableFuture shutdown() { - return inner.shutdown(); - } - - /** - * Checks if this client instance has been shutdown. - * After shutdown a client instance can no longer process new operations and - * a new client instance has to be created. - * @return {@code true} if client instance has been shutdown. - */ - public boolean isShutdown() { - return inner.isShutdown(); - } -} +package io.trogonstack.eventstore.client; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.type.TypeFactory; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; + +/** + * Represents a TrogonEventStore client for projection management. A client instance maintains two-way communication with TrogonEventStore. + * Many threads can use the TrogonEventStore client simultaneously, or a single thread can make many asynchronous requests. + */ +public class TrogonEventStoreProjectionManagementClient { + final TrogonEventStoreClientBase inner; + private TrogonEventStoreProjectionManagementClient(TrogonEventStoreClientSettings settings) { + inner = new TrogonEventStoreClientBase(settings); + } + + private TrogonEventStoreProjectionManagementClient(TrogonEventStoreClientBase inner) { + this.inner = inner; + } + + /** + * Returns the Projection Management client based on the settings. + * @param settings The settings to use for constructing the client. + */ + public static TrogonEventStoreProjectionManagementClient create(TrogonEventStoreClientSettings settings) { + return new TrogonEventStoreProjectionManagementClient(settings); + } + + /** + * Returns a Projection Management client based on existing client. + * @param existingClient Existing client. + */ + public static TrogonEventStoreProjectionManagementClient from(TrogonEventStoreClientBase existingClient) { + return new TrogonEventStoreProjectionManagementClient(existingClient); + } + + /** + * Stops the projection without writing a checkpoint. + * This can be used to disable a projection that has been faulted. + * @param projectionName Name of the projection. + */ + public CompletableFuture abort(final String projectionName) { + return this.abort(projectionName, AbortProjectionOptions.get()); + } + + /** + * Stops the projection without writing a checkpoint. + * This can be used to disable a projection that has been faulted. + * @param projectionName Name of the projection. + * @param options Additional options. + */ + public CompletableFuture abort(final String projectionName, AbortProjectionOptions options) { + return new AbortProjection(inner.getGrpcClient(), projectionName, options).execute(); + } + + /** + * Creates a new projection in the stopped state. Enable needs to be called separately to start the projection. + * @param projectionName Name of the projection. + * @param query The JavaScript projection. + */ + public CompletableFuture create(final String projectionName, final String query) { + return this.create(projectionName, query, CreateProjectionOptions.get()); + } + + /** + * Creates a new projection in the stopped state. Enable needs to be called separately to start the projection. + * @param projectionName Name of the projection. + * @param query The JavaScript projection. + * @param options Additional options. + */ + public CompletableFuture create(final String projectionName, final String query, CreateProjectionOptions options) { + if (options == null) + options = CreateProjectionOptions.get(); + + return new CreateProjection(inner.getGrpcClient(), projectionName, query, options).execute(); + } + + /** + * Enables the projection. + * @param projectionName Name of the projection. + */ + public CompletableFuture enable(final String projectionName) { + return this.enable(projectionName, EnableProjectionOptions.get()); + } + + /** + * Enables the projection. + * @param projectionName Name of the projection. + * @param options Additional options. + */ + public CompletableFuture enable(final String projectionName, EnableProjectionOptions options) { + return new EnableProjection(inner.getGrpcClient(), projectionName, options).execute(); + } + + /** + * Deletes the projection. + * @param projectionName Name of the projection. + */ + public CompletableFuture delete(final String projectionName) { + return this.delete(projectionName, DeleteProjectionOptions.get()); + } + + /** + * Deletes the projection. + * @param projectionName Name of the projection. + * @param options Additional options. + */ + public CompletableFuture delete(final String projectionName, DeleteProjectionOptions options) { + return new DeleteProjection(inner.getGrpcClient(), projectionName, options).execute(); + } + + /** + * Disables the projection. + * @param projectionName Name of the projection. + */ + public CompletableFuture disable(final String projectionName) { + return this.disable(projectionName, DisableProjectionOptions.get()); + } + + /** + * Disables the projection. + * @param projectionName Name of the projection. + * @param options Additional options. + */ + public CompletableFuture disable(final String projectionName, DisableProjectionOptions options) { + return new DisableProjection(inner.getGrpcClient(), projectionName, options).execute(); + } + + /** + * Gets the projection's result. + * @param projectionName Name of the projection. + * @param type Type of the class to construct for the result. + * @param The result type to return. + */ + public CompletableFuture getResult(final String projectionName, Class type) { + return getResult(projectionName, type, GetProjectionResultOptions.get()); + } + + /** + * Gets the projection's result. + * @param projectionName Name of the projection. + * @param type Type of the class to construct for the result. + * @param The result type to return. + */ + public CompletableFuture getResult(final String projectionName, Class type, GetProjectionResultOptions options) { + return new GetProjectionResult<>(inner.getGrpcClient(), projectionName, options, type).execute(); + } + + /** + * Gets the projection's result. + * @param projectionName Name of the projection. + * @param javaTypeFunction Factory method for constructing the return type. + * @param The result type to return. + */ + public CompletableFuture getResult(final String projectionName, + Function javaTypeFunction) { + return getResult(projectionName, javaTypeFunction, GetProjectionResultOptions.get()); + } + + /** + * Gets the projection's result. + * @param projectionName Name of the projection. + * @param javaTypeFunction Factory method for constructing the return type. + * @param The result type to return. + */ + public CompletableFuture getResult(final String projectionName, + Function javaTypeFunction, GetProjectionResultOptions options) { + return new GetProjectionResult(inner.getGrpcClient(), projectionName, options, javaTypeFunction).execute(); + } + + /** + * Gets the state of the projection. + * @param projectionName Name of the projection. + * @param type Type of the class to construct for the result. + * @param The result type to return. + */ + public CompletableFuture getState(final String projectionName, Class type) { + return getState(projectionName, type, GetProjectionStateOptions.get()); + } + + /** + * Gets the state of the projection. + * @param projectionName Name of the projection. + * @param type Type of the class to construct for the result. + * @param The result type to return. + */ + public CompletableFuture getState(final String projectionName, Class type, GetProjectionStateOptions options) { + return new GetProjectionState<>(inner.getGrpcClient(), projectionName, options, type).execute(); + } + + /** + * Gets the state of the projection. + * @param projectionName Name of the projection. + * @param javaTypeFunction Factory method for constructing the return type. + * @param The result type to return. + */ + public CompletableFuture getState(final String projectionName, + Function javaTypeFunction) { + return getState(projectionName, javaTypeFunction, GetProjectionStateOptions.get()); + } + + /** + * Gets the state of the projection. + * @param projectionName Name of the projection. + * @param javaTypeFunction Factory method for constructing the return type. + * @param The result type to return. + */ + public CompletableFuture getState(final String projectionName, + Function javaTypeFunction, GetProjectionStateOptions options) { + return new GetProjectionState(inner.getGrpcClient(), projectionName, options, javaTypeFunction).execute(); + } + + /** + * Gets the statistics for the projection. + * @param projectionName Name of the projection. + */ + public CompletableFuture getStatistics(final String projectionName) { + return this.getStatistics(projectionName, GetProjectionStatisticsOptions.get()); + } + + /** + * Gets the statistics for the projection. + * @param projectionName Name of the projection. + * @param options Additional options. + */ + public CompletableFuture getStatistics(final String projectionName, GetProjectionStatisticsOptions options) { + return new GetProjectionStatistics(inner.getGrpcClient(), projectionName, options).execute(); + } + + /** + * Gets the projection's current status. + * @param projectionName Name of the projection. + */ + public CompletableFuture getStatus(final String projectionName) { + return this.getStatus(projectionName, GetProjectionStatusOptions.get()); + } + + /** + * Gets the projection's current status. + * @param projectionName Name of the projection. + * @param options Additional options. + */ + public CompletableFuture getStatus(final String projectionName, final GetProjectionStatusOptions options) { + return new GetProjectionStatus(inner.getGrpcClient(), projectionName, options).execute(); + } + + /** + * Lists all continuous projections. + */ + public CompletableFuture> list() { + return list(ListProjectionsOptions.get()); + } + + /** + * Lists all continuous projections. + * @param options Additional options. + */ + public CompletableFuture> list(ListProjectionsOptions options) { + return new ListProjections(inner.getGrpcClient(), options).execute().thenApply(ListProjectionsResult::getProjections); + } + + /** + * Resets the projection, causing it to start again from the beginning of the stream/s it selects from. + * Resetting a projection will truncate all emitted streams and re-emit all events. + * @param projectionName Name of the projection. + */ + public CompletableFuture reset(final String projectionName) { + return this.reset(projectionName, ResetProjectionOptions.get()); + } + + /** + * Resets the projection, causing it to start again from the beginning of the stream/s it selects from. + * Resetting a projection will truncate all emitted streams and re-emit all events. + * @param projectionName Name of the projection. + * @param options Additional options. + */ + public CompletableFuture reset(final String projectionName, ResetProjectionOptions options) { + return new ResetProjection(inner.getGrpcClient(), projectionName, options).execute(); + } + + /** + * Restarts the projection subsystem. This can be used to recover from certain kinds of errors. + */ + public CompletableFuture restartSubsystem() { + return this.restartSubsystem(RestartProjectionSubsystemOptions.get()); + } + + /** + * Restarts the projection subsystem. This can be used to recover from certain kinds of errors. + * @param options Additional options. + */ + public CompletableFuture restartSubsystem(RestartProjectionSubsystemOptions options) { + return new RestartProjectionSubsystem(inner.getGrpcClient(), options).execute(); + } + + /** + * Updates the projection's query and emit options. + * @param projectionName Name of the projection. + * @param query The JavaScript projection. + */ + public CompletableFuture update(final String projectionName, final String query) { + return this.update(projectionName, query, UpdateProjectionOptions.get()); + } + + /** + * Updates the projection's query and emit options. + * @param projectionName Name of the projection. + * @param query The JavaScript projection. + * @param options Additional options. + */ + public CompletableFuture update(final String projectionName, final String query, UpdateProjectionOptions options) { + return new UpdateProjection(inner.getGrpcClient(), projectionName, query, options).execute(); + } + + /** + * Closes a connection and cleans all its allocated resources. + */ + public CompletableFuture shutdown() { + return inner.shutdown(); + } + + /** + * Checks if this client instance has been shutdown. + * After shutdown a client instance can no longer process new operations and + * a new client instance has to be created. + * @return {@code true} if client instance has been shutdown. + */ + public boolean isShutdown() { + return inner.isShutdown(); + } +} diff --git a/src/main/java/io/kurrent/dbclient/Tuple.java b/src/main/java/io/trogonstack/eventstore/client/Tuple.java similarity index 86% rename from src/main/java/io/kurrent/dbclient/Tuple.java rename to src/main/java/io/trogonstack/eventstore/client/Tuple.java index feccbfd..db0f55f 100644 --- a/src/main/java/io/kurrent/dbclient/Tuple.java +++ b/src/main/java/io/trogonstack/eventstore/client/Tuple.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; class Tuple { private final A _1; diff --git a/src/main/java/io/kurrent/dbclient/UnsupportedFeatureException.java b/src/main/java/io/trogonstack/eventstore/client/UnsupportedFeatureException.java similarity index 58% rename from src/main/java/io/kurrent/dbclient/UnsupportedFeatureException.java rename to src/main/java/io/trogonstack/eventstore/client/UnsupportedFeatureException.java index 7989978..b34b268 100644 --- a/src/main/java/io/kurrent/dbclient/UnsupportedFeatureException.java +++ b/src/main/java/io/trogonstack/eventstore/client/UnsupportedFeatureException.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** - * A request not supported by the targeted KurrentDB node was sent. + * A request not supported by the targeted TrogonEventStore node was sent. */ public class UnsupportedFeatureException extends RuntimeException { UnsupportedFeatureException(){ diff --git a/src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToAll.java b/src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToAll.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToAll.java rename to src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToAll.java index 7121387..017a0e9 100644 --- a/src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToAll.java +++ b/src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToAll.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; class UpdatePersistentSubscriptionToAll extends AbstractUpdatePersistentSubscription { private final UpdatePersistentSubscriptionToAllOptions options; diff --git a/src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToAllOptions.java b/src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToAllOptions.java similarity index 98% rename from src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToAllOptions.java rename to src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToAllOptions.java index 6cf6b33..eb93858 100644 --- a/src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToAllOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToAllOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the update persistent subscription to $all stream request. diff --git a/src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToStream.java b/src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToStream.java similarity index 91% rename from src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToStream.java rename to src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToStream.java index 81009e8..1c9a14e 100644 --- a/src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToStream.java +++ b/src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToStream.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.persistentsubscriptions.Persistent; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.persistentsubscriptions.Persistent; +import io.trogonstack.eventstore.client.proto.shared.Shared; import com.google.protobuf.ByteString; class UpdatePersistentSubscriptionToStream extends AbstractUpdatePersistentSubscription { diff --git a/src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToStreamOptions.java b/src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToStreamOptions.java similarity index 97% rename from src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToStreamOptions.java rename to src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToStreamOptions.java index 2224321..a7766b3 100644 --- a/src/main/java/io/kurrent/dbclient/UpdatePersistentSubscriptionToStreamOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/UpdatePersistentSubscriptionToStreamOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the update persistent subscription to stream request. diff --git a/src/main/java/io/kurrent/dbclient/UpdateProjection.java b/src/main/java/io/trogonstack/eventstore/client/UpdateProjection.java similarity index 87% rename from src/main/java/io/kurrent/dbclient/UpdateProjection.java rename to src/main/java/io/trogonstack/eventstore/client/UpdateProjection.java index 9edd08d..3a10e37 100644 --- a/src/main/java/io/kurrent/dbclient/UpdateProjection.java +++ b/src/main/java/io/trogonstack/eventstore/client/UpdateProjection.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.proto.projections.Projectionmanagement; -import io.kurrent.dbclient.proto.projections.ProjectionsGrpc; -import io.kurrent.dbclient.proto.shared.Shared; +import io.trogonstack.eventstore.client.proto.projections.Projectionmanagement; +import io.trogonstack.eventstore.client.proto.projections.ProjectionsGrpc; +import io.trogonstack.eventstore.client.proto.shared.Shared; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/io/kurrent/dbclient/UpdateProjectionOptions.java b/src/main/java/io/trogonstack/eventstore/client/UpdateProjectionOptions.java similarity index 93% rename from src/main/java/io/kurrent/dbclient/UpdateProjectionOptions.java rename to src/main/java/io/trogonstack/eventstore/client/UpdateProjectionOptions.java index 07769c6..059b765 100644 --- a/src/main/java/io/kurrent/dbclient/UpdateProjectionOptions.java +++ b/src/main/java/io/trogonstack/eventstore/client/UpdateProjectionOptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Options of the update projection request. diff --git a/src/main/java/io/kurrent/dbclient/UserCredentials.java b/src/main/java/io/trogonstack/eventstore/client/UserCredentials.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/UserCredentials.java rename to src/main/java/io/trogonstack/eventstore/client/UserCredentials.java index cb0ed84..1156aa6 100644 --- a/src/main/java/io/kurrent/dbclient/UserCredentials.java +++ b/src/main/java/io/trogonstack/eventstore/client/UserCredentials.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.nio.charset.StandardCharsets; import java.util.Base64; diff --git a/src/main/java/io/kurrent/dbclient/UserStreamAcl.java b/src/main/java/io/trogonstack/eventstore/client/UserStreamAcl.java similarity index 94% rename from src/main/java/io/kurrent/dbclient/UserStreamAcl.java rename to src/main/java/io/trogonstack/eventstore/client/UserStreamAcl.java index d996ba4..7238065 100644 --- a/src/main/java/io/kurrent/dbclient/UserStreamAcl.java +++ b/src/main/java/io/trogonstack/eventstore/client/UserStreamAcl.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; /** * Default user stream access control list (ACL). diff --git a/src/main/java/io/kurrent/dbclient/WorkItem.java b/src/main/java/io/trogonstack/eventstore/client/WorkItem.java similarity index 64% rename from src/main/java/io/kurrent/dbclient/WorkItem.java rename to src/main/java/io/trogonstack/eventstore/client/WorkItem.java index b6c6de4..b842842 100644 --- a/src/main/java/io/kurrent/dbclient/WorkItem.java +++ b/src/main/java/io/trogonstack/eventstore/client/WorkItem.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; interface WorkItem { void accept(WorkItemArgs args, Exception error); diff --git a/src/main/java/io/kurrent/dbclient/WorkItemArgs.java b/src/main/java/io/trogonstack/eventstore/client/WorkItemArgs.java similarity index 95% rename from src/main/java/io/kurrent/dbclient/WorkItemArgs.java rename to src/main/java/io/trogonstack/eventstore/client/WorkItemArgs.java index 2ee246f..c717dd2 100644 --- a/src/main/java/io/kurrent/dbclient/WorkItemArgs.java +++ b/src/main/java/io/trogonstack/eventstore/client/WorkItemArgs.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.ManagedChannel; @@ -46,7 +46,7 @@ public boolean supportFeature(int feature) { return info != null && info.supportFeature(feature); } - public
HttpURLConnection getHttpConnection(OptionsBase options, KurrentDBClientSettings settings, String path) { + public HttpURLConnection getHttpConnection(OptionsBase options, TrogonEventStoreClientSettings settings, String path) { try { HttpURLConnection conn = (HttpURLConnection) getURL(settings.isTls(), this.endpoint, path).openConnection(); conn.setRequestProperty("Accept", ContentType.JSON); diff --git a/src/main/java/io/kurrent/dbclient/WriteResult.java b/src/main/java/io/trogonstack/eventstore/client/WriteResult.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/WriteResult.java rename to src/main/java/io/trogonstack/eventstore/client/WriteResult.java index b4feada..299d932 100644 --- a/src/main/java/io/kurrent/dbclient/WriteResult.java +++ b/src/main/java/io/trogonstack/eventstore/client/WriteResult.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Objects; diff --git a/src/main/java/io/kurrent/dbclient/WrongExpectedVersionException.java b/src/main/java/io/trogonstack/eventstore/client/WrongExpectedVersionException.java similarity index 96% rename from src/main/java/io/kurrent/dbclient/WrongExpectedVersionException.java rename to src/main/java/io/trogonstack/eventstore/client/WrongExpectedVersionException.java index 06dab32..7e3df7d 100644 --- a/src/main/java/io/kurrent/dbclient/WrongExpectedVersionException.java +++ b/src/main/java/io/trogonstack/eventstore/client/WrongExpectedVersionException.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import javax.validation.constraints.NotNull; diff --git a/src/main/java/io/kurrent/dbclient/resolution/DeferredNodeResolution.java b/src/main/java/io/trogonstack/eventstore/client/resolution/DeferredNodeResolution.java similarity index 81% rename from src/main/java/io/kurrent/dbclient/resolution/DeferredNodeResolution.java rename to src/main/java/io/trogonstack/eventstore/client/resolution/DeferredNodeResolution.java index 337239b..a89814d 100644 --- a/src/main/java/io/kurrent/dbclient/resolution/DeferredNodeResolution.java +++ b/src/main/java/io/trogonstack/eventstore/client/resolution/DeferredNodeResolution.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.resolution; +package io.trogonstack.eventstore.client.resolution; -import io.kurrent.dbclient.Endpoint; +import io.trogonstack.eventstore.client.Endpoint; import java.net.InetSocketAddress; import java.util.Collections; diff --git a/src/main/java/io/kurrent/dbclient/resolution/DeprecatedNodeResolution.java b/src/main/java/io/trogonstack/eventstore/client/resolution/DeprecatedNodeResolution.java similarity index 88% rename from src/main/java/io/kurrent/dbclient/resolution/DeprecatedNodeResolution.java rename to src/main/java/io/trogonstack/eventstore/client/resolution/DeprecatedNodeResolution.java index be343fb..4a90976 100644 --- a/src/main/java/io/kurrent/dbclient/resolution/DeprecatedNodeResolution.java +++ b/src/main/java/io/trogonstack/eventstore/client/resolution/DeprecatedNodeResolution.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.resolution; +package io.trogonstack.eventstore.client.resolution; -import io.kurrent.dbclient.Endpoint; +import io.trogonstack.eventstore.client.Endpoint; import java.net.InetAddress; import java.net.InetSocketAddress; diff --git a/src/main/java/io/kurrent/dbclient/resolution/FixedSeedsNodeResolution.java b/src/main/java/io/trogonstack/eventstore/client/resolution/FixedSeedsNodeResolution.java similarity index 85% rename from src/main/java/io/kurrent/dbclient/resolution/FixedSeedsNodeResolution.java rename to src/main/java/io/trogonstack/eventstore/client/resolution/FixedSeedsNodeResolution.java index 3118a76..9c00471 100644 --- a/src/main/java/io/kurrent/dbclient/resolution/FixedSeedsNodeResolution.java +++ b/src/main/java/io/trogonstack/eventstore/client/resolution/FixedSeedsNodeResolution.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.resolution; +package io.trogonstack.eventstore.client.resolution; -import io.kurrent.dbclient.Endpoint; +import io.trogonstack.eventstore.client.Endpoint; import java.net.InetSocketAddress; import java.util.ArrayList; diff --git a/src/main/java/io/kurrent/dbclient/resolution/NodeResolution.java b/src/main/java/io/trogonstack/eventstore/client/resolution/NodeResolution.java similarity index 71% rename from src/main/java/io/kurrent/dbclient/resolution/NodeResolution.java rename to src/main/java/io/trogonstack/eventstore/client/resolution/NodeResolution.java index b3169e9..0ea2793 100644 --- a/src/main/java/io/kurrent/dbclient/resolution/NodeResolution.java +++ b/src/main/java/io/trogonstack/eventstore/client/resolution/NodeResolution.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient.resolution; +package io.trogonstack.eventstore.client.resolution; import java.net.InetSocketAddress; import java.util.List; diff --git a/src/main/proto/kurrentdb/protocol/v1/serverfeatures.proto b/src/main/proto/kurrentdb/protocol/v1/serverfeatures.proto deleted file mode 100644 index 38b1ecf..0000000 --- a/src/main/proto/kurrentdb/protocol/v1/serverfeatures.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; -package event_store.client.server_features; -option java_package = "io.kurrent.dbclient.proto.serverfeatures"; -import "kurrentdb/protocol/v1/shared.proto"; - -service ServerFeatures { - rpc GetSupportedMethods (event_store.client.Empty) returns (SupportedMethods); -} - -message SupportedMethods { - repeated SupportedMethod methods = 1; - string event_store_server_version = 2; -} - -message SupportedMethod { - string method_name = 1; - string service_name = 2; - repeated string features = 3; -} diff --git a/src/main/proto/kurrentdb/protocol/v2/errors.proto b/src/main/proto/kurrentdb/protocol/v2/errors.proto deleted file mode 100644 index 5c9421c..0000000 --- a/src/main/proto/kurrentdb/protocol/v2/errors.proto +++ /dev/null @@ -1,155 +0,0 @@ -// ****************************************************************************************** -// This protocol is UNSTABLE in the sense of being subject to change. -// ****************************************************************************************** - -syntax = "proto3"; - -package kurrent.rpc; - -option go_package = "github.com/kurrent-io/KurrentDB-Client-Go/protos/kurrentdb/protocols/v2/common/errors"; -option csharp_namespace = "KurrentDB.Protocol.V2.Common.Errors"; -option java_package = "io.kurrentdb.protocol.v2.common.errors"; -option java_multiple_files = true; - -import "kurrentdb/protocol/v2/rpc.proto"; - -// The canonical server error codes for the Kurrent Platform gRPC APIs. -// These errors represent common failure modes across all Kurrent services. -enum ServerError { - // Default value. This value is not used. - // An error code MUST always be set to a non-zero value. - // If an error code is not explicitly set, it MUST be treated as - // an internal server error (INTERNAL). - UNSPECIFIED = 0; - - // Authentication or authorization failure. - // The client lacks valid credentials or sufficient permissions to perform the requested operation. - // - // Common causes: - // - Missing or invalid authentication tokens - // - Insufficient permissions for the operation - // - Expired credentials - // - // Client action: Check credentials, verify permissions, and re-authenticate if necessary. - // Not retriable without fixing the underlying authorization issue. - SERVER_ERROR_ACCESS_DENIED = 1 [(kurrent.rpc.error) = { - status_code: PERMISSION_DENIED, - has_details: true - }]; - - // The request is malformed or contains invalid data. - // The server cannot process the request due to client error. - // - // Common causes: - // - Invalid field values (e.g., empty required fields, out-of-range numbers) - // - Malformed data formats - // - Validation failures - // - // Client action: Fix the request data and retry. - // Not retriable without modifying the request. - SERVER_ERROR_BAD_REQUEST = 2 [(kurrent.rpc.error) = { - status_code: INVALID_ARGUMENT, - has_details: true - }]; - - // The server is not the cluster leader and cannot process write operations. - // In a clustered deployment, only the leader node can accept write operations. - // - // Common causes: - // - Client connected to a follower node - // - Leader election in progress - // - Network partition - // - // Client action: Redirect the request to the leader node indicated in the error details. - // Retriable after redirecting to the correct leader node. - SERVER_ERROR_NOT_LEADER_NODE = 5 [(kurrent.rpc.error) = { - status_code: FAILED_PRECONDITION, - has_details: true - }]; - - // The operation did not complete within the configured timeout period. - // - // Common causes: - // - Slow disk I/O during writes - // - Cluster consensus delays - // - Network latency - // - Heavy server load - // - // Client action: Retry with exponential backoff. Consider increasing timeout values. - // Retriable - the operation may succeed on retry. - SERVER_ERROR_OPERATION_TIMEOUT = 6 [(kurrent.rpc.error) = { - status_code: DEADLINE_EXCEEDED - }]; - - // The server is starting up or shutting down and cannot process requests. - // - // Common causes: - // - Server is initializing (loading indexes, recovering state) - // - Server is performing graceful shutdown - // - Server is performing maintenance operations - // - // Client action: Retry with exponential backoff. Wait for server to become ready. - // Retriable - the server will become available after initialization completes. - SERVER_ERROR_SERVER_NOT_READY = 7 [(kurrent.rpc.error) = { - status_code: UNAVAILABLE - }]; - - // The server is temporarily overloaded and cannot accept more requests. - // This is a backpressure mechanism to prevent server overload. - // - // Common causes: - // - Too many concurrent requests - // - Resource exhaustion (CPU, memory, disk I/O) - // - Rate limiting triggered - // - // Client action: Retry with exponential backoff. Reduce request rate. - // Retriable - the server may accept requests after load decreases. - SERVER_ERROR_SERVER_OVERLOADED = 8 [(kurrent.rpc.error) = { - status_code: UNAVAILABLE - }]; - - // An internal server error occurred. - // This indicates a bug or unexpected condition in the server. - // - // Common causes: - // - Unhandled exceptions - // - Assertion failures - // - Corrupted internal state - // - Programming errors - // - // Client action: Report to server administrators with request details. - // May be retriable, but likely indicates a server-side issue requiring investigation. - SERVER_ERROR_SERVER_MALFUNCTION = 9 [(kurrent.rpc.error) = { - status_code: INTERNAL - }]; -} - -// Details for ACCESS_DENIED errors. -message AccessDeniedErrorDetails { - // The friendly name of the operation that was denied. - string operation = 1; - - // The username of the user who was denied access. - optional string username = 2; - - // The permission that was required for this operation. - optional string permission = 3; -} - -// Details for NOT_LEADER_NODE errors. -message NotLeaderNodeErrorDetails { - // Information about the current cluster leader node. - NodeInfo current_leader = 1; - - // Information about a cluster node. - message NodeInfo { - // The hostname or IP address of the node. - string host = 1; - - // The gRPC port of the node. - int32 port = 2; - - // The unique instance ID of the node. - optional string node_id = 3; - } -} diff --git a/src/main/proto/kurrentdb/protocol/v2/rpc.proto b/src/main/proto/kurrentdb/protocol/v2/rpc.proto deleted file mode 100644 index 18197e7..0000000 --- a/src/main/proto/kurrentdb/protocol/v2/rpc.proto +++ /dev/null @@ -1,77 +0,0 @@ -// ****************************************************************************************** -// This protocol is UNSTABLE in the sense of being subject to change. -// ****************************************************************************************** - -syntax = "proto3"; - -package kurrent.rpc; - -option go_package = "github.com/kurrent-io/KurrentDB-Client-Go/protos/rpc"; -option csharp_namespace = "Kurrent.Rpc"; -option java_package = "io.kurrent.rpc"; -option java_multiple_files = true; - -import "google/protobuf/descriptor.proto"; -import "google/rpc/code.proto"; - -// ErrorMetadata provides actionable information for error enum values to enable automated -// code generation, documentation, and consistent error handling across the Kurrent platform. -// -// It was modeled to support a single details type per error code to simplify code generation and -// validation. If multiple detail types are needed for a single error code, consider defining -// separate error codes for each detail type. Or, use a union type (oneof) in the detail message -// to encapsulate multiple detail variants within a single detail message. -// -// More however DebugInfo and RetryInfo can and should be added to any error regardless of -// this setting, when applicable. -// -// This annotation is applied to enum values using the google.protobuf.EnumValueOptions -// extension mechanism. It enables: -// - Automatic gRPC status code mapping -// - Code generation for error handling utilities -// - Documentation generation -// - Type-safe error detail validation -// -// Usage Example: -// enum StreamErrorCode { -// REVISION_CONFLICT = 5 [(kurrent.rpc.error) = { -// status_code: FAILED_PRECONDITION, -// has_details: true -// }]; -// } -// -// See individual field documentation for conventions and defaults. -message ErrorMetadata { - // Maps the error to a standard gRPC status code for transport-level compatibility. - // This field is REQUIRED for every error annotation. - // - // Use standard gRPC status codes from `google.rpc.code`. - // - // Code generators use this to: - // - Map errors to gRPC status codes automatically - // - Generate HTTP status code mappings - // - Create transport-agnostic error handling - google.rpc.Code status_code = 1; - - // Indicates whether this error supports rich, typed detail messages. - // Defaults to false (simple message string only). - // The message type name must be derived from the enum name by convention. - // Mask: {EnumValue}ErrorDetails, {EnumValue}Error, {EnumValue} - // - // Examples: - // ACCESS_DENIED -> "AccessDeniedErrorDetails", "AccessDeniedError" or "AccessDenied" - // SERVER_NOT_READY -> "ServerNotReadyErrorDetails", "ServerNotReadyError" or "ServerNotReady" - // - // Code generators use the message type name to: - // - Validate that the detail message matches the expected type - // - Generate type-safe error handling code - // - Create accurate documentation - bool has_details = 2; -} - -// Extend EnumValueOptions to include error information for enum values -extend google.protobuf.EnumValueOptions { - // Provides additional information about error conditions for automated - // code generation and documentation. - optional ErrorMetadata error = 2113; -} diff --git a/src/main/proto/kurrentdb/protocol/v2/streams/errors.proto b/src/main/proto/kurrentdb/protocol/v2/streams/errors.proto deleted file mode 100644 index 313252e..0000000 --- a/src/main/proto/kurrentdb/protocol/v2/streams/errors.proto +++ /dev/null @@ -1,263 +0,0 @@ -// ****************************************************************************************** -// This protocol is UNSTABLE in the sense of being subject to change. -// ****************************************************************************************** - -syntax = "proto3"; - -package kurrentdb.protocol.v2.streams.errors; - -option go_package = "github.com/kurrent-io/KurrentDB-Client-Go/protos/kurrentdb/protocols/v2/streams"; -option csharp_namespace = "KurrentDB.Protocol.V2.Streams.Errors"; -option java_package = "io.kurrentdb.protocol.v2.streams.errors"; -option java_multiple_files = true; - -import "kurrentdb/protocol/v2/rpc.proto"; - -// Error codes specific to the Streams API. -// These errors represent failure modes when working with streams of records. -enum StreamsError { - // Default value. This value is not used. - // An error code MUST always be set to a non-zero value. - // If an error code is not explicitly set, it MUST be treated as - // an internal server error (INTERNAL). - STREAMS_ERROR_UNSPECIFIED = 0; - - // The requested stream does not exist in the database. - // - // Common causes: - // - Stream name typo or incorrect stream identifier - // - Stream was never created (no events appended yet) - // - Stream was deleted and not yet recreated - // - // Client action: Verify the stream name is correct. Create the stream by appending to it. - // Recoverable by creating the stream first (append with NO_STREAM expected revision). - STREAMS_ERROR_STREAM_NOT_FOUND = 1 [(kurrent.rpc.error) = { - status_code: NOT_FOUND, - has_details: true, - }]; - - // The stream already exists when an operation expected it not to exist. - // - // Common causes: - // - Attempting to create a stream that already has events - // - Using NO_STREAM expected revision on an existing stream - // - Race condition with concurrent stream creation - // - // Client action: Use the existing stream or use a different expected revision. - // Recoverable by adjusting the expected revision or using the existing stream. - STREAMS_ERROR_STREAM_ALREADY_EXISTS = 2 [(kurrent.rpc.error) = { - status_code: ALREADY_EXISTS, - has_details: true - }]; - - // The stream has been soft deleted. - // Soft-deleted streams are hidden from stream lists but can be restored by appending to them. - // - // Common causes: - // - Stream was explicitly soft-deleted via delete operation - // - Attempting to read from a soft-deleted stream - // - // Client action: Restore the stream by appending new events, or accept that the stream is deleted. - // Recoverable by appending to the stream to restore it. - STREAMS_ERROR_STREAM_DELETED = 3 [(kurrent.rpc.error) = { - status_code: FAILED_PRECONDITION, - has_details: true - }]; - - // The stream has been tombstoned (permanently deleted). - // Tombstoned streams cannot be restored and will never accept new events. - // - // Common causes: - // - Stream was explicitly tombstoned via tombstone operation - // - Administrative deletion of sensitive data - // - Attempting to write to or read from a tombstoned stream - // - // Client action: Stream is permanently removed. Create a new stream with a different name if needed. - // Not recoverable - the stream cannot be restored. - STREAMS_ERROR_STREAM_TOMBSTONED = 4 [(kurrent.rpc.error) = { - status_code: FAILED_PRECONDITION, - has_details: true - }]; - - // The expected revision does not match the actual stream revision. - // This is an optimistic concurrency control failure. - // - // Common causes: - // - Another client modified the stream concurrently - // - Client has stale state about the stream revision - // - Race condition in distributed system - // - // Client action: Fetch the current stream revision and retry with the correct expected revision. - // Recoverable by reading the current state and retrying with proper optimistic concurrency control. - STREAMS_ERROR_STREAM_REVISION_CONFLICT = 5 [(kurrent.rpc.error) = { - status_code: FAILED_PRECONDITION, - has_details: true - }]; - - // A single record being appended exceeds the maximum allowed size. - // - // Common causes: - // - Record payload is too large (exceeds server's max record size configuration) - // - Excessive metadata in properties - // - Large binary data without chunking - // - // Client action: Reduce record size, split large payloads across multiple records, or increase server limits. - // Recoverable by reducing record size or adjusting server configuration. - STREAMS_ERROR_APPEND_RECORD_SIZE_EXCEEDED = 6 [(kurrent.rpc.error) = { - status_code: INVALID_ARGUMENT, - has_details: true - }]; - - // The total size of all records in a single append session exceeds the maximum allowed transaction size. - // - // Common causes: - // - Too many records in a single append session - // - Combined payload size exceeds server's max transaction size - // - Attempting to write very large batches - // - // Client action: Split the append into multiple smaller transactions. - // Recoverable by reducing the number of records per append session. - STREAMS_ERROR_APPEND_TRANSACTION_SIZE_EXCEEDED = 7 [(kurrent.rpc.error) = { - status_code: ABORTED, - has_details: true - }]; - - // The same stream appears multiple times in a single append session. - // This is currently not supported to prevent complexity with expected revisions and ordering. - // - // Common causes: - // - Accidentally appending to the same stream twice in one session - // - Application logic error in batch operations - // - // Client action: Remove duplicate streams from the append session or split into multiple sessions. - // Recoverable by restructuring the append session to reference each stream only once. - STREAMS_ERROR_STREAM_ALREADY_IN_APPEND_SESSION = 8 [(kurrent.rpc.error) = { - status_code: ABORTED, - has_details: true - }]; - - // An append session was started but no append requests were sent before completing the stream. - // - // Common causes: - // - Client completed the stream without sending any AppendRequest messages - // - Application logic error - // - // Client action: Ensure at least one AppendRequest is sent before completing the stream. - // Recoverable by properly implementing the append session protocol. - STREAMS_ERROR_APPEND_SESSION_NO_REQUESTS = 9 [(kurrent.rpc.error) = { - status_code: FAILED_PRECONDITION - }]; - - // One or more consistency checks failed during an AppendRecords operation. - // The transaction is aborted — no records are written. - // - // Common causes: - // - A stream state check found the stream at a different revision than expected - // - A stream referenced in a state check does not exist, was deleted, or was tombstoned - // - // Client action: Inspect the AppendConsistencyViolationErrorDetails to determine which - // checks failed and why, then correct the request or refresh local state and retry. - // Recoverable by reading the current state and resubmitting with updated checks. - STREAMS_ERROR_APPEND_CONSISTENCY_VIOLATION = 14 [(kurrent.rpc.error) = { - status_code: FAILED_PRECONDITION, - has_details: true - }]; -} - -// Details for STREAM_NOT_FOUND errors. -message StreamNotFoundErrorDetails { - // The name of the stream that was not found. - string stream = 1; -} - -// Details for STREAM_ALREADY_EXISTS errors. -message StreamAlreadyExistsErrorDetails { - // The name of the stream that already exists. - string stream = 1; -} - -// Details for STREAM_DELETED errors. -message StreamDeletedErrorDetails { - // The name of the stream that was deleted. - string stream = 1; -} - -// Details for STREAM_TOMBSTONED errors. -message StreamTombstonedErrorDetails { - // The name of the stream that was tombstoned. - string stream = 1; -} - -// Details for STREAM_REVISION_CONFLICT errors. -message StreamRevisionConflictErrorDetails { - // The name of the stream that had a revision conflict. - string stream = 1; - - // The expected revision that was provided in the append request. - sint64 expected_revision = 2 [jstype = JS_STRING]; - - // The actual current revision of the stream. - sint64 actual_revision = 3 [jstype = JS_STRING]; -} - -// Details for APPEND_RECORD_SIZE_EXCEEDED errors. -message AppendRecordSizeExceededErrorDetails { - // The name of the stream where the append was attempted. - string stream = 1; - - // The identifier of the record that exceeded the size limit. - string record_id = 2; - - // The actual size of the record in bytes. - int32 size = 3; - - // The maximum allowed size of a single record in bytes. - int32 max_size = 4; -} - -// Details for APPEND_TRANSACTION_SIZE_EXCEEDED errors. -message AppendTransactionSizeExceededErrorDetails { - // The actual size of the transaction in bytes. - int32 size = 1; - - // The maximum allowed size of an append transaction in bytes. - int32 max_size = 2; -} - -// Details for STREAM_ALREADY_IN_APPEND_SESSION errors. -message StreamAlreadyInAppendSessionErrorDetails { - // The name of the stream that appears multiple times. - string stream = 1; -} - -// Details for APPEND_CONSISTENCY_VIOLATION errors. -// -// Contains all consistency checks that were violated during the append operation. -// Only violated checks are included; satisfied checks are omitted. -message AppendConsistencyViolationErrorDetails { - // The consistency checks that were violated. - repeated ConsistencyViolation violations = 1; -} - -// Details for a single consistency check that was violated. -message ConsistencyViolation { - // Index of the check in the original consistency_checks list. - int32 check_index = 1; - - oneof type { - // The stream was not at the expected state. - StreamStateViolation stream_state = 2; - } - - // A stream state check was violated because the actual state did not match the expected state. - message StreamStateViolation { - // The name of the stream whose state was checked. - string stream = 1; - - // The expected state of the stream as specified in the consistency check. - sint64 expected_state = 2 [jstype = JS_STRING]; - - // The actual state of the stream at the time the check was evaluated. - sint64 actual_state = 3 [jstype = JS_STRING]; - } -} diff --git a/src/main/proto/kurrentdb/protocol/v2/streams/streams.proto b/src/main/proto/kurrentdb/protocol/v2/streams/streams.proto deleted file mode 100644 index 80bea04..0000000 --- a/src/main/proto/kurrentdb/protocol/v2/streams/streams.proto +++ /dev/null @@ -1,241 +0,0 @@ -// ****************************************************************************************** -// This protocol is UNSTABLE in the sense of being subject to change. -// ****************************************************************************************** - -syntax = "proto3"; - -package kurrentdb.protocol.v2.streams; - -option go_package = "github.com/kurrent-io/KurrentDB-Client-Go/protos/kurrentdb/protocols/v2/streams"; -option csharp_namespace = "KurrentDB.Protocol.Streams.V2"; -option java_package = "io.kurrentdb.protocol.v2.streams"; -option java_multiple_files = true; - -import "google/protobuf/struct.proto"; - -service StreamsService { - // Appends records to multiple streams atomically within a single transaction. - // - // This is a client-streaming RPC where the client sends multiple AppendRequest messages - // (one per stream) and receives a single AppendSessionResponse upon commit. - // - // Guarantees: - // - Atomicity: All writes succeed or all fail together - // - Optimistic Concurrency: Expected revisions are validated for all streams before commit - // - Ordering: Records within each stream maintain send order - // - // Current Limitations: - // - Each stream can only appear once per session (no multiple appends to same stream) - // - // Example flow: - // 1. Client opens stream - // 2. Client sends AppendRequest for stream "orders" with 3 records - // 3. Client sends AppendRequest for stream "inventory" with 2 records - // 4. Client completes the stream - // 5. Server validates, commits, returns AppendSessionResponse with positions - rpc AppendSession(stream AppendRequest) returns (AppendSessionResponse); - - // Appends records to multiple streams atomically with cross-stream consistency checks. - // - // This is a unary RPC where the client sends all records and consistency checks - // in a single request and receives a single AppendRecordsResponse. - // - // Records can be interleaved across streams in any order and the global log preserves - // the exact sequence from the request. - // - // Consistency checks are decoupled from writes: a check can reference any stream, - // whether or not the request writes to it. - // - // Guarantees: - // - Atomicity: All writes succeed or all fail together - // - Ordering: Records maintain the exact send order in the global log - // - Cross-stream checks: Consistency checks can reference any stream - // - // On consistency check failure, no records are written and all failing checks - // are reported in the response so the client can refresh stale state in one round trip. - rpc AppendRecords(AppendRecordsRequest) returns (AppendRecordsResponse); -} - -// Represents the input for appending records to a specific stream. -message AppendRequest { - // The stream to append records to. - string stream = 1; - - // The records to append to the stream. - repeated AppendRecord records = 2; - - // The expected revision for optimistic concurrency control. - // Can be either: - // - A specific revision number (0, 1, 2, ...) - the stream must be at exactly this revision - // - An ExpectedRevisionConstants value (-4, -2, -1) for special semantics - // - // If omitted, defaults to EXPECTED_REVISION_CONSTANTS_ANY (-2). - optional sint64 expected_revision = 3 [jstype = JS_STRING]; -} - -// Represents the outcome of an append operation. -message AppendResponse { - // The stream to which records were appended. - string stream = 1; - - // The actual/current revision of the stream after the append. - // This is the revision number of the last record written to this stream. - sint64 stream_revision = 2 [jstype = JS_STRING]; - - // The position of the last appended record in the global log. - optional sint64 position = 3 [jstype = JS_STRING]; -} - -message AppendSessionResponse { - // The results of each append request in the session. - repeated AppendResponse output = 1; - - // The global commit position of the last appended record in the session. - sint64 position = 2 [jstype = JS_STRING]; -} - -// Represents the data format of the schema. -enum SchemaFormat { - // Default value, should not be used. - SCHEMA_FORMAT_UNSPECIFIED = 0; - SCHEMA_FORMAT_JSON = 1; - SCHEMA_FORMAT_PROTOBUF = 2; - SCHEMA_FORMAT_AVRO = 3; - SCHEMA_FORMAT_BYTES = 4; -} - -// Schema information for record validation and interpretation. -message SchemaInfo { - // The format of the data payload. - // Determines how the bytes in AppendRecord.data should be interpreted. - SchemaFormat format = 1; - - // The schema name (replaces the legacy "event type" concept). - // Identifies what kind of data this record contains. - // - // Common naming formats: - // - Kebab-case: "order-placed", "customer-registered" - // - URN format: "urn:kurrentdb:events:order-placed:v1" - // - Dotted namespace: "Teams.Player.V1", "Orders.OrderPlaced.V2" - // - Reverse domain: "com.acme.orders.placed" - string name = 2; - - // The identifier of the specific version of the schema that the record payload - // conforms to. This should match a registered schema version in the system. - // Not necessary when not enforcing schema validation. - optional string id = 3; -} - -// Record to be appended to a stream. -message AppendRecord { - // Unique identifier for this record (must be a valid UUID/GUID). - // If not provided, the server will generate a new one. - optional string record_id = 1; - - // A collection of properties providing additional information about the - // record. Can contain user-defined or system propreties. - // System keys will be prefixed with "$" (e.g., "$timestamp"). - // User-defined keys MUST NOT start with "$". - // - // Common examples: - // User metadata: - // - "user-id": "12345" - // - "tenant": "acme-corp" - // - "source": "mobile-app" - // - // System metadata (with $ prefix): - // - "$trace-id": "4bf92f3577b34da6a3ce929d0e0e4736" // OpenTelemetry trace ID - // - "$span-id": "00f067aa0ba902b7" // OpenTelemetry span ID - // - "$timestamp": "2025-01-15T10:30:00.000Z" // ISO 8601 timestamp - map properties = 2; - - // Schema information for this record. - SchemaInfo schema = 3; - - // The record payload as raw bytes. - // The format specified in SchemaInfo determines how to interpret these bytes. - bytes data = 4; - - // Target stream for this record. - // Required for AppendRecords (each record specifies its own stream). - // Ignored for AppendSession (the stream is specified in AppendRequest). - string stream = 5; -} - -// Constants for expected revision validation in optimistic concurrency control. -// These can be used in the expected_revision field, or you can specify an actual revision number. -enum ExpectedRevisionConstants { - // The stream must have exactly one event at revision 0. - // Used for scenarios requiring strict single-event semantics. - EXPECTED_REVISION_CONSTANTS_SINGLE_EVENT = 0; - - // The stream must not exist yet (first write to the stream). - // Fails if the stream already has events. - EXPECTED_REVISION_CONSTANTS_NO_STREAM = -1; - - // Accept any current state of the stream (no optimistic concurrency check). - // The write will succeed regardless of the stream's current revision. - EXPECTED_REVISION_CONSTANTS_ANY = -2; - - // The stream must exist (have at least one record). - // Fails if the stream doesn't exist yet. - EXPECTED_REVISION_CONSTANTS_EXISTS = -4; -} - -// Request to append records to one or more streams atomically. -// -// All records are committed in a single transaction. Each record specifies its -// target stream via AppendRecord.stream. Consistency checks are evaluated before -// any records are written. -message AppendRecordsRequest { - // The records to append. Records targeting the same stream maintain their - // order from this list. - repeated AppendRecord records = 1; - - // Optional consistency checks evaluated before commit. If any check fails, - // the entire transaction is aborted. - repeated ConsistencyCheck checks = 2; -} - -// Response from a successful AppendRecords operation. -// -// Contains the resulting revision for each stream that was written to and the -// global commit position of the transaction. -message AppendRecordsResponse { - // The resulting revision for each stream that received records. One entry per - // distinct stream written to, in no guaranteed order. - repeated StreamRevision revisions = 1; - - // The global commit position of the last record written in this transaction. - // Can be used for read-your-writes consistency or progress tracking. - sint64 position = 2 [jstype = JS_STRING]; -} - -// A pre-commit condition that must hold true for the transaction to succeed. -// -// Consistency checks are evaluated atomically before any records are written. If -// any check is violated, the entire transaction is aborted. -message ConsistencyCheck { - oneof type { - // Check that a stream is at a specific revision or lifecycle state. - StreamStateCheck stream_state = 1; - } - - // Asserts a stream is at a specific revision or lifecycle state before commit. - message StreamStateCheck { - // The stream name. - string stream = 1; - - // The expected state of the stream (revision number or state constant). - sint64 expected_state = 2 [jstype = JS_STRING]; - } -} - -// A specific revision of a stream. -message StreamRevision { - // Stream name. - string stream = 1; - - // Revision within the stream. - sint64 revision = 2 [jstype = JS_STRING]; -} diff --git a/src/main/proto/kurrentdb/protocol/v1/gossip.proto b/src/main/proto/trogoneventstore/protocol/v1/gossip.proto similarity index 85% rename from src/main/proto/kurrentdb/protocol/v1/gossip.proto rename to src/main/proto/trogoneventstore/protocol/v1/gossip.proto index 94804fe..b8becd0 100644 --- a/src/main/proto/kurrentdb/protocol/v1/gossip.proto +++ b/src/main/proto/trogoneventstore/protocol/v1/gossip.proto @@ -1,8 +1,8 @@ syntax = "proto3"; package event_store.client.gossip; -option java_package = "io.kurrent.dbclient.proto.gossip"; +option java_package = "io.trogonstack.eventstore.client.proto.gossip"; -import "kurrentdb/protocol/v1/shared.proto"; +import "trogoneventstore/protocol/v1/shared.proto"; service Gossip { rpc Read (event_store.client.Empty) returns (ClusterInfo); @@ -41,4 +41,4 @@ message MemberInfo { VNodeState state = 3; bool is_alive = 4; EndPoint http_end_point = 5; -} \ No newline at end of file +} diff --git a/src/main/proto/kurrentdb/protocol/v1/persistent.proto b/src/main/proto/trogoneventstore/protocol/v1/persistent.proto similarity index 90% rename from src/main/proto/kurrentdb/protocol/v1/persistent.proto rename to src/main/proto/trogoneventstore/protocol/v1/persistent.proto index 59ad36a..71b2092 100644 --- a/src/main/proto/kurrentdb/protocol/v1/persistent.proto +++ b/src/main/proto/trogoneventstore/protocol/v1/persistent.proto @@ -1,8 +1,8 @@ syntax = "proto3"; package event_store.client.persistent_subscriptions; -option java_package = "io.kurrent.dbclient.proto.persistentsubscriptions"; +option java_package = "io.trogonstack.eventstore.client.proto.persistentsubscriptions"; -import "kurrentdb/protocol/v1/shared.proto"; +import "trogoneventstore/protocol/v1/shared.proto"; service PersistentSubscriptions { rpc Create (CreateReq) returns (CreateResp); @@ -11,6 +11,7 @@ service PersistentSubscriptions { rpc Read (stream ReadReq) returns (stream ReadResp); rpc GetInfo (GetInfoReq) returns (GetInfoResp); rpc ReplayParked (ReplayParkedReq) returns (ReplayParkedResp); + rpc TruncateParked (TruncateParkedReq) returns (TruncateParkedResp); rpc List (ListReq) returns (ListResp); rpc RestartSubsystem (event_store.client.Empty) returns (event_store.client.Empty); } @@ -227,7 +228,7 @@ message UpdateReq { int32 live_buffer_size = 10; int32 read_batch_size = 11; int32 history_buffer_size = 12; - ConsumerStrategy named_consumer_strategy = 13; + ConsumerStrategy named_consumer_strategy = 13 [deprecated = true]; oneof message_timeout { int64 message_timeout_ticks = 4; int32 message_timeout_ms = 14; @@ -236,6 +237,7 @@ message UpdateReq { int64 checkpoint_after_ticks = 6; int32 checkpoint_after_ms = 15; } + string consumer_strategy = 16; } enum ConsumerStrategy { @@ -348,6 +350,25 @@ message ReplayParkedReq { message ReplayParkedResp { } +message TruncateParkedReq { + Options options = 1; + + message Options { + string group_name = 1; + oneof stream_option { + event_store.client.StreamIdentifier stream_identifier = 2; + event_store.client.Empty all = 3; + } + oneof stop_at_option { + int64 stop_at = 4; + event_store.client.Empty no_limit = 5; + } + } +} + +message TruncateParkedResp { +} + message ListReq { Options options = 1; @@ -356,6 +377,8 @@ message ListReq { event_store.client.Empty list_all_subscriptions = 1; StreamOption list_for_stream = 2; } + optional int32 offset = 3; + optional int32 count = 4; } message StreamOption { oneof stream_option { @@ -367,4 +390,7 @@ message ListReq { message ListResp { repeated SubscriptionInfo subscriptions = 1; -} \ No newline at end of file + optional int32 offset = 2; + optional int32 count = 3; + optional int32 total = 4; +} diff --git a/src/main/proto/kurrentdb/protocol/v1/projectionmanagement.proto b/src/main/proto/trogoneventstore/protocol/v1/projectionmanagement.proto similarity index 50% rename from src/main/proto/kurrentdb/protocol/v1/projectionmanagement.proto rename to src/main/proto/trogoneventstore/protocol/v1/projectionmanagement.proto index 2b120e5..6fa469f 100644 --- a/src/main/proto/kurrentdb/protocol/v1/projectionmanagement.proto +++ b/src/main/proto/trogoneventstore/protocol/v1/projectionmanagement.proto @@ -1,20 +1,25 @@ syntax = "proto3"; package event_store.client.projections; -option java_package = "io.kurrent.dbclient.proto.projections"; +option java_package = "io.trogonstack.eventstore.client.proto.projections"; import "google/protobuf/struct.proto"; -import "kurrentdb/protocol/v1/shared.proto"; +import "trogoneventstore/protocol/v1/shared.proto"; service Projections { rpc Create (CreateReq) returns (CreateResp); rpc Update (UpdateReq) returns (UpdateResp); + rpc GetQuery (GetQueryReq) returns (GetQueryResp); rpc Delete (DeleteReq) returns (DeleteResp); rpc Statistics (StatisticsReq) returns (stream StatisticsResp); rpc Disable (DisableReq) returns (DisableResp); rpc Enable (EnableReq) returns (EnableResp); rpc Reset (ResetReq) returns (ResetResp); + rpc Abort (AbortReq) returns (AbortResp); rpc State (StateReq) returns (StateResp); rpc Result (ResultReq) returns (ResultResp); + rpc GetConfig (GetConfigReq) returns (GetConfigResp); + rpc UpdateConfig (UpdateConfigReq) returns (UpdateConfigResp); + rpc ReadEvents (ReadEventsReq) returns (ReadEventsResp); rpc RestartSubsystem (event_store.client.Empty) returns (event_store.client.Empty); } @@ -28,14 +33,24 @@ message CreateReq { Continuous continuous = 3; } string query = 4; - int32 engine_version = 5; // 0 or 1 = v1 (default), 2 = v2 + string handler_type = 5; + oneof enabled_option { + bool enabled = 6; + event_store.client.Empty no_enabled_option = 7; + } + optional string name = 8; + bool checkpoints_enabled = 9; + bool emit_enabled = 10; + bool track_emitted_streams = 11; + map annotations = 12; message Transient { string name = 1; } message Continuous { string name = 1; - bool track_emitted_streams = 2; + bool emit_enabled = 2; + bool track_emitted_streams = 3; } } } @@ -53,12 +68,36 @@ message UpdateReq { bool emit_enabled = 3; event_store.client.Empty no_emit_options = 4; } + map annotations = 5; } } message UpdateResp { } +message GetQueryReq { + Options options = 1; + + message Options { + string name = 1; + } +} + +message GetQueryResp { + Details details = 1; + + message Details { + string name = 1; + string query = 2; + bool emit_enabled = 3; + string projection_type = 4; + optional bool track_emitted_streams = 5; + optional bool checkpoints_enabled = 6; + string definition_json = 7; + string output_config_json = 8; + } +} + message DeleteReq { Options options = 1; @@ -82,6 +121,7 @@ message StatisticsReq { event_store.client.Empty transient = 3; event_store.client.Empty continuous = 4; event_store.client.Empty one_time = 5; + event_store.client.Empty all_non_transient = 6; } } } @@ -138,6 +178,50 @@ message ResultResp { google.protobuf.Value result = 1; } +message GetConfigReq { + Options options = 1; + + message Options { + string name = 1; + } +} + +message GetConfigResp { + Details details = 1; + + message Details { + bool emit_enabled = 1; + bool track_emitted_streams = 2; + int32 checkpoint_after_ms = 3; + int32 checkpoint_handled_threshold = 4; + int32 checkpoint_unhandled_bytes_threshold = 5; + int32 pending_events_threshold = 6; + int32 max_write_batch_length = 7; + int32 max_allowed_writes_in_flight = 8; + optional int32 projection_execution_timeout = 9; + } +} + +message UpdateConfigReq { + Options options = 1; + + message Options { + string name = 1; + bool emit_enabled = 2; + bool track_emitted_streams = 3; + int32 checkpoint_after_ms = 4; + int32 checkpoint_handled_threshold = 5; + int32 checkpoint_unhandled_bytes_threshold = 6; + int32 pending_events_threshold = 7; + int32 max_write_batch_length = 8; + int32 max_allowed_writes_in_flight = 9; + optional int32 projection_execution_timeout = 10; + } +} + +message UpdateConfigResp { +} + message ResetReq { Options options = 1; @@ -150,6 +234,16 @@ message ResetReq { message ResetResp { } +message AbortReq { + Options options = 1; + + message Options { + string name = 1; + } +} + +message AbortResp { +} message EnableReq { Options options = 1; @@ -172,4 +266,35 @@ message DisableReq { } message DisableResp { -} \ No newline at end of file +} + +message ReadEventsReq { + Options options = 1; + + message Options { + string query_sources_json = 1; + string position_json = 2; + int32 max_events = 3; + } +} + +message ReadEventsResp { + Details details = 1; + + message Details { + string correlation_id = 1; + string reader_position_json = 2; + repeated Event events = 3; + + message Event { + string event_stream_id = 1; + int64 event_number = 2; + string event_type = 3; + google.protobuf.Value data = 4; + google.protobuf.Value metadata = 5; + google.protobuf.Value link_metadata = 6; + bool is_json = 7; + string reader_position_json = 8; + } + } +} diff --git a/src/main/proto/trogoneventstore/protocol/v1/serverfeatures.proto b/src/main/proto/trogoneventstore/protocol/v1/serverfeatures.proto new file mode 100644 index 0000000..1f8d908 --- /dev/null +++ b/src/main/proto/trogoneventstore/protocol/v1/serverfeatures.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package event_store.client.server_features; +option java_package = "io.trogonstack.eventstore.client.proto.serverfeatures"; +import "trogoneventstore/protocol/v1/shared.proto"; + +service ServerFeatures { + rpc GetSupportedMethods (event_store.client.Empty) returns (SupportedMethods); +} + +message SupportedMethods { + repeated SupportedMethod methods = 1; + string event_store_server_version = 2; +} + +message SupportedMethod { + string method_name = 1; + string service_name = 2; + repeated string features = 3; +} diff --git a/src/main/proto/kurrentdb/protocol/v1/shared.proto b/src/main/proto/trogoneventstore/protocol/v1/shared.proto similarity index 93% rename from src/main/proto/kurrentdb/protocol/v1/shared.proto rename to src/main/proto/trogoneventstore/protocol/v1/shared.proto index 5929d77..5a7f63a 100644 --- a/src/main/proto/kurrentdb/protocol/v1/shared.proto +++ b/src/main/proto/trogoneventstore/protocol/v1/shared.proto @@ -1,6 +1,6 @@ syntax = "proto3"; package event_store.client; -option java_package = "io.kurrent.dbclient.proto.shared"; +option java_package = "io.trogonstack.eventstore.client.proto.shared"; import "google/protobuf/empty.proto"; message UUID { @@ -58,4 +58,4 @@ message MaximumAppendSizeExceeded { message BadRequest { string message = 1; -} \ No newline at end of file +} diff --git a/src/main/proto/kurrentdb/protocol/v1/streams.proto b/src/main/proto/trogoneventstore/protocol/v1/streams.proto similarity index 86% rename from src/main/proto/kurrentdb/protocol/v1/streams.proto rename to src/main/proto/trogoneventstore/protocol/v1/streams.proto index c8305c0..07b347c 100644 --- a/src/main/proto/kurrentdb/protocol/v1/streams.proto +++ b/src/main/proto/trogoneventstore/protocol/v1/streams.proto @@ -1,8 +1,8 @@ syntax = "proto3"; package event_store.client.streams; -option java_package = "io.kurrent.dbclient.proto.streams"; +option java_package = "io.trogonstack.eventstore.client.proto.streams"; -import "kurrentdb/protocol/v1/shared.proto"; +import "trogoneventstore/protocol/v1/shared.proto"; import "google/rpc/status.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/empty.proto"; @@ -103,35 +103,15 @@ message ReadResp { FellBehind fell_behind = 9; } - // The $all or stream subscription has caught up and become live. message CaughtUp { - // Current time in the server when the subscription caught up google.protobuf.Timestamp timestamp = 1; - - // Checkpoint for resuming a stream subscription. - // For stream subscriptions it is populated unless the stream is empty. - // For $all subscriptions it is not populated. optional int64 stream_revision = 2; - - // Checkpoint for resuming a $all subscription. - // For stream subscriptions it is not populated. - // For $all subscriptions it is populated unless the database is empty. optional Position position = 3; } - // The $all or stream subscription has fallen back into catchup mode and is no longer live. message FellBehind { - // Current time in the server when the subscription fell behind google.protobuf.Timestamp timestamp = 1; - - // Checkpoint for resuming a stream subscription. - // For stream subscriptions it is populated unless the stream is empty. - // For $all subscriptions it is not populated. optional int64 stream_revision = 2; - - // Checkpoint for resuming a $all subscription. - // For stream subscriptions it is not populated. - // For $all subscriptions it is populated unless the database is empty. optional Position position = 3; } @@ -160,16 +140,11 @@ message ReadResp { message Checkpoint { uint64 commit_position = 1; uint64 prepare_position = 2; - - // Current time in the server when the checkpoint was reached - google.protobuf.Timestamp timestamp = 3; } - message Position { uint64 commit_position = 1; uint64 prepare_position = 2; } - message StreamNotFound { event_store.client.StreamIdentifier stream_identifier = 1; } diff --git a/src/test/java/io/kurrent/dbclient/AppendRecordsCheckOnlyTests.java b/src/test/java/io/kurrent/dbclient/AppendRecordsCheckOnlyTests.java deleted file mode 100644 index 6d0266a..0000000 --- a/src/test/java/io/kurrent/dbclient/AppendRecordsCheckOnlyTests.java +++ /dev/null @@ -1,576 +0,0 @@ -package io.kurrent.dbclient; - -import org.junit.jupiter.api.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; -import java.util.concurrent.ExecutionException; - -public class AppendRecordsCheckOnlyTests implements ConnectionAware { - static private Database database; - static private Logger logger; - - @BeforeAll - public static void setup() { - database = DatabaseFactory.spawn(); - logger = LoggerFactory.getLogger(AppendRecordsCheckOnlyTests.class); - } - - @Override - public Database getDatabase() { - return database; - } - - @Override - public Logger getLogger() { - return logger; - } - - @AfterAll - public static void cleanup() { - database.dispose(); - } - - private void assumeSupported(KurrentDBClient client) throws ExecutionException, InterruptedException { - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - } - - private void seedStream(KurrentDBClient client, String stream, int eventCount) throws ExecutionException, InterruptedException { - List records = new ArrayList<>(); - for (int i = 0; i < eventCount; i++) { - records.add(new AppendRecord(stream, EventData.builderAsJson("seed-event", "{}".getBytes()).build())); - } - client.appendRecords(records).get(); - } - - // ==================== WhenExpectingExists (CheckOnly) ==================== - - @Test - public void testCheckExists_succeeds_when_stream_has_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 3); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamExists()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertEquals(1, result.getResults().size()); - Assertions.assertEquals(writeStream, result.getResults().get(0).getStream()); - } - - @Test - public void testCheckExists_fails_when_stream_not_found() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamExists()) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - Assertions.assertEquals(1, ex.getViolations().size()); - Assertions.assertEquals(checkStream, ex.getViolations().get(0).getStream()); - } - - @Test - public void testCheckExists_fails_when_stream_is_deleted() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 3); - client.deleteStream(checkStream).get(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamExists()) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testCheckExists_fails_when_stream_is_tombstoned() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 3); - client.tombstoneStream(checkStream).get(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamExists()) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - // ==================== WhenExpectingNoStream (CheckOnly) ==================== - - @Test - public void testCheckNoStream_succeeds_when_stream_not_found() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.noStream()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertEquals(1, result.getResults().size()); - Assertions.assertEquals(writeStream, result.getResults().get(0).getStream()); - } - - @Test - public void testCheckNoStream_succeeds_when_stream_is_deleted() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 3); - client.deleteStream(checkStream).get(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.noStream()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertEquals(1, result.getResults().size()); - } - - @Test - public void testCheckNoStream_succeeds_when_stream_is_tombstoned() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 3); - client.tombstoneStream(checkStream).get(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.noStream()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertEquals(1, result.getResults().size()); - } - - @Test - public void testCheckNoStream_fails_when_stream_has_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 3); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.noStream()) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - Assertions.assertEquals(1, ex.getViolations().size()); - Assertions.assertEquals(checkStream, ex.getViolations().get(0).getStream()); - } - - // ==================== WhenExpectingRevision (CheckOnly) ==================== - - private static final int EXPECTED_REVISION = 10; - - @Test - public void testCheckRevision_succeeds_when_stream_has_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, EXPECTED_REVISION + 1); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertEquals(1, result.getResults().size()); - Assertions.assertEquals(writeStream, result.getResults().get(0).getStream()); - } - - @Test - public void testCheckRevision_fails_when_stream_not_found() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testCheckRevision_fails_when_stream_has_wrong_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 5); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testCheckRevision_fails_when_stream_is_deleted() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 3); - client.deleteStream(checkStream).get(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testCheckRevision_fails_when_stream_is_tombstoned() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStream = generateName(); - String writeStream = generateName(); - seedStream(client, checkStream, 3); - client.tombstoneStream(checkStream).get(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - // ==================== WhenMultipleChecks ==================== - - @Test - public void testMultipleChecks_succeeds_when_all_checks_pass() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStreamA = generateName(); - String checkStreamB = generateName(); - String writeStream = generateName(); - seedStream(client, checkStreamA, 3); - seedStream(client, checkStreamB, 5); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Arrays.asList( - new ConsistencyCheck.StreamStateCheck(checkStreamA, StreamState.streamRevision(2)), - new ConsistencyCheck.StreamStateCheck(checkStreamB, StreamState.streamRevision(4)) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertEquals(1, result.getResults().size()); - } - - @Test - public void testMultipleChecks_succeeds_when_all_mixed_check_types_pass() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStreamA = generateName(); - String checkStreamB = generateName(); - String checkStreamC = generateName(); - String writeStream = generateName(); - seedStream(client, checkStreamA, 3); - seedStream(client, checkStreamB, 5); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Arrays.asList( - new ConsistencyCheck.StreamStateCheck(checkStreamA, StreamState.streamRevision(2)), - new ConsistencyCheck.StreamStateCheck(checkStreamB, StreamState.streamExists()), - new ConsistencyCheck.StreamStateCheck(checkStreamC, StreamState.noStream()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertEquals(1, result.getResults().size()); - } - - @Test - public void testMultipleChecks_fails_when_all_checks_fail() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStreamA = generateName(); - String checkStreamB = generateName(); - String writeStream = generateName(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Arrays.asList( - new ConsistencyCheck.StreamStateCheck(checkStreamA, StreamState.streamRevision(5)), - new ConsistencyCheck.StreamStateCheck(checkStreamB, StreamState.streamExists()) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - Assertions.assertEquals(2, ex.getViolations().size()); - } - - @Test - public void testMultipleChecks_fails_when_first_check_fails_and_second_passes() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStreamA = generateName(); - String checkStreamB = generateName(); - String writeStream = generateName(); - seedStream(client, checkStreamB, 6); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Arrays.asList( - new ConsistencyCheck.StreamStateCheck(checkStreamA, StreamState.streamRevision(5)), - new ConsistencyCheck.StreamStateCheck(checkStreamB, StreamState.streamRevision(5)) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - Assertions.assertEquals(1, ex.getViolations().size()); - Assertions.assertEquals(0, ex.getViolations().get(0).getCheckIndex()); - Assertions.assertEquals(checkStreamA, ex.getViolations().get(0).getStream()); - } - - @Test - public void testMultipleChecks_fails_when_two_of_three_checks_fail() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String checkStreamA = generateName(); - String checkStreamB = generateName(); - String checkStreamC = generateName(); - String writeStream = generateName(); - seedStream(client, checkStreamA, 3); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Arrays.asList( - new ConsistencyCheck.StreamStateCheck(checkStreamA, StreamState.streamRevision(2)), - new ConsistencyCheck.StreamStateCheck(checkStreamB, StreamState.streamExists()), - new ConsistencyCheck.StreamStateCheck(checkStreamC, StreamState.streamRevision(5)) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - Assertions.assertEquals(2, ex.getViolations().size()); - } - - @Test - public void testMultipleChecks_fails_with_mixed_violation_states() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String deletedStream = generateName(); - String tombstonedStream = generateName(); - String missingStream = generateName(); - String writeStream = generateName(); - - seedStream(client, deletedStream, 3); - client.deleteStream(deletedStream).get(); - - seedStream(client, tombstonedStream, 3); - client.tombstoneStream(tombstonedStream).get(); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Arrays.asList( - new ConsistencyCheck.StreamStateCheck(deletedStream, StreamState.streamExists()), - new ConsistencyCheck.StreamStateCheck(tombstonedStream, StreamState.streamExists()), - new ConsistencyCheck.StreamStateCheck(missingStream, StreamState.streamExists()) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - Assertions.assertEquals(3, ex.getViolations().size()); - } - - @Test - public void testMultipleChecks_fails_when_check_on_write_target_and_separate_check_fails() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String writeStream = generateName(); - String checkStream = generateName(); - seedStream(client, writeStream, 4); - - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Arrays.asList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.streamRevision(5)), - new ConsistencyCheck.StreamStateCheck(writeStream, StreamState.streamRevision(3)) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - Assertions.assertFalse(ex.getViolations().isEmpty()); - Assertions.assertEquals(0, ex.getViolations().get(0).getCheckIndex()); - Assertions.assertEquals(checkStream, ex.getViolations().get(0).getStream()); - } -} diff --git a/src/test/java/io/kurrent/dbclient/AppendRecordsTests.java b/src/test/java/io/kurrent/dbclient/AppendRecordsTests.java deleted file mode 100644 index 141f276..0000000 --- a/src/test/java/io/kurrent/dbclient/AppendRecordsTests.java +++ /dev/null @@ -1,294 +0,0 @@ -package io.kurrent.dbclient; - -import org.junit.jupiter.api.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; -import java.util.concurrent.ExecutionException; - -public class AppendRecordsTests implements ConnectionAware { - static private Database database; - static private Logger logger; - - @BeforeAll - public static void setup() { - database = DatabaseFactory.spawn(); - logger = LoggerFactory.getLogger(AppendRecordsTests.class); - } - - @Override - public Database getDatabase() { - return database; - } - - @Override - public Logger getLogger() { - return logger; - } - - @AfterAll - public static void cleanup() { - database.dispose(); - } - - @Test - public void testAppendRecordsToSingleStream() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - - String streamName = generateName(); - - List records = Arrays.asList( - new AppendRecord(streamName, EventData.builderAsJson("event-type-a", "{\"data\":\"1\"}".getBytes()).build()), - new AppendRecord(streamName, EventData.builderAsJson("event-type-b", "{\"data\":\"2\"}".getBytes()).build()), - new AppendRecord(streamName, EventData.builderAsJson("event-type-c", "{\"data\":\"3\"}".getBytes()).build()) - ); - - AppendRecordsResponse result = client.appendRecords(records).get(); - - Assertions.assertTrue(result.getPosition() > 0); - Assertions.assertFalse(result.getResults().isEmpty()); - Assertions.assertEquals(1, result.getResults().size()); - Assertions.assertEquals(streamName, result.getResults().get(0).getStream()); - - List readEvents = client.readStream(streamName, ReadStreamOptions.get()).get().getEvents(); - Assertions.assertEquals(3, readEvents.size()); - } - - @Test - public void testAppendRecordsToMultipleStreams() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - - String stream1 = generateName(); - String stream2 = generateName(); - - List records = Arrays.asList( - new AppendRecord(stream1, EventData.builderAsJson("event-a", "{\"data\":\"1\"}".getBytes()).build()), - new AppendRecord(stream1, EventData.builderAsJson("event-b", "{\"data\":\"2\"}".getBytes()).build()), - new AppendRecord(stream2, EventData.builderAsJson("event-c", "{\"data\":\"3\"}".getBytes()).build()) - ); - - AppendRecordsResponse result = client.appendRecords(records).get(); - - Assertions.assertTrue(result.getPosition() > 0); - Assertions.assertEquals(2, result.getResults().size()); - - List readEvents1 = client.readStream(stream1, ReadStreamOptions.get()).get().getEvents(); - List readEvents2 = client.readStream(stream2, ReadStreamOptions.get()).get().getEvents(); - Assertions.assertEquals(2, readEvents1.size()); - Assertions.assertEquals(1, readEvents2.size()); - } - - @Test - public void testInterleavedTracksRevisions() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - - String stream1 = generateName(); - String stream2 = generateName(); - - List records = Arrays.asList( - new AppendRecord(stream1, EventData.builderAsJson("event-1", "{}".getBytes()).build()), - new AppendRecord(stream2, EventData.builderAsJson("event-2", "{}".getBytes()).build()), - new AppendRecord(stream1, EventData.builderAsJson("event-3", "{}".getBytes()).build()), - new AppendRecord(stream2, EventData.builderAsJson("event-4", "{}".getBytes()).build()), - new AppendRecord(stream1, EventData.builderAsJson("event-5", "{}".getBytes()).build()) - ); - - AppendRecordsResponse result = client.appendRecords(records).get(); - - Assertions.assertTrue(result.getPosition() > 0); - Assertions.assertEquals(2, result.getResults().size()); - - AppendResponse rev1 = result.getResults().stream() - .filter(r -> r.getStream().equals(stream1)).findFirst().get(); - AppendResponse rev2 = result.getResults().stream() - .filter(r -> r.getStream().equals(stream2)).findFirst().get(); - - Assertions.assertEquals(2, rev1.getStreamRevision()); - Assertions.assertEquals(1, rev2.getStreamRevision()); - - List readEvents1 = client.readStream(stream1, ReadStreamOptions.get()).get().getEvents(); - List readEvents2 = client.readStream(stream2, ReadStreamOptions.get()).get().getEvents(); - Assertions.assertEquals(3, readEvents1.size()); - Assertions.assertEquals(2, readEvents2.size()); - } - - @Test - public void testAppendRecordsWithConsistencyCheckSuccess() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - - String streamName = generateName(); - - List records = Collections.singletonList( - new AppendRecord(streamName, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(streamName, StreamState.noStream()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - - Assertions.assertTrue(result.getPosition() > 0); - Assertions.assertEquals(1, result.getResults().size()); - Assertions.assertEquals(streamName, result.getResults().get(0).getStream()); - } - - @Test - public void testAppendRecordsWithConsistencyCheckFailure() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - - String streamName = generateName(); - - // First, write some records so the stream exists - client.appendRecords(Collections.singletonList( - new AppendRecord(streamName, EventData.builderAsJson("setup-event", "{}".getBytes()).build()) - )).get(); - - // Now try with NoStream check — should fail - List records = Collections.singletonList( - new AppendRecord(streamName, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(streamName, StreamState.noStream()) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - - Assertions.assertEquals(1, ex.getViolations().size()); - ConsistencyViolation violation = ex.getViolations().get(0); - Assertions.assertEquals(0, violation.getCheckIndex()); - Assertions.assertEquals(streamName, violation.getStream()); - Assertions.assertEquals(StreamState.noStream(), violation.getExpectedState()); - Assertions.assertEquals(StreamState.streamRevision(0), violation.getActualState()); - } - - @Test - public void testAppendRecordsWithDecoupledConsistencyCheck() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - - String checkStream = generateName(); - String writeStream = generateName(); - - // Check that checkStream does not exist, write to writeStream - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(checkStream, StreamState.noStream()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - - Assertions.assertTrue(result.getPosition() > 0); - Assertions.assertEquals(1, result.getResults().size()); - Assertions.assertEquals(writeStream, result.getResults().get(0).getStream()); - } - - @Test - public void testAppendRecordsWithMultipleChecks() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - - String stream1 = generateName(); - String stream2 = generateName(); - String writeStream = generateName(); - - // Write to stream1 so it exists at revision 0 - client.appendRecords(Collections.singletonList( - new AppendRecord(stream1, EventData.builderAsJson("setup", "{}".getBytes()).build()) - )).get(); - - // Check stream1 at NoStream (will fail) and stream2 at NoStream (will pass) - List records = Collections.singletonList( - new AppendRecord(writeStream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Arrays.asList( - new ConsistencyCheck.StreamStateCheck(stream1, StreamState.noStream()), - new ConsistencyCheck.StreamStateCheck(stream2, StreamState.noStream()) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - - Assertions.assertEquals(1, ex.getViolations().size()); - ConsistencyViolation violation = ex.getViolations().get(0); - Assertions.assertEquals(0, violation.getCheckIndex()); - Assertions.assertEquals(stream1, violation.getStream()); - Assertions.assertEquals(StreamState.noStream(), violation.getExpectedState()); - } - - @Test - public void testAppendRecordsWhenUnsupported() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeFalse( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords is supported on server versions 26.1 and later" - ); - - List records = Collections.singletonList( - new AppendRecord("test-stream", EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - - ExecutionException e = Assertions.assertThrows( - ExecutionException.class, - () -> client.appendRecords(records).get()); - - Assertions.assertInstanceOf(UnsupportedOperationException.class, e.getCause()); - } -} diff --git a/src/test/java/io/kurrent/dbclient/AppendRecordsWriteOnlyTests.java b/src/test/java/io/kurrent/dbclient/AppendRecordsWriteOnlyTests.java deleted file mode 100644 index 5d91f78..0000000 --- a/src/test/java/io/kurrent/dbclient/AppendRecordsWriteOnlyTests.java +++ /dev/null @@ -1,441 +0,0 @@ -package io.kurrent.dbclient; - -import org.junit.jupiter.api.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; -import java.util.concurrent.ExecutionException; - -public class AppendRecordsWriteOnlyTests implements ConnectionAware { - static private Database database; - static private Logger logger; - - @BeforeAll - public static void setup() { - database = DatabaseFactory.spawn(); - logger = LoggerFactory.getLogger(AppendRecordsWriteOnlyTests.class); - } - - @Override - public Database getDatabase() { - return database; - } - - @Override - public Logger getLogger() { - return logger; - } - - @AfterAll - public static void cleanup() { - database.dispose(); - } - - private void assumeSupported(KurrentDBClient client) throws ExecutionException, InterruptedException { - Optional version = client.getServerVersion().get(); - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(26, 1), - "AppendRecords requires server version 26.1 or later" - ); - } - - private void seedStream(KurrentDBClient client, String stream, int eventCount) throws ExecutionException, InterruptedException { - List records = new ArrayList<>(); - for (int i = 0; i < eventCount; i++) { - records.add(new AppendRecord(stream, EventData.builderAsJson("seed-event", "{}".getBytes()).build())); - } - client.appendRecords(records).get(); - } - - // ==================== WhenExpectingAny ==================== - - @Test - public void testWriteAny_succeeds_when_stream_has_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.any()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertTrue(result.getPosition() > 0); - Assertions.assertEquals(1, result.getResults().size()); - } - - @Test - public void testWriteAny_succeeds_when_stream_not_found() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.any()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertTrue(result.getPosition() > 0); - } - - @Test - public void testWriteAny_succeeds_when_stream_is_deleted() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - client.deleteStream(stream).get(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.any()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertTrue(result.getPosition() > 0); - } - - @Test - public void testWriteAny_fails_when_stream_is_tombstoned() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - client.tombstoneStream(stream).get(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.any()) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - // ==================== WhenExpectingExists ==================== - - @Test - public void testWriteExists_succeeds_when_stream_has_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamExists()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertTrue(result.getPosition() > 0); - } - - @Test - public void testWriteExists_fails_when_stream_not_found() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamExists()) - ); - - AppendConsistencyViolationException ex = Assertions.assertThrows( - AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - Assertions.assertEquals(1, ex.getViolations().size()); - Assertions.assertEquals(stream, ex.getViolations().get(0).getStream()); - } - - @Test - public void testWriteExists_fails_when_stream_is_deleted() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - client.deleteStream(stream).get(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamExists()) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testWriteExists_fails_when_stream_is_tombstoned() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - client.tombstoneStream(stream).get(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamExists()) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - // ==================== WhenExpectingNoStream ==================== - - @Test - public void testWriteNoStream_succeeds_when_stream_not_found() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.noStream()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertTrue(result.getPosition() > 0); - } - - @Test - public void testWriteNoStream_succeeds_when_stream_is_deleted() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - client.deleteStream(stream).get(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.noStream()) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertTrue(result.getPosition() > 0); - } - - @Test - public void testWriteNoStream_fails_when_stream_has_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.noStream()) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testWriteNoStream_fails_when_stream_is_tombstoned() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - client.tombstoneStream(stream).get(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.noStream()) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - // ==================== WhenExpectingRevision ==================== - - private static final int EXPECTED_REVISION = 10; - - @Test - public void testWriteRevision_succeeds_when_stream_has_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, EXPECTED_REVISION + 1); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - AppendRecordsResponse result = client.appendRecords(records, checks).get(); - Assertions.assertTrue(result.getPosition() > 0); - } - - @Test - public void testWriteRevision_fails_when_stream_not_found() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testWriteRevision_fails_when_stream_has_wrong_revision() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 5); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testWriteRevision_fails_when_stream_is_deleted() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - client.deleteStream(stream).get(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testWriteRevision_fails_when_stream_is_tombstoned() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - assumeSupported(client); - - String stream = generateName(); - seedStream(client, stream, 3); - client.tombstoneStream(stream).get(); - - List records = Collections.singletonList( - new AppendRecord(stream, EventData.builderAsJson("event-a", "{}".getBytes()).build()) - ); - List checks = Collections.singletonList( - new ConsistencyCheck.StreamStateCheck(stream, StreamState.streamRevision(EXPECTED_REVISION)) - ); - - Assertions.assertThrows(AppendConsistencyViolationException.class, () -> { - try { - client.appendRecords(records, checks).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } -} diff --git a/src/test/java/io/kurrent/dbclient/MultiStreamAppendTests.java b/src/test/java/io/kurrent/dbclient/MultiStreamAppendTests.java deleted file mode 100644 index ab31a4d..0000000 --- a/src/test/java/io/kurrent/dbclient/MultiStreamAppendTests.java +++ /dev/null @@ -1,244 +0,0 @@ -package io.kurrent.dbclient; - -import org.junit.jupiter.api.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.*; -import java.util.concurrent.ExecutionException; - -@SuppressWarnings("rawtypes") -public class MultiStreamAppendTests implements ConnectionAware { - static private Database database; - static private Logger logger; - - @BeforeAll - public static void setup() { - database = DatabaseFactory.spawn(); - logger = LoggerFactory.getLogger(MultiStreamAppendTests.class); - } - - @Override - public Database getDatabase() { - return database; - } - - @Override - public Logger getLogger() { - return logger; - } - - @AfterAll - public static void cleanup() { - database.dispose(); - } - - @Test - public void testBadEventMetadata() throws ExecutionException, InterruptedException, IOException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(25, 0), - "Multi-stream append is not supported server versions below 25.0.0" - ); - - // Arrange - String streamName1 = generateName(); - - Map metadata = new HashMap<>(); - metadata.put("stringProperty", "hello world"); - metadata.put("intProperty", 42); - - byte[] metadataBytes = mapper.writeValueAsBytes(metadata); - - EventData event1 = EventData.builderAsJson("event-a", "{\"data\":\"test1\"}".getBytes()) - .metadataAsBytes(metadataBytes) - .build(); - - List events1 = Collections.singletonList(event1); - - List requests = Collections.singletonList( - new AppendStreamRequest(streamName1, events1.iterator(), StreamState.noStream()) - ); - - // Act & Assert - Assertions.assertThrows(IllegalArgumentException.class, () -> { - try { - client.multiStreamAppend(requests.iterator()).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testMultiStreamAppend() throws ExecutionException, InterruptedException, IOException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(25, 0), - "Multi-stream append is not supported server versions below 25.0.0" - ); - - // Arrange - String streamName1 = generateName(); - String streamName2 = generateName(); - - Map metadata = new HashMap<>(); - metadata.put("stringProperty", "hello world"); - - byte[] metadataBytes = mapper.writeValueAsBytes(metadata); - - EventData event1 = EventData.builderAsJson("event-a", "{\"data\":\"test1\"}".getBytes()) - .metadataAsBytes(metadataBytes) - .build(); - - EventData event2 = EventData.builderAsBinary("event-b", new byte[0]).build(); - - List events1 = Collections.singletonList(event1); - List events2 = Collections.singletonList(event2); - - List requests = Arrays.asList( - new AppendStreamRequest(streamName1, events1.iterator(), StreamState.noStream()), - new AppendStreamRequest(streamName2, events2.iterator(), StreamState.noStream()) - ); - - // Act - MultiStreamAppendResponse result = client.multiStreamAppend(requests.iterator()).get(); - - // Assert - Assertions.assertFalse(result.getResults().isEmpty()); - Assertions.assertTrue(result.getPosition() > 0); - - List readEvents1 = client.readStream(streamName1, ReadStreamOptions.get()).get().getEvents(); - Assertions.assertEquals(1, readEvents1.size()); - - ResolvedEvent readEvent1 = readEvents1.get(0); - Assertions.assertEquals(event1.getEventType(), readEvent1.getEvent().getEventType()); - - byte[] readMetadata = readEvent1.getEvent().getUserMetadata(); - Assertions.assertNotNull(readMetadata); - Assertions.assertTrue(readMetadata.length > 0); - - Map deserializedMetadata = mapper.readValue(readMetadata, Map.class); - Assertions.assertEquals(metadata.get("stringProperty"), deserializedMetadata.get("stringProperty")); - - List readEvents2 = client.readStream(streamName2, ReadStreamOptions.get()).get().getEvents(); - Assertions.assertEquals(1, readEvents2.size()); - Assertions.assertEquals(event2.getEventType(), readEvents2.get(0).getEvent().getEventType()); - } - - @Test - public void testMultiStreamAppendWhenUnsupported() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - Assumptions.assumeFalse( - version.isPresent() && version.get().isGreaterOrEqualThan(25, 0), - "Multi-stream is supported server versions greater or equal to 25.0.0" - ); - - List requests = new ArrayList<>(); - - List events = new ArrayList<>(); - for (int i = 0; i < 10; i++) - events.add(EventData.builderAsBinary("created", new byte[0]).build()); - - requests.add(new AppendStreamRequest("foobar", events.iterator(), StreamState.any())); - requests.add(new AppendStreamRequest("baz", events.iterator(), StreamState.any())); - - ExecutionException e = Assertions.assertThrows( - ExecutionException.class, - () -> client.multiStreamAppend(requests.iterator()).get()); - - Assertions.assertInstanceOf(UnsupportedOperationException.class, e.getCause()); - } - - // - @Test - public void testMultiStreamAppendStreamRevisionConflict() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(25, 0), - "Multi-stream append is not supported server versions below 25.0.0" - ); - - // Arrange - String streamName = generateName(); - - EventData event = EventData.builderAsJson("event-1", "{}".getBytes()).build(); - - client.appendToStream( - streamName, - AppendToStreamOptions.get().streamState(StreamState.noStream()), - event - ).get(); - - List requests = Collections.singletonList( - new AppendStreamRequest( - streamName, - Collections.singletonList(EventData.builderAsBinary("event-2", "{}".getBytes()).build()).iterator(), - StreamState.noStream() - ) - ); - - // Act & Assert - Assertions.assertThrows(WrongExpectedVersionException.class, () -> { - try { - client.multiStreamAppend(requests.iterator()).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } - - @Test - public void testMultiStreamAppendStreamDeleted() throws ExecutionException, InterruptedException { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(25, 0), - "Multi-stream append is not supported server versions below 25.0.0" - ); - - // Arrange - String streamName = generateName(); - - EventData event1 = EventData.builderAsJson("event-1", "{}".getBytes()).build(); - - client.appendToStream( - streamName, - AppendToStreamOptions.get().streamState(StreamState.noStream()), - event1 - ).get(); - - client.tombstoneStream(streamName).get(); - - List requests = Collections.singletonList( - new AppendStreamRequest( - streamName, - Collections.singletonList(EventData.builderAsBinary("event-2", "{}".getBytes()).build()).iterator(), - StreamState.noStream() - ) - ); - - // Act - Assertions.assertThrows(StreamTombstonedException.class, () -> { - try { - client.multiStreamAppend(requests.iterator()).get(); - } catch (ExecutionException e) { - throw e.getCause(); - } - }); - } -} diff --git a/src/test/java/io/kurrent/dbclient/misc/ParseInvalidConnectionStringTests.java b/src/test/java/io/kurrent/dbclient/misc/ParseInvalidConnectionStringTests.java deleted file mode 100644 index 149eb97..0000000 --- a/src/test/java/io/kurrent/dbclient/misc/ParseInvalidConnectionStringTests.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.kurrent.dbclient.misc; - -import io.kurrent.dbclient.ConnectionStringParsingException; -import io.kurrent.dbclient.KurrentDBConnectionString; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.util.stream.Stream; - -public class ParseInvalidConnectionStringTests { - public static Stream invalidConnectionStrings() { - return Stream.of( - Arguments.of("localhost"), - Arguments.of("https://console.eventstore.cloud/"), - Arguments.of("kurnt+discovery://localhost"), - Arguments.of("kurrent://my:great@username:UyeXx8$^PsOo4jG88FlCauR1Coz25q@host?nodePreference=follower&tlsVerifyCert=false"), - Arguments.of("kurrent://host1,host2:200:300?tlsVerifyCert=false"), - Arguments.of("kurrent://localhost/&tlsVerifyCert=false"), - Arguments.of("kurrent://localhost?tlsVerifyCert=false?nodePreference=follower"), - Arguments.of("kurrent://localhost?tlsVerifyCert=false&nodePreference=any"), - Arguments.of("kurrent://localhost?tlsVerifyCert=if you feel like it"), - Arguments.of("kurrent://localhost?keepAliveInterval=-3"), - Arguments.of("kurrent://localhost?keepAliveInterval=sdfksjsfl"), - Arguments.of("kurrent://localhost?keepAliveTimeout=sdfksjsfl"), - Arguments.of("kurrent://localhost?keepAliveTimeout=-3"), - Arguments.of("kurrent://localhost?nodePreference=read_only_replica"), - Arguments.of("kurrent://localhost?userCertFile=/path/to/cert"), - Arguments.of("kurrent://localhost?userKeyFile=/path/to/key") - ); - } - - @ParameterizedTest - @MethodSource("invalidConnectionStrings") - public void test(String input) throws ConnectionStringParsingException { - Assertions.assertThrows(RuntimeException.class, () -> { - KurrentDBConnectionString.parseOrThrow(input); - }); - } -} diff --git a/src/test/java/io/kurrent/dbclient/samples/authentication/UserCertificate.java b/src/test/java/io/kurrent/dbclient/samples/authentication/UserCertificate.java deleted file mode 100644 index 023e629..0000000 --- a/src/test/java/io/kurrent/dbclient/samples/authentication/UserCertificate.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.kurrent.dbclient.samples.authentication; - -import io.kurrent.dbclient.KurrentDBClient; -import io.kurrent.dbclient.KurrentDBClientSettings; -import io.kurrent.dbclient.KurrentDBConnectionString; - -public class UserCertificate { - private static void tracing() { - // region client-with-user-certificates - KurrentDBClientSettings settings = KurrentDBConnectionString - .parseOrThrow("kurrentdb://admin:changeit@{endpoint}?tls=true&userCertFile={pathToCaFile}&userKeyFile={pathToKeyFile}"); - KurrentDBClient client = KurrentDBClient.create(settings); - // endregion client-with-user-certificates - } -} diff --git a/src/test/java/io/kurrent/dbclient/Action.java b/src/test/java/io/trogonstack/eventstore/client/Action.java similarity index 66% rename from src/test/java/io/kurrent/dbclient/Action.java rename to src/test/java/io/trogonstack/eventstore/client/Action.java index 7e6dc3d..c3c7e37 100644 --- a/src/test/java/io/kurrent/dbclient/Action.java +++ b/src/test/java/io/trogonstack/eventstore/client/Action.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; @FunctionalInterface public interface Action { diff --git a/src/test/java/io/kurrent/dbclient/BazEvent.java b/src/test/java/io/trogonstack/eventstore/client/BazEvent.java similarity index 95% rename from src/test/java/io/kurrent/dbclient/BazEvent.java rename to src/test/java/io/trogonstack/eventstore/client/BazEvent.java index 3ea4687..1bb935a 100644 --- a/src/test/java/io/kurrent/dbclient/BazEvent.java +++ b/src/test/java/io/trogonstack/eventstore/client/BazEvent.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Objects; diff --git a/src/test/java/io/kurrent/dbclient/ClientTracker.java b/src/test/java/io/trogonstack/eventstore/client/ClientTracker.java similarity index 85% rename from src/test/java/io/kurrent/dbclient/ClientTracker.java rename to src/test/java/io/trogonstack/eventstore/client/ClientTracker.java index 2b56a69..e2373a1 100644 --- a/src/test/java/io/kurrent/dbclient/ClientTracker.java +++ b/src/test/java/io/trogonstack/eventstore/client/ClientTracker.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.Status; import io.grpc.StatusRuntimeException; @@ -12,19 +12,19 @@ public class ClientTracker { private static final Logger logger = LoggerFactory.getLogger(ClientTracker.class); - private ArrayList otherClients = new ArrayList<>(); - private KurrentDBClient defaultClient = null; + private ArrayList otherClients = new ArrayList<>(); + private TrogonEventStoreClient defaultClient = null; - public synchronized KurrentDBClient createClient(KurrentDBClientSettings settings) { - KurrentDBClient client = KurrentDBClient.create(settings); + public synchronized TrogonEventStoreClient createClient(TrogonEventStoreClientSettings settings) { + TrogonEventStoreClient client = TrogonEventStoreClient.create(settings); otherClients.add(client); return client; } - public synchronized KurrentDBClient getDefaultClient(Database database) { + public synchronized TrogonEventStoreClient getDefaultClient(Database database) { if (defaultClient == null) { - KurrentDBClientSettings settings = database.defaultSettingsBuilder().buildConnectionSettings(); - defaultClient = KurrentDBClient.create(settings); + TrogonEventStoreClientSettings settings = database.defaultSettingsBuilder().buildConnectionSettings(); + defaultClient = TrogonEventStoreClient.create(settings); if (settings.isTls() && settings.getDefaultCredentials() != null) { for (int count = 0; count < 50; count++) { @@ -84,7 +84,7 @@ public synchronized KurrentDBClient getDefaultClient(Database database) { } catch (InterruptedException ex) { throw new RuntimeException(ex); } - defaultClient = KurrentDBClient.create(settings); + defaultClient = TrogonEventStoreClient.create(settings); continue; } @@ -107,7 +107,7 @@ public void dispose() { defaultClient = null; } - for (KurrentDBClientBase client: otherClients) { + for (TrogonEventStoreClientBase client: otherClients) { try { client.shutdown().get(); } catch (ExecutionException | InterruptedException e) { diff --git a/src/test/java/io/kurrent/dbclient/ConnectionAware.java b/src/test/java/io/trogonstack/eventstore/client/ConnectionAware.java similarity index 87% rename from src/test/java/io/kurrent/dbclient/ConnectionAware.java rename to src/test/java/io/trogonstack/eventstore/client/ConnectionAware.java index fc02396..6ec36a6 100644 --- a/src/test/java/io/kurrent/dbclient/ConnectionAware.java +++ b/src/test/java/io/trogonstack/eventstore/client/ConnectionAware.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.json.JsonMapper; @@ -19,16 +19,16 @@ public interface ConnectionAware { Logger getLogger(); - default KurrentDBClient getDefaultClient() { + default TrogonEventStoreClient getDefaultClient() { return getDatabase().defaultClient(); } - default KurrentDBProjectionManagementClient getDefaultProjectionClient() { - return KurrentDBProjectionManagementClient.from(getDefaultClient()); + default TrogonEventStoreProjectionManagementClient getDefaultProjectionClient() { + return TrogonEventStoreProjectionManagementClient.from(getDefaultClient()); } - default KurrentDBPersistentSubscriptionsClient getDefaultPersistentSubscriptionClient() { - return KurrentDBPersistentSubscriptionsClient.from(getDefaultClient()); + default TrogonEventStorePersistentSubscriptionsClient getDefaultPersistentSubscriptionClient() { + return TrogonEventStorePersistentSubscriptionsClient.from(getDefaultClient()); } default String generateName() { diff --git a/src/test/java/io/kurrent/dbclient/Database.java b/src/test/java/io/trogonstack/eventstore/client/Database.java similarity index 75% rename from src/test/java/io/kurrent/dbclient/Database.java rename to src/test/java/io/trogonstack/eventstore/client/Database.java index c8ad58a..012d936 100644 --- a/src/test/java/io/kurrent/dbclient/Database.java +++ b/src/test/java/io/trogonstack/eventstore/client/Database.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,19 +15,19 @@ public interface Database { void cleanup(); - default KurrentDBClient newClient() { + default TrogonEventStoreClient newClient() { return connectWith(Function.identity()); } - default KurrentDBClient connectWith(Function mod) { + default TrogonEventStoreClient connectWith(Function mod) { return createClient(mod.apply(defaultSettingsBuilder()).buildConnectionSettings()); } - default KurrentDBClient defaultClient() { + default TrogonEventStoreClient defaultClient() { return getClientTracker().getDefaultClient(this); } - default KurrentDBClient createClient(KurrentDBClientSettings settings) { + default TrogonEventStoreClient createClient(TrogonEventStoreClientSettings settings) { return getClientTracker().createClient(settings); } diff --git a/src/test/java/io/kurrent/dbclient/DatabaseFactory.java b/src/test/java/io/trogonstack/eventstore/client/DatabaseFactory.java similarity index 83% rename from src/test/java/io/kurrent/dbclient/DatabaseFactory.java rename to src/test/java/io/trogonstack/eventstore/client/DatabaseFactory.java index 5f17d8c..5144cbf 100644 --- a/src/test/java/io/kurrent/dbclient/DatabaseFactory.java +++ b/src/test/java/io/trogonstack/eventstore/client/DatabaseFactory.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.databases.DockerContainerDatabase; -import io.kurrent.dbclient.databases.ExternallyCreatedCluster; +import io.trogonstack.eventstore.client.databases.DockerContainerDatabase; +import io.trogonstack.eventstore.client.databases.ExternallyCreatedCluster; import java.util.Optional; @@ -37,7 +37,7 @@ private static DockerContainerDatabase.Builder singleNodeBuilder() { return DockerContainerDatabase .builder() .image(Optional - .ofNullable(System.getenv("KURRENTDB_IMAGE")) + .ofNullable(System.getenv("TROGON_EVENTSTORE_IMAGE")) .orElse(DockerContainerDatabase.DEFAULT_IMAGE)); } } diff --git a/src/test/java/io/kurrent/dbclient/Exceptions.java b/src/test/java/io/trogonstack/eventstore/client/Exceptions.java similarity index 96% rename from src/test/java/io/kurrent/dbclient/Exceptions.java rename to src/test/java/io/trogonstack/eventstore/client/Exceptions.java index eaf7d77..e95c6b8 100644 --- a/src/test/java/io/kurrent/dbclient/Exceptions.java +++ b/src/test/java/io/trogonstack/eventstore/client/Exceptions.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.Status; import io.grpc.StatusRuntimeException; diff --git a/src/test/java/io/kurrent/dbclient/Foo.java b/src/test/java/io/trogonstack/eventstore/client/Foo.java similarity index 92% rename from src/test/java/io/kurrent/dbclient/Foo.java rename to src/test/java/io/trogonstack/eventstore/client/Foo.java index abd989a..3d67d62 100644 --- a/src/test/java/io/kurrent/dbclient/Foo.java +++ b/src/test/java/io/trogonstack/eventstore/client/Foo.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import java.util.Objects; diff --git a/src/test/java/io/kurrent/dbclient/LeaderRedirectUnitTest.java b/src/test/java/io/trogonstack/eventstore/client/LeaderRedirectUnitTest.java similarity index 98% rename from src/test/java/io/kurrent/dbclient/LeaderRedirectUnitTest.java rename to src/test/java/io/trogonstack/eventstore/client/LeaderRedirectUnitTest.java index 0a37246..15be802 100644 --- a/src/test/java/io/kurrent/dbclient/LeaderRedirectUnitTest.java +++ b/src/test/java/io/trogonstack/eventstore/client/LeaderRedirectUnitTest.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import io.grpc.Metadata; import io.grpc.Status; diff --git a/src/test/java/io/kurrent/dbclient/MiscTests.java b/src/test/java/io/trogonstack/eventstore/client/MiscTests.java similarity index 72% rename from src/test/java/io/kurrent/dbclient/MiscTests.java rename to src/test/java/io/trogonstack/eventstore/client/MiscTests.java index 658a278..600a31f 100644 --- a/src/test/java/io/kurrent/dbclient/MiscTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/MiscTests.java @@ -1,10 +1,10 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.SelectPackages; import org.junit.platform.suite.api.Suite; @Suite -@SelectPackages("io.kurrent.dbclient.misc") +@SelectPackages("io.trogonstack.eventstore.client.misc") @SelectClasses({SubscriptionStreamConsumerTests.class, LeaderRedirectUnitTest.class}) public class MiscTests {} diff --git a/src/test/java/io/kurrent/dbclient/PersistentSubscriptionsTests.java b/src/test/java/io/trogonstack/eventstore/client/PersistentSubscriptionsTests.java similarity index 81% rename from src/test/java/io/kurrent/dbclient/PersistentSubscriptionsTests.java rename to src/test/java/io/trogonstack/eventstore/client/PersistentSubscriptionsTests.java index c8a3e54..f7bcc57 100644 --- a/src/test/java/io/kurrent/dbclient/PersistentSubscriptionsTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/PersistentSubscriptionsTests.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.persistentsubscriptions.*; -import io.kurrent.dbclient.persistentsubscriptions.PersistentSubscriptionToAllWithFilterTests; +import io.trogonstack.eventstore.client.persistentsubscriptions.*; +import io.trogonstack.eventstore.client.persistentsubscriptions.PersistentSubscriptionToAllWithFilterTests; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.slf4j.Logger; diff --git a/src/test/java/io/kurrent/dbclient/PluginsTests.java b/src/test/java/io/trogonstack/eventstore/client/PluginsTests.java similarity index 78% rename from src/test/java/io/kurrent/dbclient/PluginsTests.java rename to src/test/java/io/trogonstack/eventstore/client/PluginsTests.java index 9cbd3bb..1ca0131 100644 --- a/src/test/java/io/kurrent/dbclient/PluginsTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/PluginsTests.java @@ -1,13 +1,13 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.plugins.ClientCertificateAuthenticationTests; +import io.trogonstack.eventstore.client.plugins.ClientCertificateAuthenticationTests; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * PluginsTests require the enterprise edition of KurrentDB (>= 24.2.0). + * PluginsTests require the enterprise edition of TrogonEventStore (>= 24.2.0). */ public class PluginsTests implements ClientCertificateAuthenticationTests { static private Database database; diff --git a/src/test/java/io/kurrent/dbclient/StreamsTests.java b/src/test/java/io/trogonstack/eventstore/client/StreamsTests.java similarity index 84% rename from src/test/java/io/kurrent/dbclient/StreamsTests.java rename to src/test/java/io/trogonstack/eventstore/client/StreamsTests.java index 571ef25..150e1a1 100644 --- a/src/test/java/io/kurrent/dbclient/StreamsTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/StreamsTests.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.streams.*; -import io.kurrent.dbclient.streams.ReadStreamTests; +import io.trogonstack.eventstore.client.streams.*; +import io.trogonstack.eventstore.client.streams.ReadStreamTests; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.slf4j.Logger; diff --git a/src/test/java/io/kurrent/dbclient/SubscriptionStreamConsumerTests.java b/src/test/java/io/trogonstack/eventstore/client/SubscriptionStreamConsumerTests.java similarity index 98% rename from src/test/java/io/kurrent/dbclient/SubscriptionStreamConsumerTests.java rename to src/test/java/io/trogonstack/eventstore/client/SubscriptionStreamConsumerTests.java index 160bcb2..25a2cc8 100644 --- a/src/test/java/io/kurrent/dbclient/SubscriptionStreamConsumerTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/SubscriptionStreamConsumerTests.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/kurrent/dbclient/TelemetryTests.java b/src/test/java/io/trogonstack/eventstore/client/TelemetryTests.java similarity index 79% rename from src/test/java/io/kurrent/dbclient/TelemetryTests.java rename to src/test/java/io/trogonstack/eventstore/client/TelemetryTests.java index 5bfc015..60c8018 100644 --- a/src/test/java/io/kurrent/dbclient/TelemetryTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/TelemetryTests.java @@ -1,18 +1,17 @@ -package io.kurrent.dbclient; +package io.trogonstack.eventstore.client; -import io.kurrent.dbclient.telemetry.PersistentSubscriptionsTracingInstrumentationTests; -import io.kurrent.dbclient.telemetry.SpanProcessorSpy; -import io.kurrent.dbclient.telemetry.StreamsTracingInstrumentationTests; -import io.kurrent.dbclient.telemetry.TracingContextInjectionTests; +import io.trogonstack.eventstore.client.telemetry.PersistentSubscriptionsTracingInstrumentationTests; +import io.trogonstack.eventstore.client.telemetry.SpanProcessorSpy; +import io.trogonstack.eventstore.client.telemetry.StreamsTracingInstrumentationTests; +import io.trogonstack.eventstore.client.telemetry.TracingContextInjectionTests; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.common.AttributeKey; -import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.trace.ReadableSpan; import io.opentelemetry.sdk.trace.SdkTracerProvider; -import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.slf4j.Logger; @@ -44,24 +43,24 @@ public void beforeEach() { GlobalOpenTelemetry.resetForTest(); spanEndedHooks.add(recordedSpans::add); - OtlpGrpcSpanExporter otlpExporter = OtlpGrpcSpanExporter.builder() - .setEndpoint("http://localhost:4317") - .build(); - Resource resource = Resource.getDefault().toBuilder() - .put(SERVICE_NAME, "kurrentdb") + .put(SERVICE_NAME, "trogon_eventstore") .build(); OpenTelemetrySdk.builder() .setTracerProvider(SdkTracerProvider .builder() .addSpanProcessor(new SpanProcessorSpy(spanEndedHooks)) - .addSpanProcessor(SimpleSpanProcessor.create(otlpExporter)) .setResource(resource) .build()) .buildAndRegisterGlobal(); } + @AfterEach + public void afterEach() { + GlobalOpenTelemetry.resetForTest(); + } + @Override public void onOperationSpanEnded(String operation, Consumer onSpanEnded) { spanEndedHooks.add(span -> { diff --git a/src/test/java/io/kurrent/dbclient/connection/ConnectionShutdownTests.java b/src/test/java/io/trogonstack/eventstore/client/connection/ConnectionShutdownTests.java similarity index 91% rename from src/test/java/io/kurrent/dbclient/connection/ConnectionShutdownTests.java rename to src/test/java/io/trogonstack/eventstore/client/connection/ConnectionShutdownTests.java index 0afe060..f7a3fdb 100644 --- a/src/test/java/io/kurrent/dbclient/connection/ConnectionShutdownTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/connection/ConnectionShutdownTests.java @@ -1,62 +1,62 @@ -package io.kurrent.dbclient.connection; - -import io.kurrent.dbclient.*; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -public class ConnectionShutdownTests { - @Test - @Timeout(value = 1, unit = TimeUnit.MINUTES) - public void testDatabaseCleanupWithActiveSubscription() throws Throwable { - Database testDatabase = DatabaseFactory.spawn(); - KurrentDBClient client = testDatabase.defaultClient(); - - final AtomicInteger count = new AtomicInteger(0); - final AtomicInteger retryCount = new AtomicInteger(-1); - final AtomicBoolean cancellationReceived = new AtomicBoolean(false); - final CountDownLatch cancellationLatch = new CountDownLatch(1); - final AtomicReference reconnectError = new AtomicReference<>(); - - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - count.incrementAndGet(); - } - - @Override - public void onCancelled(Subscription subscription, Throwable throwable) { - cancellationReceived.set(true); - - retryCount.incrementAndGet(); - - try { - client.subscribeToAll(this).get(10, TimeUnit.SECONDS); - } catch (Throwable ex) { - reconnectError.set(ex); - } finally { - cancellationLatch.countDown(); - } - } - }; - - client.subscribeToAll(listener).get(); - - testDatabase.dispose(); - - boolean callbackReceived = cancellationLatch.await(30, TimeUnit.SECONDS); - Assertions.assertTrue(callbackReceived); - Assertions.assertTrue(cancellationReceived.get()); - Assertions.assertTrue(count.get() > 0); - Assertions.assertEquals(2, retryCount.get()); - - Throwable ex = reconnectError.get(); - Assertions.assertInstanceOf(ConnectionShutdownException.class, ex.getCause()); - } -} +package io.trogonstack.eventstore.client.connection; + +import io.trogonstack.eventstore.client.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; + +public class ConnectionShutdownTests { + @Test + @Timeout(value = 1, unit = TimeUnit.MINUTES) + public void testDatabaseCleanupWithActiveSubscription() throws Throwable { + Database testDatabase = DatabaseFactory.spawn(); + TrogonEventStoreClient client = testDatabase.defaultClient(); + + final AtomicInteger count = new AtomicInteger(0); + final AtomicInteger retryCount = new AtomicInteger(-1); + final AtomicBoolean cancellationReceived = new AtomicBoolean(false); + final CountDownLatch cancellationLatch = new CountDownLatch(1); + final AtomicReference reconnectError = new AtomicReference<>(); + + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + count.incrementAndGet(); + } + + @Override + public void onCancelled(Subscription subscription, Throwable throwable) { + cancellationReceived.set(true); + + retryCount.incrementAndGet(); + + try { + client.subscribeToAll(this).get(10, TimeUnit.SECONDS); + } catch (Throwable ex) { + reconnectError.set(ex); + } finally { + cancellationLatch.countDown(); + } + } + }; + + client.subscribeToAll(listener).get(); + + testDatabase.dispose(); + + boolean callbackReceived = cancellationLatch.await(30, TimeUnit.SECONDS); + Assertions.assertTrue(callbackReceived); + Assertions.assertTrue(cancellationReceived.get()); + Assertions.assertTrue(count.get() > 0); + Assertions.assertEquals(2, retryCount.get()); + + Throwable ex = reconnectError.get(); + Assertions.assertInstanceOf(ConnectionShutdownException.class, ex.getCause()); + } +} diff --git a/src/test/java/io/kurrent/dbclient/databases/DockerContainerDatabase.java b/src/test/java/io/trogonstack/eventstore/client/databases/DockerContainerDatabase.java similarity index 91% rename from src/test/java/io/kurrent/dbclient/databases/DockerContainerDatabase.java rename to src/test/java/io/trogonstack/eventstore/client/databases/DockerContainerDatabase.java index 656634f..69d98b0 100644 --- a/src/test/java/io/kurrent/dbclient/databases/DockerContainerDatabase.java +++ b/src/test/java/io/trogonstack/eventstore/client/databases/DockerContainerDatabase.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.databases; +package io.trogonstack.eventstore.client.databases; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import com.github.dockerjava.api.model.HealthCheck; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; @@ -12,7 +12,7 @@ import java.util.Map; public class DockerContainerDatabase extends GenericContainer implements Database { - public static final String DEFAULT_IMAGE = "docker.cloudsmith.io/eventstore/kurrent-staging/kurrentdb:ci"; + public static final String DEFAULT_IMAGE = "ghcr.io/trogonstack/trogoneventstore:ci"; public static class Builder { String image; @@ -58,8 +58,7 @@ public DockerContainerDatabase(Builder builder) { withEnv("EVENTSTORE_RUN_PROJECTIONS", "ALL"); withEnv("EVENTSTORE_START_STANDARD_PROJECTIONS", "true"); - withEnv("EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP", "true"); - + withEnv("EVENTSTORE_COMPRESSION_LEVEL", "NoCompression"); if (builder.secure) { verifyCertificatesExist(); String certsDir = Paths.get(System.getProperty("user.dir"), "certs").toAbsolutePath().toString(); @@ -89,7 +88,7 @@ public DockerContainerDatabase(Builder builder) { @Override public ConnectionSettingsBuilder defaultSettingsBuilder() { - ConnectionSettingsBuilder settingsBuilder = KurrentDBClientSettings.builder().addHost(getHost(), getMappedPort(2113)); + ConnectionSettingsBuilder settingsBuilder = TrogonEventStoreClientSettings.builder().addHost(getHost(), getMappedPort(2113)); if (!builder.anonymous) settingsBuilder.defaultCredentials("admin", "changeit"); diff --git a/src/test/java/io/kurrent/dbclient/databases/ExternallyCreatedCluster.java b/src/test/java/io/trogonstack/eventstore/client/databases/ExternallyCreatedCluster.java similarity index 85% rename from src/test/java/io/kurrent/dbclient/databases/ExternallyCreatedCluster.java rename to src/test/java/io/trogonstack/eventstore/client/databases/ExternallyCreatedCluster.java index e0f86a5..20a8d89 100644 --- a/src/test/java/io/kurrent/dbclient/databases/ExternallyCreatedCluster.java +++ b/src/test/java/io/trogonstack/eventstore/client/databases/ExternallyCreatedCluster.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.databases; +package io.trogonstack.eventstore.client.databases; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; public class ExternallyCreatedCluster implements Database { final private boolean secure; @@ -13,7 +13,7 @@ public ExternallyCreatedCluster(boolean secure) { @Override public ConnectionSettingsBuilder defaultSettingsBuilder() { - return KurrentDBClientSettings + return TrogonEventStoreClientSettings .builder() .dnsDiscover(true) .defaultCredentials("admin", "changeit") diff --git a/src/test/java/io/kurrent/dbclient/misc/EventDataTests.java b/src/test/java/io/trogonstack/eventstore/client/misc/EventDataTests.java similarity index 80% rename from src/test/java/io/kurrent/dbclient/misc/EventDataTests.java rename to src/test/java/io/trogonstack/eventstore/client/misc/EventDataTests.java index f0bb8a7..0bff877 100644 --- a/src/test/java/io/kurrent/dbclient/misc/EventDataTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/misc/EventDataTests.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient.misc; +package io.trogonstack.eventstore.client.misc; -import io.kurrent.dbclient.EventData; -import io.kurrent.dbclient.EventDataBuilder; +import io.trogonstack.eventstore.client.EventData; +import io.trogonstack.eventstore.client.EventDataBuilder; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/kurrent/dbclient/misc/ExpectedRevisionTests.java b/src/test/java/io/trogonstack/eventstore/client/misc/ExpectedRevisionTests.java similarity index 96% rename from src/test/java/io/kurrent/dbclient/misc/ExpectedRevisionTests.java rename to src/test/java/io/trogonstack/eventstore/client/misc/ExpectedRevisionTests.java index cf974d5..cfcef6d 100644 --- a/src/test/java/io/kurrent/dbclient/misc/ExpectedRevisionTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/misc/ExpectedRevisionTests.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient.misc; +package io.trogonstack.eventstore.client.misc; -import io.kurrent.dbclient.StreamState; +import io.trogonstack.eventstore.client.StreamState; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/kurrent/dbclient/misc/NodeSelectorTest.java b/src/test/java/io/trogonstack/eventstore/client/misc/NodeSelectorTest.java similarity index 95% rename from src/test/java/io/kurrent/dbclient/misc/NodeSelectorTest.java rename to src/test/java/io/trogonstack/eventstore/client/misc/NodeSelectorTest.java index fe2f48b..dca1ae7 100644 --- a/src/test/java/io/kurrent/dbclient/misc/NodeSelectorTest.java +++ b/src/test/java/io/trogonstack/eventstore/client/misc/NodeSelectorTest.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient.misc; +package io.trogonstack.eventstore.client.misc; -import io.kurrent.dbclient.ClusterInfo; -import io.kurrent.dbclient.NodePreference; -import io.kurrent.dbclient.NodeSelector; +import io.trogonstack.eventstore.client.ClusterInfo; +import io.trogonstack.eventstore.client.NodePreference; +import io.trogonstack.eventstore.client.NodeSelector; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/kurrent/dbclient/misc/OfflineMetadataTests.java b/src/test/java/io/trogonstack/eventstore/client/misc/OfflineMetadataTests.java similarity index 89% rename from src/test/java/io/kurrent/dbclient/misc/OfflineMetadataTests.java rename to src/test/java/io/trogonstack/eventstore/client/misc/OfflineMetadataTests.java index 541e2b3..e7560dc 100644 --- a/src/test/java/io/kurrent/dbclient/misc/OfflineMetadataTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/misc/OfflineMetadataTests.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient.misc; +package io.trogonstack.eventstore.client.misc; -import io.kurrent.dbclient.Acl; -import io.kurrent.dbclient.Acls; -import io.kurrent.dbclient.StreamMetadata; +import io.trogonstack.eventstore.client.Acl; +import io.trogonstack.eventstore.client.Acls; +import io.trogonstack.eventstore.client.StreamMetadata; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/trogonstack/eventstore/client/misc/ParseInvalidConnectionStringTests.java b/src/test/java/io/trogonstack/eventstore/client/misc/ParseInvalidConnectionStringTests.java new file mode 100644 index 0000000..29921a7 --- /dev/null +++ b/src/test/java/io/trogonstack/eventstore/client/misc/ParseInvalidConnectionStringTests.java @@ -0,0 +1,41 @@ +package io.trogonstack.eventstore.client.misc; + +import io.trogonstack.eventstore.client.ConnectionStringParsingException; +import io.trogonstack.eventstore.client.TrogonEventStoreConnectionString; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +public class ParseInvalidConnectionStringTests { + public static Stream invalidConnectionStrings() { + return Stream.of( + Arguments.of("localhost"), + Arguments.of("https://example.com/"), + Arguments.of("trogon-invalid+discovery://localhost"), + Arguments.of("trogon-invalid://my:great@username:UyeXx8$^PsOo4jG88FlCauR1Coz25q@host?nodePreference=follower&tlsVerifyCert=false"), + Arguments.of("trogon-invalid://host1,host2:200:300?tlsVerifyCert=false"), + Arguments.of("trogon-invalid://localhost/&tlsVerifyCert=false"), + Arguments.of("trogon-invalid://localhost?tlsVerifyCert=false?nodePreference=follower"), + Arguments.of("trogon-invalid://localhost?tlsVerifyCert=false&nodePreference=any"), + Arguments.of("trogon-invalid://localhost?tlsVerifyCert=if you feel like it"), + Arguments.of("trogon-invalid://localhost?keepAliveInterval=-3"), + Arguments.of("trogon-invalid://localhost?keepAliveInterval=sdfksjsfl"), + Arguments.of("trogon-invalid://localhost?keepAliveTimeout=sdfksjsfl"), + Arguments.of("trogon-invalid://localhost?keepAliveTimeout=-3"), + Arguments.of("trogon-invalid://localhost?nodePreference=read_only_replica"), + Arguments.of("trogon-invalid://localhost?userCertFile=/path/to/cert"), + Arguments.of("trogon-invalid://localhost?userKeyFile=/path/to/key") + ); + } + + @ParameterizedTest + @MethodSource("invalidConnectionStrings") + public void test(String input) throws ConnectionStringParsingException { + Assertions.assertThrows(RuntimeException.class, () -> { + TrogonEventStoreConnectionString.parseOrThrow(input); + }); + } +} diff --git a/src/test/java/io/kurrent/dbclient/misc/ParseValidConnectionStringTests.java b/src/test/java/io/trogonstack/eventstore/client/misc/ParseValidConnectionStringTests.java similarity index 94% rename from src/test/java/io/kurrent/dbclient/misc/ParseValidConnectionStringTests.java rename to src/test/java/io/trogonstack/eventstore/client/misc/ParseValidConnectionStringTests.java index 46fd2a8..b7031f6 100644 --- a/src/test/java/io/kurrent/dbclient/misc/ParseValidConnectionStringTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/misc/ParseValidConnectionStringTests.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient.misc; +package io.trogonstack.eventstore.client.misc; import java.net.InetSocketAddress; import java.util.Arrays; @@ -6,7 +6,7 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.json.JsonMapper; @@ -18,7 +18,7 @@ public class ParseValidConnectionStringTests { private final JsonMapper mapper = new JsonMapper(); - private static final List PROTOCOLS = Arrays.asList("esdb", "kurrentdb", "kdb"); + private static final List PROTOCOLS = Arrays.asList("trogon-eventstore"); public static Stream validConnectionStrings() { List baseConnectionStrings = Arrays.asList( @@ -59,8 +59,8 @@ public static Stream validConnectionStrings() { "{\"dnsDiscover\":false,\"maxDiscoverAttempts\":3,\"discoveryInterval\":500,\"gossipTimeout\":3000,\"nodePreference\":\"leader\",\"tls\":true,\"tlsVerifyCert\":true,\"throwOnAppendFailure\":true,\"hosts\":[{\"address\":\"host1\",\"port\":1234},{\"address\":\"host2\",\"port\":4321},{\"address\":\"host3\",\"port\":3231}]}" ), Arguments.of( - "://bubaqp2rh41uf5akmj0g-0.mesdb.eventstore.cloud:2113,bubaqp2rh41uf5akmj0g-1.mesdb.eventstore.cloud:2113,bubaqp2rh41uf5akmj0g-2.mesdb.eventstore.cloud:2113", - "{\"dnsDiscover\":false,\"maxDiscoverAttempts\":3,\"discoveryInterval\":500,\"gossipTimeout\":3000,\"nodePreference\":\"leader\",\"tls\":true,\"tlsVerifyCert\":true,\"throwOnAppendFailure\":true,\"hosts\":[{\"address\":\"bubaqp2rh41uf5akmj0g-0.mesdb.eventstore.cloud\",\"port\":2113},{\"address\":\"bubaqp2rh41uf5akmj0g-1.mesdb.eventstore.cloud\",\"port\":2113},{\"address\":\"bubaqp2rh41uf5akmj0g-2.mesdb.eventstore.cloud\",\"port\":2113}]}" + "://node.example.com:2113,node.example.com:2113,node.example.com:2113", + "{\"dnsDiscover\":false,\"maxDiscoverAttempts\":3,\"discoveryInterval\":500,\"gossipTimeout\":3000,\"nodePreference\":\"leader\",\"tls\":true,\"tlsVerifyCert\":true,\"throwOnAppendFailure\":true,\"hosts\":[{\"address\":\"node.example.com\",\"port\":2113},{\"address\":\"node.example.com\",\"port\":2113},{\"address\":\"node.example.com\",\"port\":2113}]}" ), Arguments.of( "://user:pass@host1:1234,host2:4321,host3:3231?nodePreference=follower", @@ -129,7 +129,7 @@ public static Stream validConnectionStrings() { .map(protocol -> Arguments.of(protocol + base.get()[0], base.get()[1]))); } - public void assertEquals(KurrentDBClientSettings settings, KurrentDBClientSettings other) { + public void assertEquals(TrogonEventStoreClientSettings settings, TrogonEventStoreClientSettings other) { Assertions.assertEquals(settings.isDnsDiscover(), other.isDnsDiscover()); Assertions.assertEquals(settings.getMaxDiscoverAttempts(), other.getMaxDiscoverAttempts()); Assertions.assertEquals(settings.getDiscoveryInterval(), other.getDiscoveryInterval()); @@ -154,14 +154,14 @@ public void assertEquals(KurrentDBClientSettings settings, KurrentDBClientSettin @MethodSource("validConnectionStrings") public void test(String connectionString, String json) throws ConnectionStringParsingException, JsonProcessingException { - KurrentDBClientSettings expectedSettings = this.parseJson(json); - KurrentDBClientSettings parsedSettings = KurrentDBConnectionString.parseOrThrow(connectionString); + TrogonEventStoreClientSettings expectedSettings = this.parseJson(json); + TrogonEventStoreClientSettings parsedSettings = TrogonEventStoreConnectionString.parseOrThrow(connectionString); this.assertEquals(expectedSettings, parsedSettings); } - private KurrentDBClientSettings parseJson(String input) throws JsonProcessingException { - ConnectionSettingsBuilder builder = KurrentDBClientSettings.builder(); + private TrogonEventStoreClientSettings parseJson(String input) throws JsonProcessingException { + ConnectionSettingsBuilder builder = TrogonEventStoreClientSettings.builder(); JsonNode tree = mapper.readTree(input); if (tree.get("dnsDiscover") != null) diff --git a/src/test/java/io/kurrent/dbclient/misc/PositionTests.java b/src/test/java/io/trogonstack/eventstore/client/misc/PositionTests.java similarity index 95% rename from src/test/java/io/kurrent/dbclient/misc/PositionTests.java rename to src/test/java/io/trogonstack/eventstore/client/misc/PositionTests.java index 25ecb1e..791f77f 100644 --- a/src/test/java/io/kurrent/dbclient/misc/PositionTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/misc/PositionTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.misc; +package io.trogonstack.eventstore.client.misc; -import io.kurrent.dbclient.Position; +import io.trogonstack.eventstore.client.Position; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/kurrent/dbclient/misc/ServerVersionTests.java b/src/test/java/io/trogonstack/eventstore/client/misc/ServerVersionTests.java similarity index 94% rename from src/test/java/io/kurrent/dbclient/misc/ServerVersionTests.java rename to src/test/java/io/trogonstack/eventstore/client/misc/ServerVersionTests.java index 660a2a5..4d50d53 100644 --- a/src/test/java/io/kurrent/dbclient/misc/ServerVersionTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/misc/ServerVersionTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.misc; +package io.trogonstack.eventstore.client.misc; -import io.kurrent.dbclient.ServerVersion; +import io.trogonstack.eventstore.client.ServerVersion; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/CreatePersistentSubscriptionTests.java b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/CreatePersistentSubscriptionTests.java similarity index 69% rename from src/test/java/io/kurrent/dbclient/persistentsubscriptions/CreatePersistentSubscriptionTests.java rename to src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/CreatePersistentSubscriptionTests.java index 0d2c675..0d908e1 100644 --- a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/CreatePersistentSubscriptionTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/CreatePersistentSubscriptionTests.java @@ -1,12 +1,12 @@ -package io.kurrent.dbclient.persistentsubscriptions; +package io.trogonstack.eventstore.client.persistentsubscriptions; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Test; public interface CreatePersistentSubscriptionTests extends ConnectionAware { @Test default void testCreatePersistentSub() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); client.createToStream(generateName(), generateName()) .get(); @@ -17,7 +17,7 @@ default void testCreatePersistentSub() throws Throwable { @Test default void testCreatePersistentSubToAll() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); client.createToAll(generateName()) .get(); diff --git a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/DeletePersistentSubscriptionToStreamTests.java b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/DeletePersistentSubscriptionToStreamTests.java similarity index 62% rename from src/test/java/io/kurrent/dbclient/persistentsubscriptions/DeletePersistentSubscriptionToStreamTests.java rename to src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/DeletePersistentSubscriptionToStreamTests.java index c5191ff..d3418ef 100644 --- a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/DeletePersistentSubscriptionToStreamTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/DeletePersistentSubscriptionToStreamTests.java @@ -1,13 +1,13 @@ -package io.kurrent.dbclient.persistentsubscriptions; +package io.trogonstack.eventstore.client.persistentsubscriptions; -import io.kurrent.dbclient.ConnectionAware; -import io.kurrent.dbclient.KurrentDBPersistentSubscriptionsClient; +import io.trogonstack.eventstore.client.ConnectionAware; +import io.trogonstack.eventstore.client.TrogonEventStorePersistentSubscriptionsClient; import org.junit.jupiter.api.Test; public interface DeletePersistentSubscriptionToStreamTests extends ConnectionAware { @Test default void testDeletePersistentSub() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String streamName = generateName(); String groupName = generateName(); @@ -20,7 +20,7 @@ default void testDeletePersistentSub() throws Throwable { @Test default void testDeletePersistentSubToAll() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String groupName = generateName(); client.createToAll(groupName) diff --git a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/PersistentSubscriptionManagementTests.java b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/PersistentSubscriptionManagementTests.java similarity index 88% rename from src/test/java/io/kurrent/dbclient/persistentsubscriptions/PersistentSubscriptionManagementTests.java rename to src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/PersistentSubscriptionManagementTests.java index c87a2d2..9691945 100644 --- a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/PersistentSubscriptionManagementTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/PersistentSubscriptionManagementTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.persistentsubscriptions; +package io.trogonstack.eventstore.client.persistentsubscriptions; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import com.fasterxml.jackson.databind.json.JsonMapper; import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtensionContext; @@ -19,7 +19,7 @@ public interface PersistentSubscriptionManagementTests extends ConnectionAware { @Test @Order(1) default void testListPersistentSubscriptions() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String groupName = generateName(); String streamA = generateName(); String streamB = generateName(); @@ -47,7 +47,7 @@ default void testListPersistentSubscriptions() throws Throwable { default void testListPersistentSubscriptionsForStream() throws Throwable { Exceptions exceptions = new Exceptions().registerGoAwayError(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String streamName = generateName(); String groupName = generateName(); @@ -64,7 +64,7 @@ default void testListPersistentSubscriptionsForStream() throws Throwable { @Test @Order(3) default void testListPersistentSubscriptionsToAll() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String groupName = generateName(); client.createToAll(groupName) .get(); @@ -88,7 +88,7 @@ default void testListPersistentSubscriptionsToAll() throws Throwable { @Test @Order(4) default void testGetPersistentSubscriptionInfo() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String streamName = generateName(); String groupName = generateName(); client.createToStream(streamName, groupName) @@ -111,7 +111,7 @@ default void testGetPersistentSubscriptionInfo() throws Throwable { @Test @Order(5) default void testGetPersistentSubscriptionInfoToAll() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String groupName = generateName(); client.createToAll(groupName) @@ -127,7 +127,7 @@ default void testGetPersistentSubscriptionInfoToAll() throws Throwable { @Test @Order(6) default void testGetPersistentSubscriptionInfoNotExisting() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); Optional result = client.getInfoToStream(generateName(), generateName()).get(); Assertions.assertFalse(result.isPresent()); @@ -138,8 +138,8 @@ default void testGetPersistentSubscriptionInfoNotExisting() throws Throwable { @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testReplayParkedMessages() throws Throwable { Exceptions exceptions = new Exceptions().registerGoAwayError(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); - final KurrentDBClient streamClient = getDatabase().defaultClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + final TrogonEventStoreClient streamClient = getDatabase().defaultClient(); final JsonMapper jsonMapper = new JsonMapper(); final String streamName = generateName(); final String groupName = generateName(); @@ -198,8 +198,8 @@ public void onEvent(PersistentSubscription subscription, int retryCount, Resolve @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testReplayParkedMessagesToAll() throws Throwable { Exceptions exceptions = new Exceptions().registerGoAwayError(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); - final KurrentDBClient streamClient = getDatabase().defaultClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + final TrogonEventStoreClient streamClient = getDatabase().defaultClient(); final JsonMapper jsonMapper = new JsonMapper(); String streamName = generateName(); String groupName = generateName(); @@ -257,7 +257,7 @@ public void onEvent(PersistentSubscription subscription, int retryCount, Resolve @Order(9) default void testEncoding() throws Throwable { Exceptions exceptions = new Exceptions().registerGoAwayError(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String streamName = String.format("/foo/%s/stream", generateName()); String groupName = String.format("/foo/%s/group", generateName()); @@ -282,14 +282,14 @@ default void testEncoding() throws Throwable { @Test @Order(10) default void testRestartSubsystem() throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); client.restartSubsystem().get(); } @ParameterizedTest @ArgumentsSource(NamedConsumerStrategyProvider.class) default void testCreatePersistentSubscriptionToAllWithConsumerStrategies(NamedConsumerStrategy strategy) throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String groupName = String.format("/foo/%s/group", generateName()); CreatePersistentSubscriptionToAllOptions options = CreatePersistentSubscriptionToAllOptions.get() @@ -307,7 +307,7 @@ default void testCreatePersistentSubscriptionToAllWithConsumerStrategies(NamedCo @ParameterizedTest @ArgumentsSource(NamedConsumerStrategyProvider.class) default void testCreatePersistentSubscriptionToStreamWithConsumerStrategies(NamedConsumerStrategy strategy) throws Throwable { - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); String streamName = String.format("/foo/%s/stream", generateName()); String groupName = String.format("/foo/%s/group", generateName()); diff --git a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/PersistentSubscriptionToAllWithFilterTests.java b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/PersistentSubscriptionToAllWithFilterTests.java similarity index 90% rename from src/test/java/io/kurrent/dbclient/persistentsubscriptions/PersistentSubscriptionToAllWithFilterTests.java rename to src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/PersistentSubscriptionToAllWithFilterTests.java index 2df00e0..9423b68 100644 --- a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/PersistentSubscriptionToAllWithFilterTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/PersistentSubscriptionToAllWithFilterTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.persistentsubscriptions; +package io.trogonstack.eventstore.client.persistentsubscriptions; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -11,8 +11,8 @@ public interface PersistentSubscriptionToAllWithFilterTests extends ConnectionAw @Test default void testPersistentSubscriptionToAllWithFilter() throws Throwable { Exceptions exceptions = new Exceptions().registerGoAwayError(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); - KurrentDBClient streamsClient = getDatabase().defaultClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStoreClient streamsClient = getDatabase().defaultClient(); String groupName = generateName(); int filteredEventTypeCount = 10; String filteredEventType = "filtered-event-type"; diff --git a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/SubscribePersistentSubscriptionToStreamTests.java b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/SubscribePersistentSubscriptionToStreamTests.java similarity index 89% rename from src/test/java/io/kurrent/dbclient/persistentsubscriptions/SubscribePersistentSubscriptionToStreamTests.java rename to src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/SubscribePersistentSubscriptionToStreamTests.java index 016396c..15e1d14 100644 --- a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/SubscribePersistentSubscriptionToStreamTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/SubscribePersistentSubscriptionToStreamTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.persistentsubscriptions; +package io.trogonstack.eventstore.client.persistentsubscriptions; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import com.fasterxml.jackson.databind.json.JsonMapper; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -12,8 +12,8 @@ public interface SubscribePersistentSubscriptionToStreamTests extends Connection default void testSubscribePersistentSub() throws Throwable { Exceptions exceptions = new Exceptions().registerGoAwayError(); String streamName = generateName(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); - KurrentDBClient streamsClient = getDatabase().defaultClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStoreClient streamsClient = getDatabase().defaultClient(); JsonMapper jsonMapper = new JsonMapper(); flaky(10, exceptions, () -> client.createToStream(streamName, "aGroup") @@ -65,8 +65,8 @@ public void onCancelled(PersistentSubscription subscription, Throwable throwable default void testSubscribePersistentSubToAll() throws Throwable { Exceptions exceptions = new Exceptions().registerGoAwayError(); String streamName = generateName(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); - KurrentDBClient streamsClient = getDatabase().defaultClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStoreClient streamsClient = getDatabase().defaultClient(); final JsonMapper jsonMapper = new JsonMapper(); flaky(10, exceptions, () -> client.createToAll("aGroup") diff --git a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/UpdatePersistentSubscriptionToStreamTests.java b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/UpdatePersistentSubscriptionToStreamTests.java similarity index 69% rename from src/test/java/io/kurrent/dbclient/persistentsubscriptions/UpdatePersistentSubscriptionToStreamTests.java rename to src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/UpdatePersistentSubscriptionToStreamTests.java index bd5414c..48b32fa 100644 --- a/src/test/java/io/kurrent/dbclient/persistentsubscriptions/UpdatePersistentSubscriptionToStreamTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/persistentsubscriptions/UpdatePersistentSubscriptionToStreamTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.persistentsubscriptions; +package io.trogonstack.eventstore.client.persistentsubscriptions; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Test; public interface UpdatePersistentSubscriptionToStreamTests extends ConnectionAware { @@ -9,12 +9,13 @@ default void testUpdatePersistentSub() throws Throwable { String streamName = generateName(); String groupName = generateName(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); client.createToStream(streamName, groupName) .get(); UpdatePersistentSubscriptionToStreamOptions updated = UpdatePersistentSubscriptionToStreamOptions.get() .checkpointAfterInMs(5_000) + .namedConsumerStrategy(NamedConsumerStrategy.PINNED_BY_CORRELATION) .startFrom(2); client.updateToStream(streamName, groupName, updated) @@ -24,12 +25,13 @@ default void testUpdatePersistentSub() throws Throwable { @Test default void testUpdatePersistentSubToAll() throws Throwable { String groupName = generateName(); - KurrentDBPersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); + TrogonEventStorePersistentSubscriptionsClient client = getDefaultPersistentSubscriptionClient(); client.createToAll(groupName) .get(); UpdatePersistentSubscriptionToAllOptions updatedSettings = UpdatePersistentSubscriptionToAllOptions.get() .checkpointAfterInMs(5_000) + .namedConsumerStrategy(NamedConsumerStrategy.PINNED_BY_CORRELATION) .startFrom(3,4); client.updateToAll(groupName, updatedSettings) diff --git a/src/test/java/io/kurrent/dbclient/plugins/ClientCertificateAuthenticationTests.java b/src/test/java/io/trogonstack/eventstore/client/plugins/ClientCertificateAuthenticationTests.java similarity index 88% rename from src/test/java/io/kurrent/dbclient/plugins/ClientCertificateAuthenticationTests.java rename to src/test/java/io/trogonstack/eventstore/client/plugins/ClientCertificateAuthenticationTests.java index bb70dcf..512ffe8 100644 --- a/src/test/java/io/kurrent/dbclient/plugins/ClientCertificateAuthenticationTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/plugins/ClientCertificateAuthenticationTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.plugins; +package io.trogonstack.eventstore.client.plugins; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -10,7 +10,7 @@ public interface ClientCertificateAuthenticationTests extends ConnectionAware { @Test default void testClientCertificateAuthenticationWithValidCertificate() { Assertions.assertDoesNotThrow(() -> { - KurrentDBClient client = getDatabase() + TrogonEventStoreClient client = getDatabase() .createClient(getDatabase() .defaultSettingsBuilder() .defaultClientCertificate(clientCertificate("admin"), userKey("admin")) diff --git a/src/test/java/io/kurrent/dbclient/samples/TestEvent.java b/src/test/java/io/trogonstack/eventstore/client/samples/TestEvent.java similarity index 89% rename from src/test/java/io/kurrent/dbclient/samples/TestEvent.java rename to src/test/java/io/trogonstack/eventstore/client/samples/TestEvent.java index cd2a0e1..05b1761 100644 --- a/src/test/java/io/kurrent/dbclient/samples/TestEvent.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/TestEvent.java @@ -1,30 +1,30 @@ -package io.kurrent.dbclient.samples; - -public class TestEvent { - private String id; - private String importantData; - - public TestEvent(){ - } - - public TestEvent(String id, String importantData){ - this.id = id; - this.importantData = importantData; - } - - public String getId() { - return id; - } - - public void setId(String id){ - this.id = id; - } - - public String getImportantData() { - return importantData; - } - - public void setImportantData(String importantData){ - this.importantData = importantData; - } -} +package io.trogonstack.eventstore.client.samples; + +public class TestEvent { + private String id; + private String importantData; + + public TestEvent(){ + } + + public TestEvent(String id, String importantData){ + this.id = id; + this.importantData = importantData; + } + + public String getId() { + return id; + } + + public void setId(String id){ + this.id = id; + } + + public String getImportantData() { + return importantData; + } + + public void setImportantData(String importantData){ + this.importantData = importantData; + } +} diff --git a/src/test/java/io/kurrent/dbclient/samples/appending_events/AppendingEvents.java b/src/test/java/io/trogonstack/eventstore/client/samples/appending_events/AppendingEvents.java similarity index 84% rename from src/test/java/io/kurrent/dbclient/samples/appending_events/AppendingEvents.java rename to src/test/java/io/trogonstack/eventstore/client/samples/appending_events/AppendingEvents.java index 856e8e8..8915f56 100644 --- a/src/test/java/io/kurrent/dbclient/samples/appending_events/AppendingEvents.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/appending_events/AppendingEvents.java @@ -1,143 +1,143 @@ -package io.kurrent.dbclient.samples.appending_events; - -import com.fasterxml.jackson.core.JsonProcessingException; -import io.kurrent.dbclient.*; -import io.kurrent.dbclient.samples.TestEvent; - -import java.util.UUID; -import java.util.concurrent.ExecutionException; - -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class AppendingEvents { - private static void appendToStream(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException { - // region append-to-stream - ObjectMapper objectMapper = new ObjectMapper(); - - EventData eventData = EventData - .builderAsJson( - UUID.randomUUID(), - "some-event", - objectMapper.writeValueAsBytes(new TestEvent("1", "some value")) - ) - .build(); - - AppendToStreamOptions options = AppendToStreamOptions.get() - .streamState(StreamState.noStream()); - - client.appendToStream("some-stream", options, eventData) - .get(); - // endregion append-to-stream - } - - private static void appendWithSameId(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException { - // region append-duplicate-event - ObjectMapper objectMapper = new ObjectMapper(); - - EventData eventData = EventData - .builderAsJson( - UUID.randomUUID(), - "some-event", - objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))) - .build(); - - AppendToStreamOptions options = AppendToStreamOptions.get() - .streamState(StreamState.any()); - - client.appendToStream("same-event-stream", options, eventData) - .get(); - - // attempt to append the same event again - client.appendToStream("same-event-stream", options, eventData) - .get(); - // endregion append-duplicate-event - } - - private static void appendWithNoStream(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException { - // region append-with-no-stream - ObjectMapper objectMapper = new ObjectMapper(); - - EventData eventDataOne = EventData - .builderAsJson( - UUID.randomUUID(), - "some-event", - objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))) - .build(); - - EventData eventDataTwo = EventData - .builderAsJson( - UUID.randomUUID(), - "some-event", - objectMapper.writeValueAsBytes(new TestEvent("2", "some other value"))) - .build(); - - AppendToStreamOptions options = AppendToStreamOptions.get() - .streamState(StreamState.noStream()); - - client.appendToStream("no-stream-stream", options, eventDataOne) - .get(); - - // attempt to append the same event again - client.appendToStream("no-stream-stream", options, eventDataTwo) - .get(); - // endregion append-with-no-stream - } - - private static void appendWithConcurrencyCheck(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException { - // region append-with-concurrency-check - ObjectMapper objectMapper = new ObjectMapper(); - - ReadStreamOptions readStreamOptions = ReadStreamOptions.get() - .forwards() - .fromStart(); - - ReadResult result = client.readStream("concurrency-stream", readStreamOptions) - .get(); - - EventData clientOneData = EventData - .builderAsJson( - UUID.randomUUID(), - "some-event", - objectMapper.writeValueAsBytes(new TestEvent("1", "clientOne"))) - .build(); - - EventData clientTwoData = EventData - .builderAsJson( - UUID.randomUUID(), - "some-event", - objectMapper.writeValueAsBytes(new TestEvent("2", "clientTwo"))) - .build(); - - - AppendToStreamOptions options = AppendToStreamOptions.get() - .streamRevision(result.getLastStreamPosition()); - - client.appendToStream("concurrency-stream", options, clientOneData) - .get(); - - client.appendToStream("concurrency-stream", options, clientTwoData) - .get(); - // endregion append-with-concurrency-check - } - - public void appendOverridingUserCredentials(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - - EventData eventData = EventData - .builderAsJson( - UUID.randomUUID(), - "some-event", - objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))) - .build(); - //region overriding-user-credentials - UserCredentials credentials = new UserCredentials("admin", "changeit"); - - AppendToStreamOptions options = AppendToStreamOptions.get() - .authenticated(credentials); - - client.appendToStream("some-stream", options, eventData) - .get(); - // endregion overriding-user-credentials - } -} +package io.trogonstack.eventstore.client.samples.appending_events; + +import com.fasterxml.jackson.core.JsonProcessingException; +import io.trogonstack.eventstore.client.*; +import io.trogonstack.eventstore.client.samples.TestEvent; + +import java.util.UUID; +import java.util.concurrent.ExecutionException; + +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class AppendingEvents { + private static void appendToStream(TrogonEventStoreClient client) throws ExecutionException, InterruptedException, JsonProcessingException { + // region append-to-stream + ObjectMapper objectMapper = new ObjectMapper(); + + EventData eventData = EventData + .builderAsJson( + UUID.randomUUID(), + "some-event", + objectMapper.writeValueAsBytes(new TestEvent("1", "some value")) + ) + .build(); + + AppendToStreamOptions options = AppendToStreamOptions.get() + .streamState(StreamState.noStream()); + + client.appendToStream("some-stream", options, eventData) + .get(); + // endregion append-to-stream + } + + private static void appendWithSameId(TrogonEventStoreClient client) throws ExecutionException, InterruptedException, JsonProcessingException { + // region append-duplicate-event + ObjectMapper objectMapper = new ObjectMapper(); + + EventData eventData = EventData + .builderAsJson( + UUID.randomUUID(), + "some-event", + objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))) + .build(); + + AppendToStreamOptions options = AppendToStreamOptions.get() + .streamState(StreamState.any()); + + client.appendToStream("same-event-stream", options, eventData) + .get(); + + // attempt to append the same event again + client.appendToStream("same-event-stream", options, eventData) + .get(); + // endregion append-duplicate-event + } + + private static void appendWithNoStream(TrogonEventStoreClient client) throws ExecutionException, InterruptedException, JsonProcessingException { + // region append-with-no-stream + ObjectMapper objectMapper = new ObjectMapper(); + + EventData eventDataOne = EventData + .builderAsJson( + UUID.randomUUID(), + "some-event", + objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))) + .build(); + + EventData eventDataTwo = EventData + .builderAsJson( + UUID.randomUUID(), + "some-event", + objectMapper.writeValueAsBytes(new TestEvent("2", "some other value"))) + .build(); + + AppendToStreamOptions options = AppendToStreamOptions.get() + .streamState(StreamState.noStream()); + + client.appendToStream("no-stream-stream", options, eventDataOne) + .get(); + + // attempt to append the same event again + client.appendToStream("no-stream-stream", options, eventDataTwo) + .get(); + // endregion append-with-no-stream + } + + private static void appendWithConcurrencyCheck(TrogonEventStoreClient client) throws ExecutionException, InterruptedException, JsonProcessingException { + // region append-with-concurrency-check + ObjectMapper objectMapper = new ObjectMapper(); + + ReadStreamOptions readStreamOptions = ReadStreamOptions.get() + .forwards() + .fromStart(); + + ReadResult result = client.readStream("concurrency-stream", readStreamOptions) + .get(); + + EventData clientOneData = EventData + .builderAsJson( + UUID.randomUUID(), + "some-event", + objectMapper.writeValueAsBytes(new TestEvent("1", "clientOne"))) + .build(); + + EventData clientTwoData = EventData + .builderAsJson( + UUID.randomUUID(), + "some-event", + objectMapper.writeValueAsBytes(new TestEvent("2", "clientTwo"))) + .build(); + + + AppendToStreamOptions options = AppendToStreamOptions.get() + .streamRevision(result.getLastStreamPosition()); + + client.appendToStream("concurrency-stream", options, clientOneData) + .get(); + + client.appendToStream("concurrency-stream", options, clientTwoData) + .get(); + // endregion append-with-concurrency-check + } + + public void appendOverridingUserCredentials(TrogonEventStoreClient client) throws ExecutionException, InterruptedException, JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + + EventData eventData = EventData + .builderAsJson( + UUID.randomUUID(), + "some-event", + objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))) + .build(); + //region overriding-user-credentials + UserCredentials credentials = new UserCredentials("admin", "changeit"); + + AppendToStreamOptions options = AppendToStreamOptions.get() + .authenticated(credentials); + + client.appendToStream("some-stream", options, eventData) + .get(); + // endregion overriding-user-credentials + } +} diff --git a/src/test/java/io/trogonstack/eventstore/client/samples/authentication/UserCertificate.java b/src/test/java/io/trogonstack/eventstore/client/samples/authentication/UserCertificate.java new file mode 100644 index 0000000..f696452 --- /dev/null +++ b/src/test/java/io/trogonstack/eventstore/client/samples/authentication/UserCertificate.java @@ -0,0 +1,15 @@ +package io.trogonstack.eventstore.client.samples.authentication; + +import io.trogonstack.eventstore.client.TrogonEventStoreClient; +import io.trogonstack.eventstore.client.TrogonEventStoreClientSettings; +import io.trogonstack.eventstore.client.TrogonEventStoreConnectionString; + +public class UserCertificate { + private static void tracing() { + // region client-with-user-certificates + TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString + .parseOrThrow("trogon-eventstore://admin:changeit@{endpoint}?tls=true&userCertFile={pathToCaFile}&userKeyFile={pathToKeyFile}"); + TrogonEventStoreClient client = TrogonEventStoreClient.create(settings); + // endregion client-with-user-certificates + } +} diff --git a/src/test/java/io/kurrent/dbclient/samples/opentelemetry/Instrumentation.java b/src/test/java/io/trogonstack/eventstore/client/samples/opentelemetry/Instrumentation.java similarity index 88% rename from src/test/java/io/kurrent/dbclient/samples/opentelemetry/Instrumentation.java rename to src/test/java/io/trogonstack/eventstore/client/samples/opentelemetry/Instrumentation.java index fc9c4f6..bce7754 100644 --- a/src/test/java/io/kurrent/dbclient/samples/opentelemetry/Instrumentation.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/opentelemetry/Instrumentation.java @@ -1,64 +1,64 @@ -package io.kurrent.dbclient.samples.opentelemetry; -import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException; - -import io.kurrent.dbclient.*; -import io.kurrent.dbclient.samples.TestEvent; -// region import-required-packages -import io.opentelemetry.exporter.logging.LoggingSpanExporter; -import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; -import io.opentelemetry.sdk.OpenTelemetrySdk; -import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.trace.SdkTracerProvider; -import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; -import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper; -// endregion import-required-packages - -import java.util.UUID; -import java.util.concurrent.ExecutionException; - -import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME; - -public class Instrumentation { - private static void tracing(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - - Resource resource = Resource.getDefault().toBuilder() - .put(SERVICE_NAME, "sample") - .build(); - - // region setup-exporter - LoggingSpanExporter consoleExporter = LoggingSpanExporter.create(); - - OtlpGrpcSpanExporter jaegarExporter = OtlpGrpcSpanExporter.builder() - .setEndpoint("http://localhost:4317") - .build(); - - SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder() - .addSpanProcessor(SimpleSpanProcessor.create(jaegarExporter)) - .addSpanProcessor(SimpleSpanProcessor.create(consoleExporter)) - .setResource(resource) - .build(); - // endregion setup-exporter - - // region register-instrumentation - OpenTelemetrySdk.builder() - .setTracerProvider(sdkTracerProvider) - .buildAndRegisterGlobal(); - // endregion register-instrumentation - - // region setup-client-for-tracing - EventData eventData = EventData - .builderAsJson( - UUID.randomUUID(), - "some-event", - objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))) - .build(); - // endregion setup-client-for-tracing - - AppendToStreamOptions options = AppendToStreamOptions.get() - .streamState(StreamState.any()); - - WriteResult appendResult = client.appendToStream("some-stream", options, eventData) - .get(); - } -} +package io.trogonstack.eventstore.client.samples.opentelemetry; +import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException; + +import io.trogonstack.eventstore.client.*; +import io.trogonstack.eventstore.client.samples.TestEvent; +// region import-required-packages +import io.opentelemetry.exporter.logging.LoggingSpanExporter; +import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.resources.Resource; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; +import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper; +// endregion import-required-packages + +import java.util.UUID; +import java.util.concurrent.ExecutionException; + +import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME; + +public class Instrumentation { + private static void tracing(TrogonEventStoreClient client) throws ExecutionException, InterruptedException, JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + + Resource resource = Resource.getDefault().toBuilder() + .put(SERVICE_NAME, "sample") + .build(); + + // region setup-exporter + LoggingSpanExporter consoleExporter = LoggingSpanExporter.create(); + + OtlpGrpcSpanExporter jaegarExporter = OtlpGrpcSpanExporter.builder() + .setEndpoint("http://localhost:4317") + .build(); + + SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder() + .addSpanProcessor(SimpleSpanProcessor.create(jaegarExporter)) + .addSpanProcessor(SimpleSpanProcessor.create(consoleExporter)) + .setResource(resource) + .build(); + // endregion setup-exporter + + // region register-instrumentation + OpenTelemetrySdk.builder() + .setTracerProvider(sdkTracerProvider) + .buildAndRegisterGlobal(); + // endregion register-instrumentation + + // region setup-client-for-tracing + EventData eventData = EventData + .builderAsJson( + UUID.randomUUID(), + "some-event", + objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))) + .build(); + // endregion setup-client-for-tracing + + AppendToStreamOptions options = AppendToStreamOptions.get() + .streamState(StreamState.any()); + + WriteResult appendResult = client.appendToStream("some-stream", options, eventData) + .get(); + } +} diff --git a/src/test/java/io/kurrent/dbclient/samples/persistent_subscriptions/PersistentSubscriptions.java b/src/test/java/io/trogonstack/eventstore/client/samples/persistent_subscriptions/PersistentSubscriptions.java similarity index 79% rename from src/test/java/io/kurrent/dbclient/samples/persistent_subscriptions/PersistentSubscriptions.java rename to src/test/java/io/trogonstack/eventstore/client/samples/persistent_subscriptions/PersistentSubscriptions.java index 6a68c93..1073e13 100644 --- a/src/test/java/io/kurrent/dbclient/samples/persistent_subscriptions/PersistentSubscriptions.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/persistent_subscriptions/PersistentSubscriptions.java @@ -1,13 +1,13 @@ -package io.kurrent.dbclient.samples.persistent_subscriptions; +package io.trogonstack.eventstore.client.samples.persistent_subscriptions; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutionException; public class PersistentSubscriptions { - public static void createPersistentSubscription(KurrentDBPersistentSubscriptionsClient client) { + public static void createPersistentSubscription(TrogonEventStorePersistentSubscriptionsClient client) { // region create-persistent-subscription-to-stream client.createToStream( "test-stream", @@ -17,7 +17,7 @@ public static void createPersistentSubscription(KurrentDBPersistentSubscriptions // endregion create-persistent-subscription-to-stream } - public static void connectToPersistentSubscriptionToStream(KurrentDBPersistentSubscriptionsClient client) { + public static void connectToPersistentSubscriptionToStream(TrogonEventStorePersistentSubscriptionsClient client) { // region subscribe-to-persistent-subscription-to-stream client.subscribeToStream( "test-stream", @@ -45,7 +45,7 @@ public void onCancelled(PersistentSubscription subscription, Throwable exception - public static void connectToPersistentSubscriptionToStreamWithManualAcks(KurrentDBPersistentSubscriptionsClient client) { + public static void connectToPersistentSubscriptionToStreamWithManualAcks(TrogonEventStorePersistentSubscriptionsClient client) { // region subscribe-to-persistent-subscription-with-manual-acks client.subscribeToStream( "test-stream", @@ -67,7 +67,7 @@ public void onEvent(PersistentSubscription subscription, int retryCount, Resolve // endregion subscribe-to-persistent-subscription-with-manual-acks } - public static void createPersistentSubscriptionToAll(KurrentDBPersistentSubscriptionsClient client) { + public static void createPersistentSubscriptionToAll(TrogonEventStorePersistentSubscriptionsClient client) { // region create-persistent-subscription-to-all client.createToAll( "subscription-group", @@ -76,7 +76,7 @@ public static void createPersistentSubscriptionToAll(KurrentDBPersistentSubscrip // endregion create-persistent-subscription-to-all } - public static void connectToPersistentSubscriptionToAll(KurrentDBPersistentSubscriptionsClient client) { + public static void connectToPersistentSubscriptionToAll(TrogonEventStorePersistentSubscriptionsClient client) { // region subscribe-to-persistent-subscription-to-all client.subscribeToAll( "subscription-group", @@ -106,7 +106,7 @@ public void onCancelled(PersistentSubscription subscription, Throwable exception // endregion subscribe-to-persistent-subscription-to-all } - public static void updatePersistentSubscription(KurrentDBPersistentSubscriptionsClient client) { + public static void updatePersistentSubscription(TrogonEventStorePersistentSubscriptionsClient client) { // region update-persistent-subscription client.updateToStream( "test-stream", @@ -117,7 +117,7 @@ public static void updatePersistentSubscription(KurrentDBPersistentSubscriptions // endregion update-persistent-subscription } - public static void deletePersistentSubscription(KurrentDBPersistentSubscriptionsClient client) { + public static void deletePersistentSubscription(TrogonEventStorePersistentSubscriptionsClient client) { // region delete-persistent-subscription client.deleteToStream( "test-stream", @@ -125,7 +125,7 @@ public static void deletePersistentSubscription(KurrentDBPersistentSubscriptions // endregion delete-persistent-subscription } - public static void getPersistentSubscriptionToStreamInfo(KurrentDBPersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { + public static void getPersistentSubscriptionToStreamInfo(TrogonEventStorePersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { // #region get-persistent-subscription-to-stream-info Optional result = client.getInfoToStream("test-stream", "subscription-group").get(); if (result.isPresent()) { @@ -136,7 +136,7 @@ public static void getPersistentSubscriptionToStreamInfo(KurrentDBPersistentSubs // #endregion get-persistent-subscription-to-stream-info } - public static void getPersistentSubscriptionToAllInfo(KurrentDBPersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { + public static void getPersistentSubscriptionToAllInfo(TrogonEventStorePersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { // #region get-persistent-subscription-to-all-info Optional result = client.getInfoToAll( "subscription-group").get(); if (result.isPresent()) { @@ -147,21 +147,21 @@ public static void getPersistentSubscriptionToAllInfo(KurrentDBPersistentSubscri // #endregion get-persistent-subscription-to-all-info } - public static void replayParkedToStream(KurrentDBPersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { + public static void replayParkedToStream(TrogonEventStorePersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { // #region replay-parked-of-persistent-subscription-to-stream ReplayParkedMessagesOptions options = ReplayParkedMessagesOptions.get().stopAt(10); client.replayParkedMessagesToStream("test-stream", "subscription-group", options).get(); // #endregion replay-parked-of-persistent-subscription-to-stream } - public static void replayParkedToAll(KurrentDBPersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { + public static void replayParkedToAll(TrogonEventStorePersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { // #region replay-parked-of-persistent-subscription-to-all ReplayParkedMessagesOptions options = ReplayParkedMessagesOptions.get().stopAt(10); client.replayParkedMessagesToAll("subscription-group", options).get(); // #endregion replay-parked-of-persistent-subscription-to-all } - public static void listPersistentSubscriptionToStream(KurrentDBPersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { + public static void listPersistentSubscriptionToStream(TrogonEventStorePersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { // #region list-persistent-subscriptions-to-stream List subscriptions = client.listToStream("test-stream").get(); @@ -171,7 +171,7 @@ public static void listPersistentSubscriptionToStream(KurrentDBPersistentSubscri // #endregion list-persistent-subscriptions-to-stream } - public static void listPersistentSubscriptionToAll(KurrentDBPersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { + public static void listPersistentSubscriptionToAll(TrogonEventStorePersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { // #region list-persistent-subscriptions-to-all List subscriptions = client.listToAll().get(); @@ -181,7 +181,7 @@ public static void listPersistentSubscriptionToAll(KurrentDBPersistentSubscripti // #endregion list-persistent-subscriptions-to-all } - public static void restartPersistentSubscriptionSubsystem(KurrentDBPersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { + public static void restartPersistentSubscriptionSubsystem(TrogonEventStorePersistentSubscriptionsClient client) throws ExecutionException, InterruptedException { // #region restart-persistent-subscription-subsystem client.restartSubsystem().get(); // #endregion restart-persistent-subscription-subsystem diff --git a/src/test/java/io/kurrent/dbclient/samples/projection_management/ProjectionManagement.java b/src/test/java/io/trogonstack/eventstore/client/samples/projection_management/ProjectionManagement.java similarity index 83% rename from src/test/java/io/kurrent/dbclient/samples/projection_management/ProjectionManagement.java rename to src/test/java/io/trogonstack/eventstore/client/samples/projection_management/ProjectionManagement.java index a2daa19..cd00e5d 100644 --- a/src/test/java/io/kurrent/dbclient/samples/projection_management/ProjectionManagement.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/projection_management/ProjectionManagement.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.samples.projection_management; +package io.trogonstack.eventstore.client.samples.projection_management; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.*; import org.junit.jupiter.api.Test; @@ -14,7 +14,7 @@ public void testProjectionManagementSamples() throws Throwable { Database database = DatabaseFactory.spawn(); try { - KurrentDBProjectionManagementClient client = KurrentDBProjectionManagementClient.from(database.defaultClient()); + TrogonEventStoreProjectionManagementClient client = TrogonEventStoreProjectionManagementClient.from(database.defaultClient()); disable(client); disableNotFound(client); enable(client); @@ -35,10 +35,10 @@ public void testProjectionManagementSamples() throws Throwable { } } - private static KurrentDBProjectionManagementClient createClient(String connection) { + private static TrogonEventStoreProjectionManagementClient createClient(String connection) { // region createClient - KurrentDBClientSettings settings = KurrentDBConnectionString.parseOrThrow(connection); - KurrentDBProjectionManagementClient client = KurrentDBProjectionManagementClient.create(settings); + TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString.parseOrThrow(connection); + TrogonEventStoreProjectionManagementClient client = TrogonEventStoreProjectionManagementClient.create(settings); // endregion createClient Assert.assertNotNull(client); @@ -46,14 +46,14 @@ private static KurrentDBProjectionManagementClient createClient(String connectio return client; } - private static void disable(KurrentDBProjectionManagementClient client) + private static void disable(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region Disable client.disable("$by_category").get(); // endregion Disable } - private static void disableNotFound(KurrentDBProjectionManagementClient client) + private static void disableNotFound(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region DisableNotFound try { @@ -66,14 +66,14 @@ private static void disableNotFound(KurrentDBProjectionManagementClient client) // endregion DisableNotFound } - private static void enable(KurrentDBProjectionManagementClient client) + private static void enable(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region Enable client.enable("$by_category").get(); // endregion Enable } - private static void enableNotFound(KurrentDBProjectionManagementClient client) + private static void enableNotFound(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region EnableNotFound try { @@ -86,7 +86,7 @@ private static void enableNotFound(KurrentDBProjectionManagementClient client) // endregion EnableNotFound } - private static void delete(KurrentDBProjectionManagementClient client) + private static void delete(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { String name = "to-be-deleted-projection"; client.create(name, "fromAll().when()").get(); @@ -99,7 +99,7 @@ private static void delete(KurrentDBProjectionManagementClient client) // endregion Delete } - private static void deleteNotFound(KurrentDBProjectionManagementClient client) + private static void deleteNotFound(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region DeleteNotFound try { @@ -112,14 +112,14 @@ private static void deleteNotFound(KurrentDBProjectionManagementClient client) // endregion DeleteNotFound } - private static void abort(KurrentDBProjectionManagementClient client) + private static void abort(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region Abort client.abort("$by_category").get(); // endregion Abort } - private static void abortNotFound(KurrentDBProjectionManagementClient client) + private static void abortNotFound(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region Abort_NotFound try { @@ -132,14 +132,14 @@ private static void abortNotFound(KurrentDBProjectionManagementClient client) // endregion Abort_NotFound } - private static void reset(KurrentDBProjectionManagementClient client) + private static void reset(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region Reset client.reset("$by_category").get(); // endregion Reset } - private static void resetNotFound(KurrentDBProjectionManagementClient client) + private static void resetNotFound(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region Reset_NotFound try { @@ -152,7 +152,7 @@ private static void resetNotFound(KurrentDBProjectionManagementClient client) // endregion Reset_NotFound } - private static void create(KurrentDBProjectionManagementClient client) + private static void create(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region CreateContinuous String js = @@ -175,7 +175,7 @@ private static void create(KurrentDBProjectionManagementClient client) // endregion CreateContinuous } - private static void createConflict(KurrentDBProjectionManagementClient client) + private static void createConflict(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { String js = "{}"; String name = "projection" + java.util.UUID.randomUUID(); @@ -191,7 +191,7 @@ private static void createConflict(KurrentDBProjectionManagementClient client) // endregion CreateContinuous_Conflict } - private static void update(KurrentDBProjectionManagementClient client) + private static void update(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region Update String name = "countEvents_Update_" + java.util.UUID.randomUUID(); @@ -214,7 +214,7 @@ private static void update(KurrentDBProjectionManagementClient client) // endregion Update } - private static void updateNotFound(KurrentDBProjectionManagementClient client) + private static void updateNotFound(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region Update_NotFound try { @@ -227,7 +227,7 @@ private static void updateNotFound(KurrentDBProjectionManagementClient client) // endregion Update_NotFound } - private static void listAll(KurrentDBProjectionManagementClient client) + private static void listAll(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region ListAll List details = client.list().get(); @@ -245,7 +245,7 @@ private static void listAll(KurrentDBProjectionManagementClient client) Assert.assertTrue(details.size() >= 5); } - private static void list(KurrentDBProjectionManagementClient client) + private static void list(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region ListContinuous List details = client.list().get(); @@ -263,7 +263,7 @@ private static void list(KurrentDBProjectionManagementClient client) Assert.assertTrue(details.size() >= 5); } - private static void getStatus(KurrentDBProjectionManagementClient client) + private static void getStatus(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region GetStatus ProjectionDetails status = client.getStatus("$by_category").get(); @@ -278,7 +278,7 @@ private static void getStatus(KurrentDBProjectionManagementClient client) Assert.assertEquals("$by_category", status.getName()); } - private static void getState(KurrentDBProjectionManagementClient client) + private static void getState(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region GetState // This example requires the following class to be defined: @@ -321,7 +321,7 @@ private static void getState(KurrentDBProjectionManagementClient client) Assert.assertTrue(result.getCount() > 0); } - private static void getResult(KurrentDBProjectionManagementClient client) + private static void getResult(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region GetResult String name = "get_result_example"; @@ -354,7 +354,7 @@ private static void getResult(KurrentDBProjectionManagementClient client) Assert.assertTrue(result > 0); } - private static void restartSubSystem(KurrentDBProjectionManagementClient client) + private static void restartSubSystem(TrogonEventStoreProjectionManagementClient client) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException { // region RestartSubSystem client.restartSubsystem().get(); diff --git a/src/test/java/io/kurrent/dbclient/samples/quick_start/QuickStart.java b/src/test/java/io/trogonstack/eventstore/client/samples/quick_start/QuickStart.java similarity index 81% rename from src/test/java/io/kurrent/dbclient/samples/quick_start/QuickStart.java rename to src/test/java/io/trogonstack/eventstore/client/samples/quick_start/QuickStart.java index 7fa72c2..b3f65fd 100644 --- a/src/test/java/io/kurrent/dbclient/samples/quick_start/QuickStart.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/quick_start/QuickStart.java @@ -1,53 +1,53 @@ -package io.kurrent.dbclient.samples.quick_start; - -import io.kurrent.dbclient.*; -import io.kurrent.dbclient.samples.TestEvent; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.json.JsonMapper; - -import java.util.UUID; -import java.util.concurrent.ExecutionException; - -public class QuickStart { - public static void Run() throws ConnectionStringParsingException, ExecutionException, InterruptedException, JsonProcessingException { - // region createClient - KurrentDBClientSettings settings = KurrentDBConnectionString.parseOrThrow("{connectionString}"); - KurrentDBClient client = KurrentDBClient.create(settings); - // endregion createClient - - // region createEvent - TestEvent event = new TestEvent(); - JsonMapper jsonMapper = new JsonMapper(); - event.setId(UUID.randomUUID().toString()); - event.setImportantData("I wrote my first event!"); - - EventData eventData = EventData - .builderAsJson("TestEvent", jsonMapper.writeValueAsBytes(event)) - .build(); - // endregion createEvent - - // region appendEvents - client.appendToStream("some-stream", eventData) - .get(); - // endregion appendEvents - - // region overriding-user-credentials - AppendToStreamOptions appendToStreamOptions = AppendToStreamOptions.get() - .authenticated("admin", "changeit"); - - client.appendToStream("some-stream", appendToStreamOptions, eventData) - .get(); - // endregion overriding-user-credentials - - - // region readStream - ReadStreamOptions options = ReadStreamOptions.get() - .forwards() - .fromStart() - .maxCount(10); - - ReadResult result = client.readStream("some-stream", options) - .get(); - // endregion readStream - } -} +package io.trogonstack.eventstore.client.samples.quick_start; + +import io.trogonstack.eventstore.client.*; +import io.trogonstack.eventstore.client.samples.TestEvent; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.json.JsonMapper; + +import java.util.UUID; +import java.util.concurrent.ExecutionException; + +public class QuickStart { + public static void Run() throws ConnectionStringParsingException, ExecutionException, InterruptedException, JsonProcessingException { + // region createClient + TrogonEventStoreClientSettings settings = TrogonEventStoreConnectionString.parseOrThrow("{connectionString}"); + TrogonEventStoreClient client = TrogonEventStoreClient.create(settings); + // endregion createClient + + // region createEvent + TestEvent event = new TestEvent(); + JsonMapper jsonMapper = new JsonMapper(); + event.setId(UUID.randomUUID().toString()); + event.setImportantData("I wrote my first event!"); + + EventData eventData = EventData + .builderAsJson("TestEvent", jsonMapper.writeValueAsBytes(event)) + .build(); + // endregion createEvent + + // region appendEvents + client.appendToStream("some-stream", eventData) + .get(); + // endregion appendEvents + + // region overriding-user-credentials + AppendToStreamOptions appendToStreamOptions = AppendToStreamOptions.get() + .authenticated("admin", "changeit"); + + client.appendToStream("some-stream", appendToStreamOptions, eventData) + .get(); + // endregion overriding-user-credentials + + + // region readStream + ReadStreamOptions options = ReadStreamOptions.get() + .forwards() + .fromStart() + .maxCount(10); + + ReadResult result = client.readStream("some-stream", options) + .get(); + // endregion readStream + } +} diff --git a/src/test/java/io/kurrent/dbclient/samples/reading_events/ReadingEvents.java b/src/test/java/io/trogonstack/eventstore/client/samples/reading_events/ReadingEvents.java similarity index 88% rename from src/test/java/io/kurrent/dbclient/samples/reading_events/ReadingEvents.java rename to src/test/java/io/trogonstack/eventstore/client/samples/reading_events/ReadingEvents.java index 9098358..5d12bb6 100644 --- a/src/test/java/io/kurrent/dbclient/samples/reading_events/ReadingEvents.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/reading_events/ReadingEvents.java @@ -1,448 +1,448 @@ -package io.kurrent.dbclient.samples.reading_events; - -import io.kurrent.dbclient.*; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.reactivestreams.*; -import org.reactivestreams.Subscription; - -import java.util.concurrent.ExecutionException; - -@SuppressWarnings("ALL") -public class ReadingEvents { - private static void readFromStream(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException { - // region read-from-stream - ReadStreamOptions options = ReadStreamOptions.get() - .forwards() - .fromStart(); - - ReadResult result = client.readStream("some-stream", options) - .get(); - - - // or using read reactive - Publisher publisher = client.readStreamReactive("some-stream", options); - // endregion read-from-stream - - // region iterate-stream - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - - // or using read reactive - publisher.subscribe(new Subscriber() { - @Override - public void onSubscribe(Subscription subscription) { - } - - @Override - public void onNext(ReadMessage readMessage) { - RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); - try { - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - @Override - public void onError(Throwable throwable) { - } - - @Override - public void onComplete() { - } - }); - // endregion iterate-stream - } - - private static void readFromStreamPosition(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException { - // region read-from-stream-position - ReadStreamOptions options = ReadStreamOptions.get() - .forwards() - .fromRevision(10) - .maxCount(20); - - ReadResult result = client.readStream("some-stream", options) - .get(); - - // or using read reactive - Publisher publisher = client.readStreamReactive("some-stream", options); - // endregion read-from-stream-position - - // region iterate-stream - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - - // or using read reactive - publisher.subscribe(new Subscriber() { - @Override - public void onSubscribe(Subscription subscription) { - } - - @Override - public void onNext(ReadMessage readMessage) { - RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); - try { - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - @Override - public void onError(Throwable throwable) { - } - - @Override - public void onComplete() { - } - }); - // endregion iterate-stream - } - - private static void readStreamOverridingUserCredentials(KurrentDBClient client) throws ExecutionException, InterruptedException { - // region overriding-user-credentials - ReadStreamOptions options = ReadStreamOptions.get() - .forwards() - .fromStart() - .authenticated("admin", "changeit"); - - ReadResult result = client.readStream("some-stream", options) - .get(); - - // Or using reactive stream - Publisher publisher = client.readStreamReactive("some-stream", options); - // endregion overriding-user-credentials - } - - private static void readFromStreamPositionCheck(KurrentDBClient client) throws JsonProcessingException, InterruptedException { - // region checking-for-stream-presence - ReadStreamOptions options = ReadStreamOptions.get() - .forwards() - .fromRevision(10) - .maxCount(20); - - ReadResult result = null; - try { - result = client.readStream("some-stream", options) - .get(); - } catch (ExecutionException e) { - Throwable innerException = e.getCause(); - - if (innerException instanceof StreamNotFoundException) { - return; - } - } - - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - - // or using read reactive - Publisher publisher = client.readStreamReactive("some-stream", options); - - publisher.subscribe(new Subscriber() { - @Override - public void onSubscribe(Subscription subscription) { - } - - @Override - public void onNext(ReadMessage readMessage) { - RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); - try { - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - @Override - public void onError(Throwable throwable) { - Throwable innerException = throwable.getCause(); - - if (innerException instanceof StreamNotFoundException) { - return; - } - // Handle other errors - } - - @Override - public void onComplete() { - } - }); - // endregion checking-for-stream-presence - } - - private static void readFromStreamBackwards(KurrentDBClient client) throws JsonProcessingException, ExecutionException, InterruptedException { - // region reading-backwards - ReadStreamOptions options = ReadStreamOptions.get() - .backwards() - .fromEnd(); - - ReadResult result = client.readStream("some-stream", options) - .get(); - - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - - // or using read reactive - Publisher publisher = client.readStreamReactive("some-stream", options); - - publisher.subscribe(new Subscriber() { - @Override - public void onSubscribe(Subscription subscription) { - } - - @Override - public void onNext(ReadMessage readMessage) { - RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); - try { - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - @Override - public void onError(Throwable throwable) { - } - - @Override - public void onComplete() { - } - }); - // endregion reading-backwards - } - - private static void readFromAllStream(KurrentDBClient client) throws JsonProcessingException, ExecutionException, InterruptedException { - // region read-from-all-stream - ReadAllOptions options = ReadAllOptions.get() - .forwards() - .fromStart(); - - ReadResult result = client.readAll(options) - .get(); - - // or using read reactive - Publisher publisher = client.readAllReactive(options); - // endregion read-from-all-stream - - // region read-from-all-stream-iterate - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - - // or using read reactive - publisher.subscribe(new Subscriber() { - @Override - public void onSubscribe(Subscription subscription) { - } - - @Override - public void onNext(ReadMessage readMessage) { - RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); - try { - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - @Override - public void onError(Throwable throwable) { - } - - @Override - public void onComplete() { - } - }); - // endregion read-from-all-stream-iterate - } - - private static void readAllOverridingUserCredentials(KurrentDBClient client) throws ExecutionException, InterruptedException { - // region read-all-overriding-user-credentials - ReadAllOptions options = ReadAllOptions.get() - .forwards() - .fromStart() - .authenticated("admin", "changeit"); - - ReadResult result = client.readAll(options) - .get(); - - // or using read reactive - Publisher publisher = client.readAllReactive(options); - // endregion read-all-overriding-user-credentials - } - - private static void ignoreSystemEvents(KurrentDBClient client) throws JsonProcessingException, ExecutionException, InterruptedException { - // region ignore-system-events - ReadAllOptions options = ReadAllOptions.get() - .forwards() - .fromStart(); - - ReadResult result = client.readAll(options) - .get(); - - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - if (recordedEvent.getEventType().startsWith("$")) { - continue; - } - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - - // or using read reactive - Publisher publisher = client.readAllReactive(options); - - publisher.subscribe(new Subscriber() { - @Override - public void onSubscribe(Subscription subscription) { - } - - @Override - public void onNext(ReadMessage readMessage) { - RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); - - if (recordedEvent.getEventType().startsWith("$")) { - return; - } - - try { - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - @Override - public void onError(Throwable throwable) { - } - - @Override - public void onComplete() { - } - }); - // endregion ignore-system-events - } - - private static void readFromAllStreamBackwards(KurrentDBClient client) throws JsonProcessingException, ExecutionException, InterruptedException { - // region read-from-all-stream-backwards - ReadAllOptions options = ReadAllOptions.get() - .backwards() - .fromEnd(); - - ReadResult result = client.readAll(options) - .get(); - - // or using read reactive - Publisher publisher = client.readAllReactive(options); - // endregion read-from-all-stream-backwards - - // region read-from-all-stream-iterate - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - - // or using read reactive - publisher.subscribe(new Subscriber() { - @Override - public void onSubscribe(Subscription subscription) { - } - - @Override - public void onNext(ReadMessage readMessage) { - RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); - try { - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - @Override - public void onError(Throwable throwable) { - } - - @Override - public void onComplete() { - } - }); - // endregion read-from-all-stream-iterate - } - - private static void filteringOutSystemEvents(KurrentDBClient client) throws JsonProcessingException, ExecutionException, InterruptedException { - ReadAllOptions options = ReadAllOptions.get() - .forwards() - .fromStart(); - - ReadResult result = client.readAll(options) - .get(); - - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - if (!recordedEvent.getEventType().startsWith("$")) { - continue; - } - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - - // or using read reactive - Publisher publisher = client.readAllReactive(options); - - publisher.subscribe(new Subscriber() { - @Override - public void onSubscribe(Subscription subscription) { - } - - @Override - public void onNext(ReadMessage readMessage) { - RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); - if (!recordedEvent.getEventType().startsWith("$")) { - return; - } - try { - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - @Override - public void onError(Throwable throwable) { - } - - @Override - public void onComplete() { - } - }); - } - - private static void readFromStreamResolvingLinkTos(KurrentDBClient client) throws JsonProcessingException, ExecutionException, InterruptedException { - // region read-from-all-stream-resolving-link-Tos - ReadAllOptions options = ReadAllOptions.get() - .forwards() - .fromStart() - .resolveLinkTos(); - - ReadResult result = client.readAll(options) - .get(); - - // or using read reactive - Publisher publisher = client.readAllReactive(options); - - // endregion read-from-all-stream-resolving-link-Tos - for (ResolvedEvent resolvedEvent : result.getEvents()) { - RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); - System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); - } - } -} +package io.trogonstack.eventstore.client.samples.reading_events; + +import io.trogonstack.eventstore.client.*; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.reactivestreams.*; +import org.reactivestreams.Subscription; + +import java.util.concurrent.ExecutionException; + +@SuppressWarnings("ALL") +public class ReadingEvents { + private static void readFromStream(TrogonEventStoreClient client) throws ExecutionException, InterruptedException, JsonProcessingException { + // region read-from-stream + ReadStreamOptions options = ReadStreamOptions.get() + .forwards() + .fromStart(); + + ReadResult result = client.readStream("some-stream", options) + .get(); + + + // or using read reactive + Publisher publisher = client.readStreamReactive("some-stream", options); + // endregion read-from-stream + + // region iterate-stream + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + + // or using read reactive + publisher.subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription subscription) { + } + + @Override + public void onNext(ReadMessage readMessage) { + RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); + try { + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + @Override + public void onError(Throwable throwable) { + } + + @Override + public void onComplete() { + } + }); + // endregion iterate-stream + } + + private static void readFromStreamPosition(TrogonEventStoreClient client) throws ExecutionException, InterruptedException, JsonProcessingException { + // region read-from-stream-position + ReadStreamOptions options = ReadStreamOptions.get() + .forwards() + .fromRevision(10) + .maxCount(20); + + ReadResult result = client.readStream("some-stream", options) + .get(); + + // or using read reactive + Publisher publisher = client.readStreamReactive("some-stream", options); + // endregion read-from-stream-position + + // region iterate-stream + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + + // or using read reactive + publisher.subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription subscription) { + } + + @Override + public void onNext(ReadMessage readMessage) { + RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); + try { + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + @Override + public void onError(Throwable throwable) { + } + + @Override + public void onComplete() { + } + }); + // endregion iterate-stream + } + + private static void readStreamOverridingUserCredentials(TrogonEventStoreClient client) throws ExecutionException, InterruptedException { + // region overriding-user-credentials + ReadStreamOptions options = ReadStreamOptions.get() + .forwards() + .fromStart() + .authenticated("admin", "changeit"); + + ReadResult result = client.readStream("some-stream", options) + .get(); + + // Or using reactive stream + Publisher publisher = client.readStreamReactive("some-stream", options); + // endregion overriding-user-credentials + } + + private static void readFromStreamPositionCheck(TrogonEventStoreClient client) throws JsonProcessingException, InterruptedException { + // region checking-for-stream-presence + ReadStreamOptions options = ReadStreamOptions.get() + .forwards() + .fromRevision(10) + .maxCount(20); + + ReadResult result = null; + try { + result = client.readStream("some-stream", options) + .get(); + } catch (ExecutionException e) { + Throwable innerException = e.getCause(); + + if (innerException instanceof StreamNotFoundException) { + return; + } + } + + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + + // or using read reactive + Publisher publisher = client.readStreamReactive("some-stream", options); + + publisher.subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription subscription) { + } + + @Override + public void onNext(ReadMessage readMessage) { + RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); + try { + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + @Override + public void onError(Throwable throwable) { + Throwable innerException = throwable.getCause(); + + if (innerException instanceof StreamNotFoundException) { + return; + } + // Handle other errors + } + + @Override + public void onComplete() { + } + }); + // endregion checking-for-stream-presence + } + + private static void readFromStreamBackwards(TrogonEventStoreClient client) throws JsonProcessingException, ExecutionException, InterruptedException { + // region reading-backwards + ReadStreamOptions options = ReadStreamOptions.get() + .backwards() + .fromEnd(); + + ReadResult result = client.readStream("some-stream", options) + .get(); + + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + + // or using read reactive + Publisher publisher = client.readStreamReactive("some-stream", options); + + publisher.subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription subscription) { + } + + @Override + public void onNext(ReadMessage readMessage) { + RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); + try { + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + @Override + public void onError(Throwable throwable) { + } + + @Override + public void onComplete() { + } + }); + // endregion reading-backwards + } + + private static void readFromAllStream(TrogonEventStoreClient client) throws JsonProcessingException, ExecutionException, InterruptedException { + // region read-from-all-stream + ReadAllOptions options = ReadAllOptions.get() + .forwards() + .fromStart(); + + ReadResult result = client.readAll(options) + .get(); + + // or using read reactive + Publisher publisher = client.readAllReactive(options); + // endregion read-from-all-stream + + // region read-from-all-stream-iterate + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + + // or using read reactive + publisher.subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription subscription) { + } + + @Override + public void onNext(ReadMessage readMessage) { + RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); + try { + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + @Override + public void onError(Throwable throwable) { + } + + @Override + public void onComplete() { + } + }); + // endregion read-from-all-stream-iterate + } + + private static void readAllOverridingUserCredentials(TrogonEventStoreClient client) throws ExecutionException, InterruptedException { + // region read-all-overriding-user-credentials + ReadAllOptions options = ReadAllOptions.get() + .forwards() + .fromStart() + .authenticated("admin", "changeit"); + + ReadResult result = client.readAll(options) + .get(); + + // or using read reactive + Publisher publisher = client.readAllReactive(options); + // endregion read-all-overriding-user-credentials + } + + private static void ignoreSystemEvents(TrogonEventStoreClient client) throws JsonProcessingException, ExecutionException, InterruptedException { + // region ignore-system-events + ReadAllOptions options = ReadAllOptions.get() + .forwards() + .fromStart(); + + ReadResult result = client.readAll(options) + .get(); + + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + if (recordedEvent.getEventType().startsWith("$")) { + continue; + } + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + + // or using read reactive + Publisher publisher = client.readAllReactive(options); + + publisher.subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription subscription) { + } + + @Override + public void onNext(ReadMessage readMessage) { + RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); + + if (recordedEvent.getEventType().startsWith("$")) { + return; + } + + try { + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + @Override + public void onError(Throwable throwable) { + } + + @Override + public void onComplete() { + } + }); + // endregion ignore-system-events + } + + private static void readFromAllStreamBackwards(TrogonEventStoreClient client) throws JsonProcessingException, ExecutionException, InterruptedException { + // region read-from-all-stream-backwards + ReadAllOptions options = ReadAllOptions.get() + .backwards() + .fromEnd(); + + ReadResult result = client.readAll(options) + .get(); + + // or using read reactive + Publisher publisher = client.readAllReactive(options); + // endregion read-from-all-stream-backwards + + // region read-from-all-stream-iterate + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + + // or using read reactive + publisher.subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription subscription) { + } + + @Override + public void onNext(ReadMessage readMessage) { + RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); + try { + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + @Override + public void onError(Throwable throwable) { + } + + @Override + public void onComplete() { + } + }); + // endregion read-from-all-stream-iterate + } + + private static void filteringOutSystemEvents(TrogonEventStoreClient client) throws JsonProcessingException, ExecutionException, InterruptedException { + ReadAllOptions options = ReadAllOptions.get() + .forwards() + .fromStart(); + + ReadResult result = client.readAll(options) + .get(); + + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + if (!recordedEvent.getEventType().startsWith("$")) { + continue; + } + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + + // or using read reactive + Publisher publisher = client.readAllReactive(options); + + publisher.subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription subscription) { + } + + @Override + public void onNext(ReadMessage readMessage) { + RecordedEvent recordedEvent = readMessage.getEvent().getOriginalEvent(); + if (!recordedEvent.getEventType().startsWith("$")) { + return; + } + try { + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + @Override + public void onError(Throwable throwable) { + } + + @Override + public void onComplete() { + } + }); + } + + private static void readFromStreamResolvingLinkTos(TrogonEventStoreClient client) throws JsonProcessingException, ExecutionException, InterruptedException { + // region read-from-all-stream-resolving-link-Tos + ReadAllOptions options = ReadAllOptions.get() + .forwards() + .fromStart() + .resolveLinkTos(); + + ReadResult result = client.readAll(options) + .get(); + + // or using read reactive + Publisher publisher = client.readAllReactive(options); + + // endregion read-from-all-stream-resolving-link-Tos + for (ResolvedEvent resolvedEvent : result.getEvents()) { + RecordedEvent recordedEvent = resolvedEvent.getOriginalEvent(); + System.out.println(new ObjectMapper().writeValueAsString(recordedEvent.getEventData())); + } + } +} diff --git a/src/test/java/io/kurrent/dbclient/samples/server_side_filtering/ServerSideFiltering.java b/src/test/java/io/trogonstack/eventstore/client/samples/server_side_filtering/ServerSideFiltering.java similarity index 90% rename from src/test/java/io/kurrent/dbclient/samples/server_side_filtering/ServerSideFiltering.java rename to src/test/java/io/trogonstack/eventstore/client/samples/server_side_filtering/ServerSideFiltering.java index 1b678c2..86b814f 100644 --- a/src/test/java/io/kurrent/dbclient/samples/server_side_filtering/ServerSideFiltering.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/server_side_filtering/ServerSideFiltering.java @@ -1,206 +1,206 @@ -package io.kurrent.dbclient.samples.server_side_filtering; - -import io.kurrent.dbclient.*; - -import java.util.concurrent.CompletableFuture; - -public class ServerSideFiltering { - private static void excludeSystemEvents(KurrentDBClient client) { - //region exclude-system - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - } - }; - String excludeSystemEventsRegex = "^[^\\$].*"; - - SubscriptionFilter filter = SubscriptionFilter.newBuilder() - .withEventTypeRegularExpression(excludeSystemEventsRegex) - .build(); - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .filter(filter); - - client.subscribeToAll( - listener, - options - ); - //endregion exclude-system - } - - private static void eventTypePrefix(KurrentDBClient client) { - //region event-type-prefix - SubscriptionFilter filter = SubscriptionFilter.newBuilder() - .addEventTypePrefix("customer-") - .build(); - //endregion event-type-prefix - - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - } - }; - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .filter(filter); - - client.subscribeToAll( - listener, - options - ); - } - - private static void eventTypeRegex(KurrentDBClient client) { - //region event-type-regex - SubscriptionFilter filter = SubscriptionFilter.newBuilder() - .withEventTypeRegularExpression("^user|^company") - .build(); - //endregion event-type-regex - - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - } - }; - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .filter(filter); - - client.subscribeToAll( - listener, - options - ); - } - - private static void streamPrefix(KurrentDBClient client) { - //region stream-prefix - SubscriptionFilter filter = SubscriptionFilter.newBuilder() - .addStreamNamePrefix("user-") - .build(); - //endregion stream-prefix - - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - } - }; - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .filter(filter); - - client.subscribeToAll( - listener, - options - ); - } - - private static void streamRegex(KurrentDBClient client) { - //region stream-regex - SubscriptionFilter filter = SubscriptionFilter.newBuilder() - .withStreamNameRegularExpression("^account|^savings") - .build(); - //endregion stream-regex - - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - } - }; - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .filter(filter); - - client.subscribeToAll( - listener, - options - ); - } - - private static void checkpointCallback(KurrentDBClient client) { - //region checkpoint - String excludeSystemEventsRegex = "/^[^\\$].*/"; - - SubscriptionFilter filter = SubscriptionFilter.newBuilder() - .withEventTypeRegularExpression(excludeSystemEventsRegex) - .withCheckpointer( - new Checkpointer() { - @Override - public CompletableFuture onCheckpoint(Subscription subscription, Position position) { - // Save commit position to a persistent store as a checkpoint - System.out.println("checkpoint taken at {position.getCommitUnsigned}"); - return CompletableFuture.completedFuture(null); - } - }) - .build(); - //endregion checkpoint - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .filter(filter); - - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - } - }; - - client.subscribeToAll( - listener, - options - ); - } - - private static void CheckpointCallbackWithInterval(KurrentDBClient client) { - //region checkpoint-with-interval - String excludeSystemEventsRegex = "/^[^\\$].*/"; - - SubscriptionFilter filter = SubscriptionFilter.newBuilder() - .withEventTypeRegularExpression(excludeSystemEventsRegex) - .withCheckpointer( - new Checkpointer() { - @Override - public CompletableFuture onCheckpoint(Subscription subscription, Position position) { - // Save commit position to a persistent store as a checkpoint - System.out.println("checkpoint taken at {position.getCommitUnsigned}"); - return CompletableFuture.completedFuture(null); - } - }, - 1000) - .build(); - //endregion checkpoint-with-interval - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .filter(filter); - - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - } - }; - - client.subscribeToAll( - listener, - options - ); - } -} +package io.trogonstack.eventstore.client.samples.server_side_filtering; + +import io.trogonstack.eventstore.client.*; + +import java.util.concurrent.CompletableFuture; + +public class ServerSideFiltering { + private static void excludeSystemEvents(TrogonEventStoreClient client) { + //region exclude-system + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + } + }; + String excludeSystemEventsRegex = "^[^\\$].*"; + + SubscriptionFilter filter = SubscriptionFilter.newBuilder() + .withEventTypeRegularExpression(excludeSystemEventsRegex) + .build(); + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .filter(filter); + + client.subscribeToAll( + listener, + options + ); + //endregion exclude-system + } + + private static void eventTypePrefix(TrogonEventStoreClient client) { + //region event-type-prefix + SubscriptionFilter filter = SubscriptionFilter.newBuilder() + .addEventTypePrefix("customer-") + .build(); + //endregion event-type-prefix + + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + } + }; + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .filter(filter); + + client.subscribeToAll( + listener, + options + ); + } + + private static void eventTypeRegex(TrogonEventStoreClient client) { + //region event-type-regex + SubscriptionFilter filter = SubscriptionFilter.newBuilder() + .withEventTypeRegularExpression("^user|^company") + .build(); + //endregion event-type-regex + + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + } + }; + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .filter(filter); + + client.subscribeToAll( + listener, + options + ); + } + + private static void streamPrefix(TrogonEventStoreClient client) { + //region stream-prefix + SubscriptionFilter filter = SubscriptionFilter.newBuilder() + .addStreamNamePrefix("user-") + .build(); + //endregion stream-prefix + + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + } + }; + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .filter(filter); + + client.subscribeToAll( + listener, + options + ); + } + + private static void streamRegex(TrogonEventStoreClient client) { + //region stream-regex + SubscriptionFilter filter = SubscriptionFilter.newBuilder() + .withStreamNameRegularExpression("^account|^savings") + .build(); + //endregion stream-regex + + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + } + }; + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .filter(filter); + + client.subscribeToAll( + listener, + options + ); + } + + private static void checkpointCallback(TrogonEventStoreClient client) { + //region checkpoint + String excludeSystemEventsRegex = "/^[^\\$].*/"; + + SubscriptionFilter filter = SubscriptionFilter.newBuilder() + .withEventTypeRegularExpression(excludeSystemEventsRegex) + .withCheckpointer( + new Checkpointer() { + @Override + public CompletableFuture onCheckpoint(Subscription subscription, Position position) { + // Save commit position to a persistent store as a checkpoint + System.out.println("checkpoint taken at {position.getCommitUnsigned}"); + return CompletableFuture.completedFuture(null); + } + }) + .build(); + //endregion checkpoint + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .filter(filter); + + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + } + }; + + client.subscribeToAll( + listener, + options + ); + } + + private static void CheckpointCallbackWithInterval(TrogonEventStoreClient client) { + //region checkpoint-with-interval + String excludeSystemEventsRegex = "/^[^\\$].*/"; + + SubscriptionFilter filter = SubscriptionFilter.newBuilder() + .withEventTypeRegularExpression(excludeSystemEventsRegex) + .withCheckpointer( + new Checkpointer() { + @Override + public CompletableFuture onCheckpoint(Subscription subscription, Position position) { + // Save commit position to a persistent store as a checkpoint + System.out.println("checkpoint taken at {position.getCommitUnsigned}"); + return CompletableFuture.completedFuture(null); + } + }, + 1000) + .build(); + //endregion checkpoint-with-interval + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .filter(filter); + + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + } + }; + + client.subscribeToAll( + listener, + options + ); + } +} diff --git a/src/test/java/io/kurrent/dbclient/samples/subscribing_to_stream/SubscribingToStream.java b/src/test/java/io/trogonstack/eventstore/client/samples/subscribing_to_stream/SubscribingToStream.java similarity index 92% rename from src/test/java/io/kurrent/dbclient/samples/subscribing_to_stream/SubscribingToStream.java rename to src/test/java/io/trogonstack/eventstore/client/samples/subscribing_to_stream/SubscribingToStream.java index 6135feb..478cac9 100644 --- a/src/test/java/io/kurrent/dbclient/samples/subscribing_to_stream/SubscribingToStream.java +++ b/src/test/java/io/trogonstack/eventstore/client/samples/subscribing_to_stream/SubscribingToStream.java @@ -1,190 +1,190 @@ -package io.kurrent.dbclient.samples.subscribing_to_stream; - -import io.kurrent.dbclient.*; - -import static org.junit.Assert.fail; - -public class SubscribingToStream { - private static void subscribeToStream(KurrentDBClient client) { - // region subscribe-to-stream - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - HandleEvent(event); - } - }; - client.subscribeToStream("some-stream", listener); - // endregion subscribe-to-stream - - // region subscribe-to-stream-from-position - client.subscribeToStream( - "some-stream", - listener, - SubscribeToStreamOptions.get() - .fromRevision(20) - ); - // endregion subscribe-to-stream-from-position - - // region subscribe-to-stream-live - client.subscribeToStream( - "some-stream", - listener, - SubscribeToStreamOptions.get() - .fromEnd() - ); - // endregion subscribe-to-stream-live - - // region subscribe-to-stream-resolving-linktos - client.subscribeToStream( - "$et-myEventType", - listener, - SubscribeToStreamOptions.get() - .fromStart() - .resolveLinkTos() - ); - // endregion subscribe-to-stream-resolving-linktos - - // region subscribe-to-stream-subscription-dropped - client.subscribeToStream( - "some-stream", - new SubscriptionListener() { - StreamPosition checkpoint = StreamPosition.start(); - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - HandleEvent(event); - checkpoint = StreamPosition.position(event.getOriginalEvent().getRevision()); - } - - @Override - public void onCancelled(Subscription subscription, Throwable exception) { - // Subscription was dropped by the user. - if (exception == null) - return; - - System.out.println("Subscription was dropped due to " + exception.getMessage()); - Resubscribe(checkpoint); - } - }, - SubscribeToStreamOptions.get() - .fromStart() - ); - // endregion subscribe-to-stream-subscription-dropped - } - - private static void subscribeToAll(KurrentDBClient client) { - // region subscribe-to-all - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - HandleEvent(event); - } - }; - client.subscribeToAll(listener); - // endregion subscribe-to-all - - // region subscribe-to-all-from-position - client.subscribeToAll( - listener, - SubscribeToAllOptions.get() - .fromPosition(new Position(1056, 1056)) - ); - // endregion subscribe-to-all-from-position - - // region subscribe-to-all-live - client.subscribeToAll( - listener, - SubscribeToAllOptions.get() - .fromEnd() - ); - // endregion subscribe-to-all-live - - // region subscribe-to-all-subscription-dropped - client.subscribeToAll( - new SubscriptionListener() { - StreamPosition checkpoint = StreamPosition.start(); - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - HandleEvent(event); - checkpoint = StreamPosition.position(event.getOriginalEvent().getPosition()); - } - - @Override - public void onCancelled(Subscription subscription, Throwable exception) { - // Subscription was dropped by the user. - if (exception == null) - return; - - System.out.println("Subscription was dropped due to " + exception.getMessage()); - Resubscribe(checkpoint); - } - }, - SubscribeToAllOptions.get() - .fromStart() - ); - // endregion subscribe-to-all-subscription-dropped - } - - private static void subscribeToFiltered(KurrentDBClient client) { - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - HandleEvent(event); - } - }; - // region stream-prefix-filtered-subscription - SubscriptionFilter filter = SubscriptionFilter.newBuilder() - .addStreamNamePrefix("test-") - .build(); - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .filter(filter); - - client.subscribeToAll( - listener, - options); - // endregion stream-prefix-filtered-subscription - - // region stream-regex-filtered-subscription - SubscriptionFilter regexStreamFilter = SubscriptionFilter.newBuilder() - .withStreamNameRegularExpression("/invoice-\\d\\d\\d/g") - .build(); - // endregion stream-regex-filtered-subscription - } - - private static void overridingUserCredentials(KurrentDBClient client) { - SubscriptionListener listener = new SubscriptionListener() { - @Override - public void onEvent(Subscription subscription, ResolvedEvent event) { - System.out.println("Received event" - + event.getOriginalEvent().getRevision() - + "@" + event.getOriginalEvent().getStreamId()); - HandleEvent(event); - } - }; - // region overriding-user-credentials - UserCredentials credentials = new UserCredentials("admin", "changeit"); - - SubscribeToAllOptions options = SubscribeToAllOptions.get() - .authenticated(credentials); - - client.subscribeToAll( - listener, - options); - // endregion overriding-user-credentials - } - - private static void HandleEvent(ResolvedEvent event) { - } - - private static void Resubscribe(StreamPosition checkpoint) { - } -} +package io.trogonstack.eventstore.client.samples.subscribing_to_stream; + +import io.trogonstack.eventstore.client.*; + +import static org.junit.Assert.fail; + +public class SubscribingToStream { + private static void subscribeToStream(TrogonEventStoreClient client) { + // region subscribe-to-stream + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + HandleEvent(event); + } + }; + client.subscribeToStream("some-stream", listener); + // endregion subscribe-to-stream + + // region subscribe-to-stream-from-position + client.subscribeToStream( + "some-stream", + listener, + SubscribeToStreamOptions.get() + .fromRevision(20) + ); + // endregion subscribe-to-stream-from-position + + // region subscribe-to-stream-live + client.subscribeToStream( + "some-stream", + listener, + SubscribeToStreamOptions.get() + .fromEnd() + ); + // endregion subscribe-to-stream-live + + // region subscribe-to-stream-resolving-linktos + client.subscribeToStream( + "$et-myEventType", + listener, + SubscribeToStreamOptions.get() + .fromStart() + .resolveLinkTos() + ); + // endregion subscribe-to-stream-resolving-linktos + + // region subscribe-to-stream-subscription-dropped + client.subscribeToStream( + "some-stream", + new SubscriptionListener() { + StreamPosition checkpoint = StreamPosition.start(); + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + HandleEvent(event); + checkpoint = StreamPosition.position(event.getOriginalEvent().getRevision()); + } + + @Override + public void onCancelled(Subscription subscription, Throwable exception) { + // Subscription was dropped by the user. + if (exception == null) + return; + + System.out.println("Subscription was dropped due to " + exception.getMessage()); + Resubscribe(checkpoint); + } + }, + SubscribeToStreamOptions.get() + .fromStart() + ); + // endregion subscribe-to-stream-subscription-dropped + } + + private static void subscribeToAll(TrogonEventStoreClient client) { + // region subscribe-to-all + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + HandleEvent(event); + } + }; + client.subscribeToAll(listener); + // endregion subscribe-to-all + + // region subscribe-to-all-from-position + client.subscribeToAll( + listener, + SubscribeToAllOptions.get() + .fromPosition(new Position(1056, 1056)) + ); + // endregion subscribe-to-all-from-position + + // region subscribe-to-all-live + client.subscribeToAll( + listener, + SubscribeToAllOptions.get() + .fromEnd() + ); + // endregion subscribe-to-all-live + + // region subscribe-to-all-subscription-dropped + client.subscribeToAll( + new SubscriptionListener() { + StreamPosition checkpoint = StreamPosition.start(); + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + HandleEvent(event); + checkpoint = StreamPosition.position(event.getOriginalEvent().getPosition()); + } + + @Override + public void onCancelled(Subscription subscription, Throwable exception) { + // Subscription was dropped by the user. + if (exception == null) + return; + + System.out.println("Subscription was dropped due to " + exception.getMessage()); + Resubscribe(checkpoint); + } + }, + SubscribeToAllOptions.get() + .fromStart() + ); + // endregion subscribe-to-all-subscription-dropped + } + + private static void subscribeToFiltered(TrogonEventStoreClient client) { + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + HandleEvent(event); + } + }; + // region stream-prefix-filtered-subscription + SubscriptionFilter filter = SubscriptionFilter.newBuilder() + .addStreamNamePrefix("test-") + .build(); + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .filter(filter); + + client.subscribeToAll( + listener, + options); + // endregion stream-prefix-filtered-subscription + + // region stream-regex-filtered-subscription + SubscriptionFilter regexStreamFilter = SubscriptionFilter.newBuilder() + .withStreamNameRegularExpression("/invoice-\\d\\d\\d/g") + .build(); + // endregion stream-regex-filtered-subscription + } + + private static void overridingUserCredentials(TrogonEventStoreClient client) { + SubscriptionListener listener = new SubscriptionListener() { + @Override + public void onEvent(Subscription subscription, ResolvedEvent event) { + System.out.println("Received event" + + event.getOriginalEvent().getRevision() + + "@" + event.getOriginalEvent().getStreamId()); + HandleEvent(event); + } + }; + // region overriding-user-credentials + UserCredentials credentials = new UserCredentials("admin", "changeit"); + + SubscribeToAllOptions options = SubscribeToAllOptions.get() + .authenticated(credentials); + + client.subscribeToAll( + listener, + options); + // endregion overriding-user-credentials + } + + private static void HandleEvent(ResolvedEvent event) { + } + + private static void Resubscribe(StreamPosition checkpoint) { + } +} diff --git a/src/test/java/io/kurrent/dbclient/streams/AppendTests.java b/src/test/java/io/trogonstack/eventstore/client/streams/AppendTests.java similarity index 88% rename from src/test/java/io/kurrent/dbclient/streams/AppendTests.java rename to src/test/java/io/trogonstack/eventstore/client/streams/AppendTests.java index b2bc0b8..26a82c4 100644 --- a/src/test/java/io/kurrent/dbclient/streams/AppendTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/streams/AppendTests.java @@ -1,7 +1,7 @@ -package io.kurrent.dbclient.streams; +package io.trogonstack.eventstore.client.streams; import com.fasterxml.jackson.databind.node.ObjectNode; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -10,7 +10,7 @@ public interface AppendTests extends ConnectionAware { @Test default void testAppendSingleEventNoStream() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); String streamName = generateName(); UUID eventId = UUID.randomUUID(); Foo foo = new Foo(); @@ -43,7 +43,7 @@ default void testAppendSingleEventNoStream() throws Throwable { @Test default void testAppendMultipleEventsAtOnce() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); String streamName = generateName(); int eventCount = 5; @@ -57,7 +57,7 @@ default void testAppendMultipleEventsAtOnce() throws Throwable { @Test default void testStreamStateOptimisticConcurrency() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); String anyStream = generateName(); appendEvent(client, anyStream, StreamState.any()); @@ -85,11 +85,11 @@ default EventData createTestEvent() throws Exception { .build(); } - default void appendEvent(KurrentDBClient client, String streamName, StreamState state) throws Exception { + default void appendEvent(TrogonEventStoreClient client, String streamName, StreamState state) throws Exception { client.appendToStream(streamName, AppendToStreamOptions.get().streamState(state), createTestEvent()).get(); } - default void assertWrongExpectedVersion(KurrentDBClient client, String streamName, StreamState state, StreamState expectedState, StreamState actualState) { + default void assertWrongExpectedVersion(TrogonEventStoreClient client, String streamName, StreamState state, StreamState expectedState, StreamState actualState) { WrongExpectedVersionException ex = Assertions.assertThrows(WrongExpectedVersionException.class, () -> { try { appendEvent(client, streamName, state); diff --git a/src/test/java/io/kurrent/dbclient/streams/ClientLifecycleTests.java b/src/test/java/io/trogonstack/eventstore/client/streams/ClientLifecycleTests.java similarity index 64% rename from src/test/java/io/kurrent/dbclient/streams/ClientLifecycleTests.java rename to src/test/java/io/trogonstack/eventstore/client/streams/ClientLifecycleTests.java index ad7a4d7..8de701c 100644 --- a/src/test/java/io/kurrent/dbclient/streams/ClientLifecycleTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/streams/ClientLifecycleTests.java @@ -1,9 +1,9 @@ -package io.kurrent.dbclient.streams; +package io.trogonstack.eventstore.client.streams; -import io.kurrent.dbclient.ConnectionAware; -import io.kurrent.dbclient.ConnectionShutdownException; -import io.kurrent.dbclient.KurrentDBClient; -import io.kurrent.dbclient.KurrentDBClientSettings; +import io.trogonstack.eventstore.client.ConnectionAware; +import io.trogonstack.eventstore.client.ConnectionShutdownException; +import io.trogonstack.eventstore.client.TrogonEventStoreClient; +import io.trogonstack.eventstore.client.TrogonEventStoreClientSettings; import org.junit.jupiter.api.Test; import java.util.concurrent.ExecutionException; @@ -16,14 +16,14 @@ public interface ClientLifecycleTests extends ConnectionAware { @Test default void testProvidesRunningStatus() { - KurrentDBClient client = getDatabase().newClient(); + TrogonEventStoreClient client = getDatabase().newClient(); assertFalse(client.isShutdown()); } @Test default void testProvidesShutdownStatusAfterManualShutdown() throws Throwable { - KurrentDBClient client = getDatabase().newClient(); + TrogonEventStoreClient client = getDatabase().newClient(); client.shutdown().get(); @@ -32,10 +32,10 @@ default void testProvidesShutdownStatusAfterManualShutdown() throws Throwable { @Test default void testProvidesShutdownStatusAfterAutomaticShutdown() throws Throwable { - KurrentDBClientSettings settings = KurrentDBClientSettings.builder() + TrogonEventStoreClientSettings settings = TrogonEventStoreClientSettings.builder() .addHost("unknown.host.name", 2113) .buildConnectionSettings(); - KurrentDBClient client = KurrentDBClient.create(settings); + TrogonEventStoreClient client = TrogonEventStoreClient.create(settings); try { client.readAll().get(); diff --git a/src/test/java/io/kurrent/dbclient/streams/DeadlineTests.java b/src/test/java/io/trogonstack/eventstore/client/streams/DeadlineTests.java similarity index 87% rename from src/test/java/io/kurrent/dbclient/streams/DeadlineTests.java rename to src/test/java/io/trogonstack/eventstore/client/streams/DeadlineTests.java index 0df32e8..a5f0025 100644 --- a/src/test/java/io/kurrent/dbclient/streams/DeadlineTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/streams/DeadlineTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.streams; +package io.trogonstack.eventstore.client.streams; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import io.grpc.Status; import io.grpc.StatusRuntimeException; import org.junit.jupiter.api.Assertions; @@ -12,7 +12,7 @@ public interface DeadlineTests extends ConnectionAware { @RetryingTest(10) default void testDefaultDeadline() { - KurrentDBClient client = getDatabase().connectWith(opts -> + TrogonEventStoreClient client = getDatabase().connectWith(opts -> opts.defaultDeadline(1) .maxDiscoverAttempts(3)); UUID id = UUID.randomUUID(); @@ -26,7 +26,7 @@ default void testDefaultDeadline() { @RetryingTest(3) default void testOptionLevelDeadline() { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); UUID id = UUID.randomUUID(); EventData data = EventDataBuilder.binary(id, "type", new byte[]{}).build(); @@ -39,7 +39,7 @@ default void testOptionLevelDeadline() { @RetryingTest(3) default void testReadStreamWithDefaultDeadline() { - KurrentDBClient client = getDatabase().connectWith(opts -> + TrogonEventStoreClient client = getDatabase().connectWith(opts -> opts.defaultDeadline(1) .maxDiscoverAttempts(3)); @@ -53,7 +53,7 @@ default void testReadStreamWithDefaultDeadline() { @RetryingTest(3) default void testReadStreamWithLevelDeadline() { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); ExecutionException e = Assertions.assertThrows( ExecutionException.class, @@ -66,7 +66,7 @@ default void testReadStreamWithLevelDeadline() { @RetryingTest(3) default void testReadAllWithDefaultDeadline() { - KurrentDBClient client = getDatabase().connectWith(opts -> + TrogonEventStoreClient client = getDatabase().connectWith(opts -> opts.defaultDeadline(1) .maxDiscoverAttempts(3)); @@ -80,7 +80,7 @@ default void testReadAllWithDefaultDeadline() { @RetryingTest(3) default void testReadAllWithLevelDeadline() { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); ReadAllOptions options = ReadAllOptions.get().deadline(1); diff --git a/src/test/java/io/kurrent/dbclient/streams/DeleteTests.java b/src/test/java/io/trogonstack/eventstore/client/streams/DeleteTests.java similarity index 83% rename from src/test/java/io/kurrent/dbclient/streams/DeleteTests.java rename to src/test/java/io/trogonstack/eventstore/client/streams/DeleteTests.java index 60cae72..a7c9a13 100644 --- a/src/test/java/io/kurrent/dbclient/streams/DeleteTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/streams/DeleteTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.streams; +package io.trogonstack.eventstore.client.streams; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -9,7 +9,7 @@ public interface DeleteTests extends ConnectionAware { @Test default void testCanDeleteStream() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); String streamName = generateName(); client.appendToStream(streamName, generateEvents(1, "foobar").iterator()).get(); @@ -19,7 +19,7 @@ default void testCanDeleteStream() throws Throwable { @Test default void testDeleteStreamWhenAlreadyDeleted() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); String streamName = generateName(); client.appendToStream(streamName, generateEvents(1, "foobar").iterator()).get(); @@ -35,7 +35,7 @@ default void testDeleteStreamWhenAlreadyDeleted() throws Throwable { @Test default void testDeleteStreamWhenDoesntExist() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); String streamName = generateName(); DeleteStreamOptions options = DeleteStreamOptions.get() diff --git a/src/test/java/io/kurrent/dbclient/streams/InterceptorTests.java b/src/test/java/io/trogonstack/eventstore/client/streams/InterceptorTests.java similarity index 73% rename from src/test/java/io/kurrent/dbclient/streams/InterceptorTests.java rename to src/test/java/io/trogonstack/eventstore/client/streams/InterceptorTests.java index 761e5bf..7f9b75e 100644 --- a/src/test/java/io/kurrent/dbclient/streams/InterceptorTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/streams/InterceptorTests.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient.streams; +package io.trogonstack.eventstore.client.streams; -import io.kurrent.dbclient.ConnectionAware; -import io.kurrent.dbclient.KurrentDBClient; -import io.kurrent.dbclient.ReadStreamOptions; +import io.trogonstack.eventstore.client.ConnectionAware; +import io.trogonstack.eventstore.client.TrogonEventStoreClient; +import io.trogonstack.eventstore.client.ReadStreamOptions; import io.grpc.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -13,7 +13,7 @@ public interface InterceptorTests extends ConnectionAware { @Test default void testInterceptorIsCalled() { AtomicInteger atom = new AtomicInteger(0); - KurrentDBClient client = getDatabase().connectWith(opts -> opts.addInterceptor(new MyInterceptor(atom))); + TrogonEventStoreClient client = getDatabase().connectWith(opts -> opts.addInterceptor(new MyInterceptor(atom))); try { client.readStream("foobar", ReadStreamOptions.get()).get(); diff --git a/src/test/java/io/kurrent/dbclient/streams/MetadataTests.java b/src/test/java/io/trogonstack/eventstore/client/streams/MetadataTests.java similarity index 85% rename from src/test/java/io/kurrent/dbclient/streams/MetadataTests.java rename to src/test/java/io/trogonstack/eventstore/client/streams/MetadataTests.java index 3f81f9e..eec032d 100644 --- a/src/test/java/io/kurrent/dbclient/streams/MetadataTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/streams/MetadataTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.streams; +package io.trogonstack.eventstore.client.streams; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -9,7 +9,7 @@ public interface MetadataTests extends ConnectionAware { @Test default void testSetStreamMetadata() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); StreamMetadata metadata = new StreamMetadata(); @@ -41,7 +41,7 @@ default void testSetStreamMetadata() throws Throwable { @Test default void testReadNoExistingMetadata() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); String streamName = generateName(); client.appendToStream(streamName, EventDataBuilder.json("bar", "data".getBytes()).build()).get(); @@ -52,7 +52,7 @@ default void testReadNoExistingMetadata() throws Throwable { @Test default void testReadMetadataAfterStreamDeletion() throws Throwable { - KurrentDBClient client = getDatabase().defaultClient(); + TrogonEventStoreClient client = getDatabase().defaultClient(); String streamName = generateName(); client.appendToStream(streamName, EventDataBuilder.json("bar", "data".getBytes()).build()).get(); diff --git a/src/test/java/io/kurrent/dbclient/streams/ReadStreamTests.java b/src/test/java/io/trogonstack/eventstore/client/streams/ReadStreamTests.java similarity index 91% rename from src/test/java/io/kurrent/dbclient/streams/ReadStreamTests.java rename to src/test/java/io/trogonstack/eventstore/client/streams/ReadStreamTests.java index 50fa83b..8af36e1 100644 --- a/src/test/java/io/kurrent/dbclient/streams/ReadStreamTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/streams/ReadStreamTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.streams; +package io.trogonstack.eventstore.client.streams; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -21,7 +21,7 @@ default void testReadStreamEvents() throws Throwable { events.add(serializeBazEvent(event)); } - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); client.appendToStream(streamName, events.iterator()).get(); ReadResult result = client.readStream(streamName, ReadStreamOptions.get()).get(); diff --git a/src/test/java/io/kurrent/dbclient/streams/SubscriptionTests.java b/src/test/java/io/trogonstack/eventstore/client/streams/SubscriptionTests.java similarity index 97% rename from src/test/java/io/kurrent/dbclient/streams/SubscriptionTests.java rename to src/test/java/io/trogonstack/eventstore/client/streams/SubscriptionTests.java index 3150957..7656e94 100644 --- a/src/test/java/io/kurrent/dbclient/streams/SubscriptionTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/streams/SubscriptionTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.streams; +package io.trogonstack.eventstore.client.streams; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; @@ -235,7 +235,7 @@ public void onCancelled(Subscription subscription, Throwable throwable) { @Test default void testCancellingSubscriptionShouldNotRaiseAnException() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); String eventType = generateName(); @@ -259,7 +259,7 @@ public void onCancelled(Subscription subscription, Throwable exception) { @Test @Timeout(value = 5, unit = TimeUnit.MINUTES) default void testCaughtUpMessageIsReceived() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); Optional version = client.getServerVersion().get(); Assumptions.assumeTrue(version.isPresent()); @@ -285,7 +285,7 @@ public void onCaughtUp(Subscription subscription, Instant timestamp, Long stream @Test @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testOnCancelledIsInvokedWhenSubscriptionIsStopped() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); client.appendToStream( @@ -323,7 +323,7 @@ public void onCancelled(Subscription subscription, Throwable exception) { @Test @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testOnCancelledIsInvokedWhenOnEventThrows() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); final CountDownLatch onCancelledReceived = new CountDownLatch(1); diff --git a/src/test/java/io/kurrent/dbclient/telemetry/PersistentSubscriptionsTracingInstrumentationTests.java b/src/test/java/io/trogonstack/eventstore/client/telemetry/PersistentSubscriptionsTracingInstrumentationTests.java similarity index 91% rename from src/test/java/io/kurrent/dbclient/telemetry/PersistentSubscriptionsTracingInstrumentationTests.java rename to src/test/java/io/trogonstack/eventstore/client/telemetry/PersistentSubscriptionsTracingInstrumentationTests.java index f069722..38c95b3 100644 --- a/src/test/java/io/kurrent/dbclient/telemetry/PersistentSubscriptionsTracingInstrumentationTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/telemetry/PersistentSubscriptionsTracingInstrumentationTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.telemetry; +package io.trogonstack.eventstore.client.telemetry; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.sdk.trace.ReadableSpan; import org.junit.jupiter.api.Assertions; @@ -16,8 +16,8 @@ public interface PersistentSubscriptionsTracingInstrumentationTests extends Tele @Test @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testPersistentSubscriptionIsInstrumentedWithTracingAndRestoresRemoteContextAsExpected() throws Throwable { - KurrentDBClient streamsClient = getDefaultClient(); - KurrentDBPersistentSubscriptionsClient psClient = getDefaultPersistentSubscriptionClient(); + TrogonEventStoreClient streamsClient = getDefaultClient(); + TrogonEventStorePersistentSubscriptionsClient psClient = getDefaultPersistentSubscriptionClient(); String streamName = generateName(); String groupName = "aGroup"; @@ -78,8 +78,8 @@ default void testPersistentSubscriptionIsInstrumentedWithTracingAndRestoresRemot @Test @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testPersistentSubscriptionInstrumentationHandlesExceptionsAsExpected() throws Throwable { - KurrentDBClient streamsClient = getDefaultClient(); - KurrentDBPersistentSubscriptionsClient psClient = getDefaultPersistentSubscriptionClient(); + TrogonEventStoreClient streamsClient = getDefaultClient(); + TrogonEventStorePersistentSubscriptionsClient psClient = getDefaultPersistentSubscriptionClient(); String streamName = generateName(); String groupName = generateName(); diff --git a/src/test/java/io/kurrent/dbclient/telemetry/SpanProcessorSpy.java b/src/test/java/io/trogonstack/eventstore/client/telemetry/SpanProcessorSpy.java similarity index 94% rename from src/test/java/io/kurrent/dbclient/telemetry/SpanProcessorSpy.java rename to src/test/java/io/trogonstack/eventstore/client/telemetry/SpanProcessorSpy.java index e17e9c4..824d627 100644 --- a/src/test/java/io/kurrent/dbclient/telemetry/SpanProcessorSpy.java +++ b/src/test/java/io/trogonstack/eventstore/client/telemetry/SpanProcessorSpy.java @@ -1,4 +1,4 @@ -package io.kurrent.dbclient.telemetry; +package io.trogonstack.eventstore.client.telemetry; import io.opentelemetry.context.Context; import io.opentelemetry.sdk.trace.ReadWriteSpan; diff --git a/src/test/java/io/kurrent/dbclient/telemetry/StreamsTracingInstrumentationTests.java b/src/test/java/io/trogonstack/eventstore/client/telemetry/StreamsTracingInstrumentationTests.java similarity index 71% rename from src/test/java/io/kurrent/dbclient/telemetry/StreamsTracingInstrumentationTests.java rename to src/test/java/io/trogonstack/eventstore/client/telemetry/StreamsTracingInstrumentationTests.java index 4e91ed0..3e52758 100644 --- a/src/test/java/io/kurrent/dbclient/telemetry/StreamsTracingInstrumentationTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/telemetry/StreamsTracingInstrumentationTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.telemetry; +package io.trogonstack.eventstore.client.telemetry; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.opentelemetry.api.trace.SpanContext; @@ -8,7 +8,6 @@ import io.opentelemetry.api.trace.StatusCode; import io.opentelemetry.sdk.trace.ReadableSpan; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -20,7 +19,7 @@ public interface StreamsTracingInstrumentationTests extends TelemetryAware { @Test default void testAppendIsInstrumentedWithTracingAsExpected() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); client.appendToStream( @@ -39,7 +38,7 @@ default void testAppendIsInstrumentedWithTracingAsExpected() throws Throwable { @Test default void testTracingContextIsInjectedAsExpectedWhenUserMetadataIsJsonObject() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); client.appendToStream( @@ -69,7 +68,7 @@ default void testTracingContextIsInjectedAsExpectedWhenUserMetadataIsJsonObject( @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testTracingContextInjectionIsIgnoredAsExpectedWhenUserMetadataIsNonNullAndNotAJsonObject() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); byte[] userMetadata = mapper.writeValueAsBytes("clearlynotvalidjson"); @@ -126,7 +125,7 @@ default void testTracingContextInjectionIsIgnoredAsExpectedWhenUserMetadataIsNon @Test default void testAppendInstrumentationHandlesExceptionsAsExpected() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); WrongExpectedVersionException actualException = null; @@ -156,7 +155,7 @@ default void testAppendInstrumentationHandlesExceptionsAsExpected() throws Throw @Test @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testCatchupSubscriptionIsInstrumentedWithTracingAndRestoresRemoteContextAsExpected() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); EventData[] events = { @@ -210,7 +209,7 @@ default void testCatchupSubscriptionIsInstrumentedWithTracingAndRestoresRemoteCo @Test @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testCatchupSubscriptionInstrumentationHandlesExceptionsAsExpected() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String streamName = generateName(); client.appendToStream( @@ -250,7 +249,7 @@ public void onCancelled(Subscription subscription, Throwable throwable) { @Test @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testCatchupSubscriptionTracingIsNotRestoredOnDeletedEvents() throws Throwable { - KurrentDBClient client = getDefaultClient(); + TrogonEventStoreClient client = getDefaultClient(); String category = UUID.randomUUID().toString().replace("-", ""); String streamName = category + "-test"; @@ -292,107 +291,4 @@ public void onEvent(Subscription subscription, ResolvedEvent event) { Assertions.assertTrue(subscribeSpans.isEmpty(), "No spans should be recorded for deleted events"); } - @Test - default void testMultiStreamAppendIsInstrumentedWithTracingAsExpected() throws Throwable { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(25, 0), - "Multi-stream append is not supported server versions below 25.0.0" - ); - - String streamName1 = generateName(); - String streamName2 = generateName(); - - EventData event1 = EventData.builderAsJson("TestEvent", mapper.writeValueAsBytes(new Foo())) - .eventId(UUID.randomUUID()) - .build(); - - EventData event2 = EventData.builderAsJson("TestEvent", mapper.writeValueAsBytes(new Foo())) - .eventId(UUID.randomUUID()) - .build(); - - AppendStreamRequest request1 = new AppendStreamRequest( - streamName1, - Collections.singletonList(event1).iterator(), - StreamState.noStream() - ); - - AppendStreamRequest request2 = new AppendStreamRequest( - streamName2, - Collections.singletonList(event2).iterator(), - StreamState.noStream() - ); - - MultiStreamAppendResponse result = client.multiStreamAppend( - Arrays.asList(request1, request2).iterator() - ).get(); - - Assertions.assertFalse(result.getResults().isEmpty()); - Assertions.assertTrue(result.getPosition() > 0); - - List spans = getSpansForOperation(ClientTelemetryConstants.Operations.MULTI_APPEND); - Assertions.assertEquals(1, spans.size()); - - assertSpanAttributeEquals(spans.get(0), ClientTelemetryAttributes.Database.SYSTEM, ClientTelemetryConstants.INSTRUMENTATION_NAME); - assertSpanAttributeEquals(spans.get(0), ClientTelemetryAttributes.Database.OPERATION, ClientTelemetryConstants.Operations.MULTI_APPEND); - assertSpanAttributeEquals(spans.get(0), ClientTelemetryAttributes.Database.USER, "admin"); - Assertions.assertEquals(StatusCode.OK, spans.get(0).toSpanData().getStatus().getStatusCode()); - Assertions.assertEquals(SpanKind.CLIENT, spans.get(0).getKind()); - } - - @Test - default void testMultiStreamAppendIsInstrumentedWithErrors() throws Throwable { - KurrentDBClient client = getDefaultClient(); - - Optional version = client.getServerVersion().get(); - - Assumptions.assumeTrue( - version.isPresent() && version.get().isGreaterOrEqualThan(25, 0), - "Multi-stream append is not supported server versions below 25.0.0" - ); - - String streamName1 = generateName(); - String streamName2 = generateName(); - - EventData event1 = EventData.builderAsJson("TestEvent", mapper.writeValueAsBytes(new Foo())) - .eventId(UUID.randomUUID()) - .build(); - - EventData event2 = EventData.builderAsJson("TestEvent", mapper.writeValueAsBytes(new Foo())) - .eventId(UUID.randomUUID()) - .build(); - - AppendStreamRequest request1 = new AppendStreamRequest( - streamName1, - Collections.singletonList(event1).iterator(), - StreamState.noStream() - ); - - AppendStreamRequest request2 = new AppendStreamRequest( - streamName2, - Collections.singletonList(event2).iterator(), - StreamState.streamExists() - ); - - WrongExpectedVersionException actualException = null; - try { - MultiStreamAppendResponse result = client.multiStreamAppend( - Arrays.asList(request1, request2).iterator() - ).get(); - } catch (ExecutionException e) { - if (e.getCause() instanceof WrongExpectedVersionException) - actualException = (WrongExpectedVersionException) e.getCause(); - } - - // Ensure WrongExpectedVersionException was thrown. - Assertions.assertNotNull(actualException); - - List spans = getSpansForOperation(ClientTelemetryConstants.Operations.MULTI_APPEND); - Assertions.assertEquals(1, spans.size()); - - assertErroneousSpanHasExpectedAttributes(spans.get(0), actualException); - } } diff --git a/src/test/java/io/kurrent/dbclient/telemetry/TelemetryAware.java b/src/test/java/io/trogonstack/eventstore/client/telemetry/TelemetryAware.java similarity index 86% rename from src/test/java/io/kurrent/dbclient/telemetry/TelemetryAware.java rename to src/test/java/io/trogonstack/eventstore/client/telemetry/TelemetryAware.java index edf0e9d..0815c7f 100644 --- a/src/test/java/io/kurrent/dbclient/telemetry/TelemetryAware.java +++ b/src/test/java/io/trogonstack/eventstore/client/telemetry/TelemetryAware.java @@ -1,8 +1,8 @@ -package io.kurrent.dbclient.telemetry; +package io.trogonstack.eventstore.client.telemetry; -import io.kurrent.dbclient.ClientTelemetryAttributes; -import io.kurrent.dbclient.ClientTelemetryConstants; -import io.kurrent.dbclient.ConnectionAware; +import io.trogonstack.eventstore.client.ClientTelemetryAttributes; +import io.trogonstack.eventstore.client.ClientTelemetryConstants; +import io.trogonstack.eventstore.client.ConnectionAware; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.api.trace.StatusCode; @@ -21,7 +21,7 @@ public interface TelemetryAware extends ConnectionAware { default void assertAppendSpanHasExpectedAttributes(ReadableSpan span, String streamName) { assertSpanAttributeEquals(span, ClientTelemetryAttributes.Database.SYSTEM, ClientTelemetryConstants.INSTRUMENTATION_NAME); assertSpanAttributeEquals(span, ClientTelemetryAttributes.Database.OPERATION, ClientTelemetryConstants.Operations.APPEND); - assertSpanAttributeEquals(span, ClientTelemetryAttributes.KurrentDB.STREAM, streamName); + assertSpanAttributeEquals(span, ClientTelemetryAttributes.TrogonEventStore.STREAM, streamName); assertSpanAttributeEquals(span, ClientTelemetryAttributes.Database.USER, "admin"); Assertions.assertEquals(StatusCode.OK, span.toSpanData().getStatus().getStatusCode()); Assertions.assertEquals(SpanKind.CLIENT, span.getKind()); @@ -42,10 +42,10 @@ default void assertSubscriptionActivityHasExpectedAttributes(ReadableSpan span, assertSpanAttributeEquals(span, ClientTelemetryAttributes.Database.SYSTEM, ClientTelemetryConstants.INSTRUMENTATION_NAME); assertSpanAttributeEquals(span, ClientTelemetryAttributes.Database.OPERATION, ClientTelemetryConstants.Operations.SUBSCRIBE); assertSpanAttributeEquals(span, ClientTelemetryAttributes.Database.USER, "admin"); - assertSpanAttributeEquals(span, ClientTelemetryAttributes.KurrentDB.STREAM, streamName); - assertSpanAttributeEquals(span, ClientTelemetryAttributes.KurrentDB.SUBSCRIPTION_ID, subscriptionId); - assertSpanAttributeEquals(span, ClientTelemetryAttributes.KurrentDB.EVENT_ID, eventId); - assertSpanAttributeEquals(span, ClientTelemetryAttributes.KurrentDB.EVENT_TYPE, eventType); + assertSpanAttributeEquals(span, ClientTelemetryAttributes.TrogonEventStore.STREAM, streamName); + assertSpanAttributeEquals(span, ClientTelemetryAttributes.TrogonEventStore.SUBSCRIPTION_ID, subscriptionId); + assertSpanAttributeEquals(span, ClientTelemetryAttributes.TrogonEventStore.EVENT_ID, eventId); + assertSpanAttributeEquals(span, ClientTelemetryAttributes.TrogonEventStore.EVENT_TYPE, eventType); Assertions.assertEquals(StatusCode.OK, span.toSpanData().getStatus().getStatusCode()); Assertions.assertEquals(SpanKind.CONSUMER, span.getKind()); } diff --git a/src/test/java/io/kurrent/dbclient/telemetry/TracingContextInjectionTests.java b/src/test/java/io/trogonstack/eventstore/client/telemetry/TracingContextInjectionTests.java similarity index 90% rename from src/test/java/io/kurrent/dbclient/telemetry/TracingContextInjectionTests.java rename to src/test/java/io/trogonstack/eventstore/client/telemetry/TracingContextInjectionTests.java index da13e05..e2f96cd 100644 --- a/src/test/java/io/kurrent/dbclient/telemetry/TracingContextInjectionTests.java +++ b/src/test/java/io/trogonstack/eventstore/client/telemetry/TracingContextInjectionTests.java @@ -1,6 +1,6 @@ -package io.kurrent.dbclient.telemetry; +package io.trogonstack.eventstore.client.telemetry; -import io.kurrent.dbclient.*; +import io.trogonstack.eventstore.client.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -15,8 +15,8 @@ public interface TracingContextInjectionTests extends TelemetryAware { @Test @Timeout(value = 2, unit = TimeUnit.MINUTES) default void testTracingContextInjectionDoesNotAffectEventBody() throws Throwable { - KurrentDBClient streamsClient = getDefaultClient(); - KurrentDBPersistentSubscriptionsClient psClient = getDefaultPersistentSubscriptionClient(); + TrogonEventStoreClient streamsClient = getDefaultClient(); + TrogonEventStorePersistentSubscriptionsClient psClient = getDefaultPersistentSubscriptionClient(); String streamName = generateName(); String groupName = "aGroup"; diff --git a/src/test/resources/simplelogger.properties b/src/test/resources/simplelogger.properties index 9b4876a..c849008 100644 --- a/src/test/resources/simplelogger.properties +++ b/src/test/resources/simplelogger.properties @@ -1,2 +1,2 @@ org.slf4j.simpleLogger.defaultLogLevel=error -org.slf4j.simpleLogger.log.io.kurrent.dbclient=debug \ No newline at end of file +org.slf4j.simpleLogger.log.io.trogonstack.eventstore.client=debug \ No newline at end of file diff --git a/vars.env b/vars.env index a3ecdad..917e77c 100644 --- a/vars.env +++ b/vars.env @@ -2,7 +2,7 @@ EVENTSTORE_CLUSTER_SIZE=3 EVENTSTORE_RUN_PROJECTIONS=All EVENTSTORE_REPLICATION_PORT=1112 EVENTSTORE_NODE_PORT=2113 -EVENTSTORE_TRUSTED_ROOT_CERTIFICATES_PATH=/etc/kurrentdb/certs/ca +EVENTSTORE_TRUSTED_ROOT_CERTIFICATES_PATH=/etc/trogon-eventstore/certs/ca EVENTSTORE_DISCOVER_VIA_DNS=false EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=true EVENTSTORE_ADVERTISE_HOST_TO_CLIENT_AS=localhost