Jackson
Jackson is the default serialization format. No extra configuration is usually required for workflow/activity parameters to be serialized.
ZIO-Temporal goes with:
- Jackson-Scala module
- Java 8 data time module
(1) If custom serialization logic is required, refer to Jackson documentation.
(2) If providing a custom ObjectMapper
is required (like this):
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.json.JsonMapper
// Scala module
import com.fasterxml.jackson.module.scala.DefaultScalaModule
val CustomMapper: ObjectMapper = JsonMapper
.builder()
.addModule(DefaultScalaModule)
// Do whatever you need
.build()
// CustomMapper: ObjectMapper = com.fasterxml.jackson.databind.json.JsonMapper@1d8cf971
Override the default ZWorkflowClientOptions
by providing a new DataConverter
:
import zio._
import zio.temporal.json._
import zio.temporal.workflow.ZWorkflowClientOptions
import io.temporal.common.converter.DataConverter
// Create a data converter
val dataConverter: DataConverter = JacksonDataConverter.make(CustomMapper)
// dataConverter: DataConverter = io.temporal.common.converter.DefaultDataConverter@23aedfc0
// Create a new ZWorkflowClientOptions
val optionsLayer =
ZWorkflowClientOptions.make @@
// override any configuration if needed
ZWorkflowClientOptions.withDataConverter(dataConverter)
// optionsLayer: ZLayer[Any, Config.Error, ZWorkflowClientOptions] = Suspend(
// self = zio.ZLayer$$Lambda$8955/0x00007fea09a20580@45cd7769
// )