Skip to main content Link Search Menu Expand Document (external link)

Serialization overview

Added in v1.0.0


Table of contents


constructors

make

Signature

export declare const make: (args: Omit<Serialization, typeof SerializationTypeId>) => Serialization

Added in v1.0.0

context

Serialization

Signature

export declare const Serialization: Context.Tag<Serialization, Serialization>

Added in v1.0.0

layers

json

A layer that uses JSON serialization for encoding and decoding messages. This is useful for testing and not recommended to use in production.

Signature

export declare const json: Layer.Layer<Serialization>

Added in v1.0.0

models

Serialization (interface)

An interface to serialize user messages that will be sent between pods.

Signature

export interface Serialization {
  /**
   * @since 1.0.0
   */
  readonly [SerializationTypeId]: SerializationTypeId

  /**
   * Transforms the given message into binary
   * @since 1.0.0
   */
  readonly encode: <A, I>(
    schema: Schema.Schema<A, I>,
    message: A
  ) => Effect.Effect<SerializedMessage.SerializedMessage, ShardingException.SerializationException>

  /**
   * Transform binary back into the given type
   * @since 1.0.0
   */
  readonly decode: <A, I>(
    schema: Schema.Schema<A, I>,
    bytes: SerializedMessage.SerializedMessage
  ) => Effect.Effect<A, ShardingException.SerializationException>
}

Added in v1.0.0

symbols

SerializationTypeId

Signature

export declare const SerializationTypeId: typeof SerializationTypeId

Added in v1.0.0

SerializationTypeId (type alias)

Signature

export type SerializationTypeId = typeof SerializationTypeId

Added in v1.0.0