Defining flows | ZIO

submited by
Style Pass
2022-12-03 18:30:09

ZIO Flow is based on defining executable workflows as values of the type ZFlow[R, E, A]. This type is similar to ZIO[R, E, A] in that it represents a program as a value that can fail with the type E or succeed with the type A. The most important difference is that a ZFlow value is serializable, which means that it can be sent over the network for a remote executor.

When working with ZFlow programs, another core concept of ZIO Flow is remote values. There is a separate section about working with remote values and remote functions. In this section we will focus on how to define flows and we can assume that remote values and functions work similarly to regular Scala values and functions.

The basic building blocks of defining a ZFlow workflow are similar to ZIO. We can use succeed or fail to create a flow that finishes with a result immediately:

Note that the above code does not run anything; it just defines workflows as serializable values of the type ZFlow that can be later sent to an executor. In the future code examples we will not show the evaluated ZFlow values as they can be very verbose.

Leave a Comment