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

Storage overview

Added in v1.0.0


Table of contents


constructors

make

Signature

export declare const make: (args: Omit<Storage, typeof StorageTypeId>) => Storage

Added in v1.0.0

context

Storage

Signature

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

Added in v1.0.0

layers

memory

A layer that stores data in-memory. This is useful for testing with a single pod only.

Signature

export declare const memory: Layer.Layer<Storage>

Added in v1.0.0

noop

A layer that does nothing, useful for testing.

Signature

export declare const noop: Layer.Layer<Storage>

Added in v1.0.0

models

Storage (interface)

The storage Service is responsible of persisting assignments and registered pods. The storage is expected to be shared among all pods, so it works also as communication of assignments between Pods.

Signature

export interface Storage {
  readonly [StorageTypeId]: StorageTypeId

  /**
   * Get the current state of shard assignments to pods
   */
  readonly getAssignments: Effect.Effect<HashMap.HashMap<ShardId.ShardId, Option.Option<PodAddress.PodAddress>>>

  /**
   * Save the current state of shard assignments to pods
   */
  readonly saveAssignments: (
    assignments: HashMap.HashMap<ShardId.ShardId, Option.Option<PodAddress.PodAddress>>
  ) => Effect.Effect<void>

  /**
   * A stream that will emit the state of shard assignments whenever it changes
   */
  readonly assignmentsStream: Stream.Stream<HashMap.HashMap<ShardId.ShardId, Option.Option<PodAddress.PodAddress>>>

  /**
   * Get the list of existing pods
   */
  readonly getPods: Effect.Effect<HashMap.HashMap<PodAddress.PodAddress, Pod.Pod>>

  /**
   * Save the list of existing pods
   */
  readonly savePods: (pods: HashMap.HashMap<PodAddress.PodAddress, Pod.Pod>) => Effect.Effect<void>
}

Added in v1.0.0

symbols

StorageTypeId

Signature

export declare const StorageTypeId: typeof StorageTypeId

Added in v1.0.0

StorageTypeId (type alias)

Signature

export type StorageTypeId = typeof StorageTypeId

Added in v1.0.0