Repository navigation
Releases
v5.0.0-RC1
This is the first release candidate of fs2-kafka-vulcan 5.0, which uses Vulcan 2.0.0-RC1, http4s-schema-registry 1.0.0-RC1, and fs2-kafka 4.3.0. It breaks binary and source compatibility with 4.x, and is not binary compatible with 5.0.0-M1. We're looking for feedback before the final 5.0.0 release, so please raise an issue or join us on Discord to discuss.
The intent is to keep binary compatibility in following release candidates, unless issues are discovered which require breaking changes. There are no more features planned for the 5.0.0 release. When upgrading from 4.x, refer to the migration guide for the changes.
libraryDependencies += "org.typelevel" %% "fs2-kafka-vulcan" % "5.0.0-RC1"For this release, we have a new project logo and a new website based on Laika/sbt-typelevel-site.
Highlights for this release include the following.
- Writing values using the latest version of the subject, or the schema with an id, like
use.latest.versionanduse.schema.idfor the Confluent serializers. - Writing schema GUIDs in the
__key_schema_idand__value_schema_idrecord headers, like the ConfluentHeaderSchemaIdSerializer.
Writer Schemas
AvroSerializer can write values using the latest version of the subject, or the schema with an id, rather than the schema of the Codec.
AvroSerializer.default(client).withLatestVersion.forValue[Person]
AvroSerializer.default(client).withSchemaId(SchemaId(42)).forValue[Person]- Values are resolved into the writer schema following Avro's schema resolution, using
Codec#binaryEncoder(writerSchema)from Vulcan 2.0.0-RC1, so fields missing in theCodecuse the defaults of the writer schema. - Serialization fails if values cannot be written using the writer schema, like
latest.compatibility.strictandid.compatibility.strictfor the Confluent serializers, which are enabled by default. There is no non-strict mode. - Schemas are not registered automatically when using these settings. The last of
withAutoRegisterSchemas,withLatestVersion, andwithSchemaIdapplies. - The
SchemaRegistryClientcaches latest versions for as long as it is used, or until a new version is registered using the client, like the Confluent serializers. UseSchemaRegistryClientBuilder#withLatestCacheExpiryto expire them, likelatest.cache.ttl.sec.
Schema Identifiers in Headers
AvroSerializer can write schema GUIDs in the __key_schema_id and __value_schema_id record headers, in which case values are not prefixed with the schema id.
AvroSerializer.default(client).withSchemaIdHeaders(true).forValue[Person]- This requires a schema registry supporting schema GUIDs, like Confluent Schema Registry. Serialization fails if the registry does not return GUIDs, for example with Karapace.
- Deserializers read schema identifiers in headers since 5.0.0-M1.
Changes Since 5.0.0-M1
- Use Vulcan 2.0.0-RC1, which is not binary compatible with 2.0.0-M1, so if you depend on Vulcan directly, also update it to 2.0.0-RC1. Refer to its release notes for changes, including support for recursive types.
- Use http4s-schema-registry 1.0.0-RC1, which updates http4s to 0.23.39 and fs2 to 3.16.0.
- Use fs2-kafka 4.3.0, where serializers can modify record headers.
Full Changelog: v5.0.0-M1...v5.0.0-RC1
v5.0.0-M1
This is the first milestone release of fs2-kafka-vulcan 5.0. It uses Vulcan 2.0.0-M1, which is written in pure Scala and no longer uses the Java Apache Avro library. As a result, fs2-kafka-vulcan no longer uses the Confluent serializers or the Confluent schema registry client. Serializers and deserializers are now part of fs2-kafka-vulcan, using the same wire format as the Confluent serializers, and schema registry support is provided by http4s-schema-registry (1.0.0-M1). Note this release breaks binary and source compatibility with 4.x, and binary compatibility is not guaranteed between milestone releases.
Highlights for this release include the following.
- There is no longer dependencies on the Apache Avro or Confluent libraries.
- Publishing has moved from the
com.github.fd4sgroup toorg.typelevel. - The wire format and schemas maintain compatibility with fs2-kafka-vulcan 4.x.
- Single shared schema registry client with caching from http4s-schema-registry.
- Creating serializers or deserializers now fails early if the codec schema is invalid.
- Supports schema identifiers in headers when deserializing (
__key_schema_idand__value_schema_id).- Serialization support requires additional changes in fs2-kafka and is planned for the next milestone.
The following example shows the most common changes.
// 4.x
import fs2.kafka.vulcan.{Auth, AvroSettings, SchemaRegistryClientSettings, avroSerializer}
import vulcan.Codec
val avroSettings =
AvroSettings {
SchemaRegistryClientSettings[IO]("http://localhost:8081")
.withAuth(Auth.Basic("username", "password"))
}
val serializer = avroSerializer[Person].forValue(avroSettings)
// 5.0
import fs2.kafka.vulcan.AvroSerializer
import org.http4s.ember.client.EmberClientBuilder
import org.http4s.schemaregistry.{Auth, SchemaRegistryClientBuilder}
import org.http4s.syntax.literals._
import org.typelevel.vulcan.Codec
val serializer =
EmberClientBuilder.default[IO].build
.evalMap { client =>
SchemaRegistryClientBuilder
.default(client, uri"http://localhost:8081")
.withAuth(Auth.Basic("username", "password"))
.build
}
.flatMap(client => AvroSerializer.default(client).forValue[Person])The following table shows what has, and has not, changed from 4.x, and what to do instead in 5.0.
| 4.x | 5.0 |
|---|---|
"com.github.fd4s" %% "vulcan" and import vulcan.Codec |
"org.typelevel" %% "vulcan" % "2.0.0-M1" and import org.typelevel.vulcan.Codec. Refer to the Vulcan 2.0.0-M1 release notes for changes to codecs. |
resolvers += "confluent"... |
No longer needed. |
| Scala 2.12 | No longer supported. |
SchemaRegistryClientSettings[F](url).withAuth(auth) |
SchemaRegistryClientBuilder.default(client, uri).withAuth(auth).build, using an http4s Client. |
fs2.kafka.vulcan.Auth |
org.http4s.schemaregistry.Auth, with the same Basic, Bearer, and None options. |
AvroSettings(settings) and AvroSettings(client) |
Removed. Settings are on AvroSerializer.default(client) and AvroDeserializer.default(client). |
avroSerializer[A].forValue(settings) and avroDeserializer[A].forKey(settings) |
AvroSerializer.default(client).forValue[A] and AvroDeserializer.default(client).forKey[A]. |
withAutoRegisterSchemas(false) |
AvroSerializer.default(client).withAutoRegisterSchemas(false). |
withKeySubjectNameStrategy/withValueSubjectNameStrategy with class names |
withSubjectNameStrategy(SubjectNameStrategy.RecordName), which applies to both keys and values. Use TopicName, RecordName, TopicRecordName, or SubjectNameStrategy.custom for custom strategies. |
withProperty("normalize.schemas", "true") |
withNormalizeSchemas(true). |
| SSL, proxy, timeout, and header properties | Configure the http4s client, for example using EmberClientBuilder settings and client middleware. |
withMaxCacheSize |
Removed. The schema registry client caches schemas as described here. |
withCreateAvroSerializer, withCreateAvroDeserializer, withRegisterSchema, withCreateSchemaRegistryClient |
Removed. Create the SchemaRegistryClient with SchemaRegistryClientBuilder, or with TestSchemaRegistry in tests, and customize requests to the schema registry using http4s client middleware. |
MockSchemaRegistryClient in tests |
TestSchemaRegistry[IO].flatMap(_.client.build) from http4s-schema-registry. |
registerSchema[A](subject): F[Int] |
AvroSerializer.default(client).registerSchema[A](SubjectName(subject)): F[SchemaId]. registerKeySchema[A](topic) and registerValueSchema[A](topic) use the subject name strategy. |
Serializers for codecs with invalid schemas failed on every serialize |
Creating the serializer fails, the same as deserializers, so the producer cannot be created. |
| Exceptions from the Confluent serializers and schema registry client | Error responses... |
v4.2.0
fs2-kafka-vulcan and fs2-kafka-vulcan-testkit-munit modules have moved from fs2-kafka. Artifact names and packages are unchanged, so a version bump should be enough to upgrade. The documentation has moved from the fs2-kafka website to the readme.
This is the last release with the same version as fs2-kafka. Going forward, the modules will follow their own release schedule, as we prepare the next major release using Vulcan 2.0, which will no longer use the Confluent serializers and schema registry client.
Updates
- Update fs2-kafka to 4.2.0 by @vlovgr in #1
- Update kafka-avro-serializer, ... to 8.4.0 by @typelevel-steward[bot] in typelevel/fs2-kafka#1540
- Update logback-classic to 1.6.6 by @typelevel-steward[bot] in typelevel/fs2-kafka#1538
- Update scala3-library to 3.3.9 by @typelevel-steward[bot] in typelevel/fs2-kafka#1535
- Update vulcan to 1.14.1 by @typelevel-steward[bot] in typelevel/fs2-kafka#1539
Miscellaneous
- Move fs2-kafka-vulcan modules to separate repository by @vlovgr in typelevel/fs2-kafka#1548
- Update scalafmt config and use scalafix to organize imports by @vlovgr in typelevel/fs2-kafka#1544
Full Changelog: v4.1.3...v4.2.0