I am a Registry for objects that are referenced from GT.
This allows GT to keep references to Elixir objects via IDs, and handles cleanup when GT's proxy objects are garbage collected.
Summary
Functions
Returns a specification to start this module under a supervisor.
Get an object by ID.
Get the value of a specific attribute from an object by ID.
List all attributes (field names) of an object by ID. For structs, returns the field names. For maps, returns the keys.
Register an object and return its ID.
Remove an object by ID (called when GT garbage collects the proxy).
I batch-remove multiple objects by ID.
Called by GtBridge.Eval.terminate/2 to clean up all objects
registered during a session's lifetime.
Resolve an object by ID, returning the object directly (or nil if not found). This is the function GT should call when retrieving lazy objects.
Start the object registry.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get(GenServer.server(), non_neg_integer()) :: {:ok, any()} | :error
Get an object by ID.
@spec get_attribute(non_neg_integer(), atom() | String.t()) :: any() | nil
Get the value of a specific attribute from an object by ID.
@spec list_attributes(non_neg_integer()) :: [atom() | String.t()] | nil
List all attributes (field names) of an object by ID. For structs, returns the field names. For maps, returns the keys.
@spec register(GenServer.server(), any()) :: non_neg_integer() | nil
Register an object and return its ID.
@spec remove(GenServer.server(), non_neg_integer()) :: :ok
Remove an object by ID (called when GT garbage collects the proxy).
@spec remove_all(GenServer.server(), [non_neg_integer()]) :: :ok
I batch-remove multiple objects by ID.
Called by GtBridge.Eval.terminate/2 to clean up all objects
registered during a session's lifetime.
@spec resolve(non_neg_integer()) :: any() | nil
Resolve an object by ID, returning the object directly (or nil if not found). This is the function GT should call when retrieving lazy objects.
Start the object registry.