Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LC-195: Introduce an 8.0 Compatibility Setting to Streamline Future Migrations #1172

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.cloud.common.config.kcqlprops

import enumeratum.Enum
import enumeratum.EnumEntry
import io.lenses.streamreactor.connect.cloud.common.config.kcqlprops.PropsKeyEnum.KeyNameFormatVersion
import io.lenses.streamreactor.connect.config.kcqlprops.KcqlProperties

sealed trait KeyNamerVersion extends EnumEntry

object KeyNamerVersion extends Enum[KeyNamerVersion] {

case object V0 extends KeyNamerVersion

case object V1 extends KeyNamerVersion

def apply(
props: KcqlProperties[PropsKeyEntry, PropsKeyEnum.type],
default: KeyNamerVersion,
): KeyNamerVersion = fromProps(props).getOrElse(default)

private def fromProps(props: KcqlProperties[PropsKeyEntry, PropsKeyEnum.type]): Option[KeyNamerVersion] =
props.getOptionalInt(KeyNameFormatVersion).collect {
case 0 => V0
case 1 => V1
}

override def values: IndexedSeq[KeyNamerVersion] = findValues
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ object PropsKeyEnum extends Enum[PropsKeyEntry] {
case object FlushCount extends PropsKeyEntry("flush.count")

case object FlushInterval extends PropsKeyEntry("flush.interval")

case object KeyNameFormatVersion extends PropsKeyEntry("key.name.format.version")
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ object SinkPropsSchema {
FlushCount -> LongPropsSchema,
FlushSize -> LongPropsSchema,
FlushInterval -> IntPropsSchema,
KeyNameFormatVersion -> IntPropsSchema,
)

val schema: KcqlPropsSchema[PropsKeyEntry, PropsKeyEnum.type] =
Expand Down
Loading