-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from lensesio-dev/chore/refactor-simplify-sta…
…te-management HTTP Sink - Avoid State Conflicts
- Loading branch information
Showing
11 changed files
with
640 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Functional Tests Only | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
run-func-tests: | ||
timeout-minutes: 30 | ||
#runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
module: ["http"] | ||
connectImageVersion: [ 7.3.1, 6.2.2 ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
- name: Get version | ||
id: version | ||
shell: bash | ||
run: | | ||
if [ "${{ inputs.version }}" != "" ]; then | ||
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | ||
else | ||
echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Build assembly | ||
env: | ||
JVM_OPTS: -Xmx3200m | ||
VERSION: ${{ steps.version.outputs.version }} | ||
run: sbt "project ${{ matrix.module }};set assembly / test := {}" assembly | ||
- name: Run tests | ||
run: sbt "project ${{ matrix.module }}" fun:test | ||
env: | ||
JVM_OPTS: -Xmx3200m | ||
CONNECT_IMAGE_VERSION: ${{matrix.connectImageVersion}} | ||
- name: Publish test results | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: "**/target/**/test-reports/*.xml" | ||
check_name: ${{ matrix.module }}-${{ matrix.connectImageVersion }}-fun-results | ||
comment_mode: off | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
kafka-connect-http/src/main/scala/io/lenses/streamreactor/connect/http/sink/BatchInfo.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2017-2024 Lenses.io Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.lenses.streamreactor.connect.http.sink | ||
|
||
import cats.data.NonEmptySeq | ||
import io.lenses.streamreactor.connect.http.sink.commit.HttpCommitContext | ||
import io.lenses.streamreactor.connect.http.sink.tpl.RenderedRecord | ||
|
||
/** | ||
* \`BatchInfo\` represents information about a batch of records in the queue. | ||
*/ | ||
sealed trait BatchInfo { | ||
|
||
/** | ||
* Get the total number of records in the queue. | ||
* @return queueSize the total number of records in the queue. | ||
*/ | ||
def queueSize: Int | ||
} | ||
|
||
/** | ||
* EmptyBatchInfo may be returned in the following circumstances: | ||
* - there is no data in the queue to process | ||
* - there is data in the queue however not enough for a batch (the commit has not been triggered per the CommitPolicy) | ||
* @param queueSize the total number of records in the queue. | ||
*/ | ||
case class EmptyBatchInfo(queueSize: Int) extends BatchInfo | ||
|
||
/** | ||
* NonEmptyBatchInfo is returned for an actual batch of data. | ||
* @param batch the RenderedRecords to return | ||
* @param updatedCommitContext the amended commit context | ||
* @param queueSize the total number of records in the queue. | ||
*/ | ||
case class NonEmptyBatchInfo( | ||
batch: NonEmptySeq[RenderedRecord], | ||
updatedCommitContext: HttpCommitContext, | ||
queueSize: Int, | ||
) extends BatchInfo |
Oops, something went wrong.