Astro.Kernel (ex_astro v0.3.0)

View Source

Runtime SPICE kernel management.

:spice_kernels is read from application env when the application starts. Missing configured files log a warning and skip; load them later with load/1 once the files exist. This module is also the path for kernels downloaded after boot.

The native library owns one process-wide CSPICE kernel pool. Kernel mutations and all other CSPICE calls are serialized by the native mutex. A failed load/1 restores the prior pool before returning an error.

loaded/0 returns directly loaded paths as absolute paths. Paths pulled in by meta-kernels are returned exactly as CSPICE stored them and may be relative.

Summary

Functions

Unload every kernel from the CSPICE kernel pool.

Load a SPICE kernel into the CSPICE kernel pool.

Return the kernels currently loaded in the CSPICE kernel pool.

Unload a SPICE kernel from the CSPICE kernel pool.

Functions

clear()

@spec clear() :: :ok | {:error, String.t()}

Unload every kernel from the CSPICE kernel pool.

load(path)

@spec load(Path.t()) :: :ok | {:error, String.t()}

Load a SPICE kernel into the CSPICE kernel pool.

The path is expanded so later unload/1 and loaded/0 match what was furnished. Paths longer than 255 bytes are rejected, as is a missing file.

Loading the same directly furnished path again is idempotent. A path loaded only as a meta-kernel child is still furnished directly by this function. A failed load restores the pool to its prior state before returning.

loaded()

@spec loaded() :: [String.t()]

Return the kernels currently loaded in the CSPICE kernel pool.

Directly loaded paths are expanded absolute paths. Meta-kernel children are returned exactly as CSPICE stored them and may be relative.

unload(path)

@spec unload(Path.t()) :: :ok | {:error, String.t()}

Unload a SPICE kernel from the CSPICE kernel pool.

The path is expanded to match a direct load/1 call. Missing files are not rejected, so a deleted kernel can still be removed from the pool. Paths longer than 255 bytes are rejected.

Transitive children named by a meta-kernel cannot be unloaded through their returned path; unload the top-level meta-kernel instead. CSPICE treats an absent path as a successful no-op.