Skip to content

Commit 9353d70

Browse files
Prepare documentation for zio-kafka 3 (#1473)
1 parent 1dea69a commit 9353d70

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
id: migrating-to-2.11
3-
title: "Migrating to zio-kafka 2.11"
2+
id: migrating-to-zio-kafka-3
3+
title: "Migrating to zio-kafka 3"
44
---
55

6-
Zio-kafka 2.11 paves the way for zio-kafka 3.0 by deprecating things that will be removed in zio-kafka 3.0.
7-
8-
If you encounter deprecated methods in your code, follow this guide.
6+
Zio-kafka 3.0.0 removes everything that was deprecated in the zio-kafka 2.x series. In particular, this includes
7+
accessor methods. To prepare for zio-kafka 3.0, _you should always first migrate to zio-kafka 2.11.0_ and solve all
8+
deprecation issues, using this page as a guide.
99

1010
# Renamed methods
1111

@@ -25,7 +25,7 @@ you use these accessor methods follow one of these approaches:
2525
## Use the ZIO Service pattern
2626

2727
This is the best option. For established codebases it may be a lot of work to get here. If you are already follow
28-
this pattern, using it for zio-kafka services as well will be easy.
28+
this pattern, using it for zio-kafka services as well will be easy. See [ZIO service pattern](https://zio.dev/reference/service-pattern/) for more information.
2929

3030
Here is an example with a `Consumer`, but it works the same with `Producer` and `TransactionalProducer`. We get the
3131
`Consumer` from the environment in the layer with the `ZIO.service` method, and then inject it into the service class.
@@ -57,6 +57,9 @@ case class ServiceLive(consumer: Consumer) extends Service {
5757
}
5858
```
5959

60+
Constructing a `Consumer` layer is described in [creating a consumer](creating-a-consumer.md). Constructing a
61+
`Producer` or `TransactionalProducer` layer works in a similar way.
62+
6063
## YOLO, use `ZIO.service` everywhere
6164

6265
The other option is to replace all accessor methods of `Consumer`, `Producer` and `TransactionalProducer` as follows:
@@ -65,7 +68,9 @@ The other option is to replace all accessor methods of `Consumer`, `Producer` an
6568
- `Producer.method(...)` => `ZIO.serviceWithZIO[Producer](_.method(...))`
6669
- `TransactionalProducer.method(...)` => `ZIO.serviceWithZIO[TransactionalProducer](_.method(...))`
6770

68-
Or, alternatively, use `ZIO.service`: `Consumer.method(...)` is transformed to:
71+
Or, alternatively, use `ZIO.service`.
72+
73+
For example: `Consumer.method(...)` is transformed to:
6974
```scala
7075
for {
7176
consumer <- ZIO.service[Consumer]
@@ -98,6 +103,7 @@ override def spec: Spec[TestEnvironment, Any] =
98103
}
99104
)
100105
.provideSome[Kafka](KafkaTestUtils.producer)
106+
.provideShared(Kafka.embedded)
101107

102108
// New
103109
// Added `Scope`:
@@ -111,7 +117,9 @@ override def spec: Spec[TestEnvironment & Scope, Any] =
111117
_ <- KafkaTestUtils.produceOne(producer, "topic", "key", "message")
112118
} yield assertCompletes
113119
}
114-
// No more layer magic!
120+
// Producer layer removed.
121+
.provideSomeShared[Scope](Kafka.embedded)
122+
// Using `provideSomeShared[Scope]` instead of `provideShared`
115123
)
116124
```
117125

@@ -135,6 +143,10 @@ for {
135143
} yield ()
136144
```
137145

146+
# `restartStreamOnRebalancing` mode
147+
148+
This mode will no longer be available in zio-kafka 3. Contact us on [Discord](https://discord.com/channels/629491597070827530/629497941719121960) for alternatives.
149+
138150
# Other changes?
139151

140152
If you find a change that is not documented here then please let us know via a

docs/sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const sidebars = {
1616
"sharing-consumer",
1717
"serialization-and-deserialization",
1818
"writing-tests",
19-
"migrating-to-2.11"
19+
"migrating-to-zio-kafka-3"
2020
]
2121
}
2222
]

0 commit comments

Comments
 (0)