FS2 Kafka Vulcan

Migration Guide

fs2-kafka-vulcan 5.x uses Vulcan 2.x, which is written in pure Scala, without the official Apache Avro Java library. Serializers and deserializers are now part of fs2-kafka-vulcan, instead of using the Confluent serializers, and schema registries are accessed using http4s-schema-registry.

This page describes what has changed from 4.x, and what to use instead in 5.x. Records use the same wire format as in 4.x, and Codec schemas remain the same, except in some minor cases.

Dependencies

fs2-kafka-vulcan 5.x is published under org.typelevel instead of com.github.fd4s, and no longer depends on the Apache Avro or Confluent libraries, so the Confluent resolver is no longer needed.

libraryDependencies += "org.typelevel" %% "fs2-kafka-vulcan" % "5.0.0-RC1"

The fs2-kafka-vulcan-testkit-munit module keeps its name. Both modules are published for Scala 2.13 and 3.3, and Scala 2.12 is no longer supported.

Codecs use Vulcan 2.x, which is published under org.typelevel and uses the org.typelevel.vulcan package, so if you depend on Vulcan directly, also update it. Also see the Vulcan 2.x migration guide.

The schema registry client uses an http4s Client, for example http4s-ember-client.

API Changes

The following table shows what has changed from 4.x, and what to use instead in 5.x.

4.x 5.x
import vulcan.Codec import org.typelevel.vulcan.Codec
SchemaRegistryClientSettings[F](baseUrl) SchemaRegistryClientBuilder.default(client, uri), then build, with an http4s Client and Uri
withAuth(auth), with fs2.kafka.vulcan.Auth withAuth(auth), with org.http4s.schemaregistry.Auth, which has the same Basic, Bearer and None options
SSL, proxy, timeout and header properties Configure the http4s Client, for example using EmberClientBuilder settings and client middleware
withMaxCacheSize Removed; the client caches schemas as described in caching
AvroSettings(settings), AvroSettings(client) AvroSerializer.default(client) and AvroDeserializer.default(client), with a SchemaRegistryClient
AvroSettings(client) with a MockSchemaRegistryClient TestSchemaRegistry[F], then client.build, see testing
avroSerializer[A] or AvroSerializer[A], then forKey(settings) or forValue(settings) AvroSerializer.default(client), then forKey[A] or forValue[A]
avroDeserializer[A] or AvroDeserializer[A], then forKey(settings) or forValue(settings) AvroDeserializer.default(client), then forKey[A] or forValue[A]
withAutoRegisterSchemas(false) on AvroSettings withAutoRegisterSchemas(false) on AvroSerializer
withKeySubjectNameStrategy, withValueSubjectNameStrategy with class names withSubjectNameStrategy(SubjectNameStrategy.RecordName), which applies to both keys and values; also TopicName, TopicRecordName and SubjectNameStrategy.custom
withProperty("normalize.schemas", "true") withNormalizeSchemas(true)
withProperty("use.latest.version", "true"), withProperty("use.schema.id", id) withLatestVersion, withSchemaId(SchemaId(id)); see writer schemas
registerSchema[A](subject) on AvroSettings, returning F[Int] registerSchema[A](SubjectName(subject)) on AvroSerializer, returning F[SchemaId]
withCreateAvroSerializer, withCreateAvroDeserializer, withRegisterSchema, withCreateSchemaRegistryClient Removed; customize requests to the schema registry using http4s client middleware
KafkaAvroSerializer, KafkaAvroDeserializer, SchemaRegistryClient and CachedSchemaRegistryClient aliases Removed; org.http4s.schemaregistry.SchemaRegistryClient replaces the Confluent client
compatibilityChecker(clientSettings) compatibilityChecker(client), with a Resource[IO, SchemaRegistryClient[IO]]
newCompatibilityChecker(clientSettings), returning IO newCompatibilityChecker(client), with a SchemaRegistryClient[IO]
checkReaderCompatibility, checkWriterCompatibility checkCompatibility(codec, SubjectName(subject))
assertReaderCompatibility, assertWriterCompatibility assertCompatibility(codec, SubjectName(subject))

Behaviour Changes

New Features