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

ShardStorage.ts overview

Since v1.0.0


Exports Grouped by Category


Encoded

Encoded (interface)

Signature

export interface Encoded {
  /**
   * Get the current assignments of shards to runners.
   */
  readonly getAssignments: Effect.Effect<
    Array<readonly [shardId: number, runnerAddress: string | null]>,
    PersistenceError
  >

  /**
   * Save the current state of shards assignments to runners.
   */
  readonly saveAssignments: (
    assignments: Array<readonly [shardId: number, RunnerAddress: string | null]>
  ) => Effect.Effect<void, PersistenceError>

  /**
   * Get all runners registered with the cluster.
   */
  readonly getRunners: Effect.Effect<Array<readonly [address: string, runner: string]>, PersistenceError>

  /**
   * Save the current runners registered with the cluster.
   */
  readonly saveRunners: (
    runners: Array<readonly [address: string, runner: string]>
  ) => Effect.Effect<void, PersistenceError>

  /**
   * Acquire the lock on the given shards, returning the shards that were
   * successfully locked.
   */
  readonly acquire: (address: string, shardIds: ReadonlyArray<number>) => Effect.Effect<Array<number>, PersistenceError>

  /**
   * Refresh the lock on the given shards, returning the shards that were
   * successfully locked.
   */
  readonly refresh: (address: string, shardIds: ReadonlyArray<number>) => Effect.Effect<Array<number>, PersistenceError>

  /**
   * Release the lock on the given shards.
   */
  readonly release: (address: string, shardIds: number) => Effect.Effect<void, PersistenceError>

  /**
   * Release the lock on all shards for the given runner.
   */
  readonly releaseAll: (address: string) => Effect.Effect<void, PersistenceError>
}

Source

Since v1.0.0

constructors

makeMemory

Signature

declare const makeMemory: Effect.Effect<
  {
    readonly getAssignments: Effect.Effect<ReadonlyMap<ShardId, Option.Option<RunnerAddress>>, PersistenceError>
    readonly saveAssignments: (
      assignments: Iterable<readonly [ShardId, Option.Option<RunnerAddress>]>
    ) => Effect.Effect<void, PersistenceError>
    readonly getRunners: Effect.Effect<Array<[RunnerAddress, Runner]>, PersistenceError>
    readonly saveRunners: (runners: Iterable<readonly [RunnerAddress, Runner]>) => Effect.Effect<void, PersistenceError>
    readonly acquire: (
      address: RunnerAddress,
      shardIds: Iterable<ShardId>
    ) => Effect.Effect<Array<ShardId>, PersistenceError>
    readonly refresh: (
      address: RunnerAddress,
      shardIds: Iterable<ShardId>
    ) => Effect.Effect<Array<ShardId>, PersistenceError>
    readonly release: (address: RunnerAddress, shardId: ShardId) => Effect.Effect<void, PersistenceError>
    readonly releaseAll: (address: RunnerAddress) => Effect.Effect<void, PersistenceError>
  },
  never,
  never
>

Source

Since v1.0.0

layers

layerMemory

Signature

declare const layerMemory: Layer.Layer<ShardStorage, never, never>

Source

Since v1.0.0

layerNoop

Signature

declare const layerNoop: Layer.Layer<ShardStorage, never, never>

Source

Since v1.0.0

makeEncoded

Signature

declare const makeEncoded: (
  encoded: Encoded
) => Effect.Effect<
  {
    readonly getAssignments: Effect.Effect<ReadonlyMap<ShardId, Option.Option<RunnerAddress>>, PersistenceError>
    readonly saveAssignments: (
      assignments: Iterable<readonly [ShardId, Option.Option<RunnerAddress>]>
    ) => Effect.Effect<void, PersistenceError>
    readonly getRunners: Effect.Effect<Array<[RunnerAddress, Runner]>, PersistenceError>
    readonly saveRunners: (runners: Iterable<readonly [RunnerAddress, Runner]>) => Effect.Effect<void, PersistenceError>
    readonly acquire: (
      address: RunnerAddress,
      shardIds: Iterable<ShardId>
    ) => Effect.Effect<Array<ShardId>, PersistenceError>
    readonly refresh: (
      address: RunnerAddress,
      shardIds: Iterable<ShardId>
    ) => Effect.Effect<Array<ShardId>, PersistenceError>
    readonly release: (address: RunnerAddress, shardId: ShardId) => Effect.Effect<void, PersistenceError>
    readonly releaseAll: (address: RunnerAddress) => Effect.Effect<void, PersistenceError>
  },
  never,
  never
>

Source

Since v1.0.0

models

ShardStorage (class)

Represents a generic interface to the persistent storage required by the cluster.

Signature

declare class ShardStorage

Source

Since v1.0.0