dream_ets/config

Types

pub type Access {
  Public
  Protected
  Private
}

Constructors

  • Public
  • Protected
  • Private
pub opaque type TableConfig(key, value)
pub type TableType {
  Set
  OrderedSet
  Bag
  DuplicateBag
}

Constructors

  • Set
  • OrderedSet
  • Bag
  • DuplicateBag

Values

pub fn access(
  config: TableConfig(k, v),
  access_mode: Access,
) -> TableConfig(k, v)

Set the access mode

pub fn access_private() -> Access
pub fn access_protected() -> Access
pub fn access_public() -> Access

Helper functions to create Access values

pub fn compressed(
  config: TableConfig(k, v),
  enabled: Bool,
) -> TableConfig(k, v)

Enable or disable table compression

pub fn counter(
  config: TableConfig(String, Int),
) -> TableConfig(String, Int)

Convenience: Configure as counter table (String keys, Int values)

pub fn create(
  config: TableConfig(k, v),
) -> Result(table.Table(k, v), table.EtsError)

Create the table from configuration

Validates configuration and creates the ETS table. Returns an error if the table name already exists or configuration is invalid.

pub fn key(
  config: TableConfig(k, v),
  encoder: fn(k) -> dynamic.Dynamic,
  decoder: decode.Decoder(k),
) -> TableConfig(k, v)

Set key encoder and decoder

pub fn key_string(
  config: TableConfig(String, v),
) -> TableConfig(String, v)

Convenience: Set string key encoding

pub fn keypos(
  config: TableConfig(k, v),
  pos: Int,
) -> TableConfig(k, v)

Set the key position in tuples (default: 1)

pub fn new(name: String) -> TableConfig(k, v)

Create a new table configuration with sensible defaults

Defaults:

  • Table type: Set
  • Access: Public
  • Key position: 1
  • Read concurrency: True
  • Write concurrency: False
  • Compressed: False
  • Named table: True

Example

import dream_ets as ets

let config = ets.new("my_table")
pub fn read_concurrency(
  config: TableConfig(k, v),
  enabled: Bool,
) -> TableConfig(k, v)

Enable or disable read concurrency

pub fn table_type(
  config: TableConfig(k, v),
  type_: TableType,
) -> TableConfig(k, v)

Set the table type

pub fn table_type_bag() -> TableType
pub fn table_type_duplicate_bag() -> TableType
pub fn table_type_ordered_set() -> TableType
pub fn table_type_set() -> TableType

Helper functions to create TableType values

pub fn value(
  config: TableConfig(k, v),
  encoder: fn(v) -> dynamic.Dynamic,
  decoder: decode.Decoder(v),
) -> TableConfig(k, v)

Set value encoder and decoder

pub fn value_string(
  config: TableConfig(k, String),
) -> TableConfig(k, String)

Convenience: Set string value encoding

pub fn write_concurrency(
  config: TableConfig(k, v),
  enabled: Bool,
) -> TableConfig(k, v)

Enable or disable write concurrency

Search Document