ZIO Framework Documentation

website·Indexed 35 days ago

https://zio.dev

A next-generation, high-performance framework for building cloud-native applications on the JVM. ZIO features a highly concurrent model powered by lightweight virtual threads called fibers, providing robust error handling, resource management, and a powerful dependency injection system via ZLayer and ZEnvironment. The documentation covers core concepts including effects, concurrent data types like Hub, Promise, Queue, Ref, and Semaphore, as well as architectural patterns such as Onion Architecture.

Tokens
689.7K
Snippets
3.5K
Records
4.2K
Agent score
72%

What's inside ZIO

  1. Overview of zio-blocks-sql

    The zio-blocks-sql module provides a type-safe, schema-driven approach to SQL query building and execution. It leverages the ZIO Blocks Schema system to synchronize Scala data models with database columns at compile time, avoiding runtime reflection. Key features include compile-time SQL parameterization via the sql"..." interpolator to prevent SQL injection, composable SQL fragments, and explicit transaction management with automatic commit/rollback.
  2. Overview of ZIO Blocks

    ZIO Blocks is a family of type-safe, modular building blocks for Scala applications. Each block is a standalone library with zero or minimal dependencies, designed to be compatible with any Scala stack (ZIO, Cats Effect, Kyo, Ox, Akka, or plain Scala) and cross-platform (JVM, JS).
  3. Overview of izumi-reflect

    izumi-reflect is a fast, lightweight, and portable alternative to TypeTag from scala-reflect. It provides a simulator of the Scala typechecker and a lightweight model of the Scala type system. Key advantages include:

    • Faster compilation and execution compared to scala-reflect.
    • Full immutability and thread-safety.
    • Support for Scala 2.11, 2.12, 2.13, and Scala 3.
    • Compatibility with Scala.js, Scala Native, and GraalVM Native Image.
    • Ability to obtain and combine tags for unapplied type constructors (e.g., F[_]) at runtime.
  4. Overview of ZIO Temporal

    ZIO Temporal is a ZIO library based on the Temporal Java-SDK. It provides first-class Scala and ZIO support for the Temporal platform, adding compile-time checks not available in the Java SDK. Temporal is used for durable execution of microservice workflows, eliminating the need for complex retry logic and callbacks.
  5. Overview of zio-blocks-openapi

    zio-blocks-openapi is a type-safe OpenAPI 3.1 data model for building API documentation programmatically in Scala. It provides immutable case classes and sealed traits representing OpenAPI concepts (operations, parameters, security schemes, components), allowing developers to construct specifications at compile-time and export them as JSON for tools like Swagger UI and Redoc.
  6. Overview of ZIO Quill

    ZIO Quill is a library that provides a Quoted Domain Specific Language (QDSL) to express database queries in Scala and execute them in target languages such as SQL and Cassandra Query Language (CQL). It focuses on reducing boilerplate and shifting query generation and validation to compile time to minimize runtime overhead.
  7. Overview of BindingResolver and Registry

    The BindingResolver is a read-only interface used to look up bindings by type identity during schema rebinding. It is primarily used by DynamicSchema#rebind to traverse a reflect tree and associate nodes with concrete bindings to produce a functional Schema[A]. A Registry is the underlying structure used to store and manage these bindings.
  8. Overview of the Into type class

    Into[-A, +B] is a one-way conversion type class used to transform values of type A into type B. It is designed for type-safe, validated conversions, such as schema evolution, domain boundary mapping (DTO to domain model), type refinement, and collection reshaping. The conversion returns Either[SchemaError, B], where Right indicates success and Left contains accumulated validation failures.
    trait Into[-A, +B] {
      def into(a: A): Either[SchemaError, B]
    }
  9. Overview of ZIO XYZ Frag

    Frag is an immutable SQL fragment consisting of SQL text and typed parameter values. It prevents SQL injection by keeping parameter values separate from the literal SQL string, binding them to ? placeholders only at execution time. Fragments are primarily created using the sql"..." string interpolator and can be composed using the ++ operator.
  10. Overview of ZIO XYZ Stream

    Stream[+E, +A] is a lazy, pull-based, typed-error stream of elements. It is purely functional, referentially transparent, and resource-safe.

    Key characteristics:

    • Lazy: It describes a pipeline; no computation occurs until a terminal operation is called.
    • Synchronous: Terminal operations return Either[E, Z] directly.
    • Pull-based: The sink (consumer) drives execution backward through the pipeline, enabling automatic short-circuiting.
    • Typed Errors: Distinguishes recoverable domain errors (E) from untyped defects (Throwable).
    • Resource-safe: Uses RAII semantics to ensure resources are released regardless of success, error, or cancellation.
    abstract class Stream[+E, +A] {
      def run[E2 >: E, Z](sink: Sink[E2, A, Z]): Either[E2, Z]
      def runCollect: Either[E, Chunk[A]]
    }
  11. Overview of zio-blocks-smithy

    zio-blocks-smithy is a Smithy IDL parser and AST library that provides a complete representation of Smithy 2.0 API models. It allows developers to parse Smithy IDL text into rich data structures, query shape definitions, and pretty-print models back to valid IDL syntax without external dependencies.
  12. Overview of ZIO Blocks Schema Migration

    Migration[A, B] is a typed API in ZIO Blocks Schema used to evolve data from one schema version to another. It provides a builder-based workflow to handle structural changes (adding, dropping, or renaming fields) and type transformations.

    The system consists of three layers:

    1. Migration[A, B]: The typed user-facing entry point for migrations between source type A and target type B.
    2. DynamicMigration: A pure runtime, serializable representation consisting of a sequence of MigrationActions. This is used for transport, inspection, or dynamic application.
    3. MigrationBuilder[A, B, Changeset]: A macro-validated builder that accumulates actions and ensures the target shape is fully handled before calling build.