Gno.Service.Setup (Gno v0.1.0)

Copy Markdown View Source

Setup and teardown of Gno repositories in the SPARQL store of a Gno.Service.

The setup pipeline checks store availability, prepares the store adapter, initializes repository metadata, and validates the result.

Application-specific setup logic can be added via Gno.Service.Setup.Extension.

For command-line usage, see mix gno.setup and mix gno.teardown.

Summary

Functions

Checks if the repository is already set up.

Sets up a new repository for the given service.

Tears down the repository for the given service.

Validates the setup state including basic integrity and extension validations.

Types

options()

@type options() :: [
  store_options: keyword(),
  repository_data: nil,
  extension: atom() | nil,
  extension_opts: keyword(),
  store_repository_metadata: boolean()
]

Functions

check(service, opts \\ [])

@spec check(
  Gno.Service.t(),
  keyword()
) :: :ok | {:error, term()}

Checks if the repository is already set up.

setup(service, opts \\ [])

@spec setup(Gno.Service.t(), options()) :: {:ok, Gno.Service.t()} | {:error, term()}

Sets up a new repository for the given service.

Options

  • :store_options (keyword/0) - Options passed to the store adapter's setup functions The default value is [].

  • :repository_data (RDF.Graph.input/0) - Additional RDF data to merge into the repository before storing The default value is [].

  • :extension - Extension module for application-specific setup logic The default value is nil.

  • :extension_opts (keyword/0) - Options passed to the extension module callbacks The default value is [].

  • :store_repository_metadata (boolean/0) - If false, skips storing repository metadata in the triple store The default value is true.

Examples

# Simple setup with defaults
{:ok, service} = Gno.Service.Setup.setup(service)

# Setup without storing repository metadata
{:ok, service} = Gno.Service.Setup.setup(service, store_repository_metadata: false)

# Setup with extension
{:ok, service} = Gno.Service.Setup.setup(service,
  extension: MyApp.Setup,
  extension_opts: [history: true, roles: [:admin, :user]]
)

teardown(service, opts \\ [])

@spec teardown(Gno.Service.t(), options()) :: :ok | {:error, [term()]}

Tears down the repository for the given service.

DESTRUCTIVE OPERATION

⚠️ This will permanently delete repository data. ⚠️

Only use in development/testing environments.

Options

  • :store_options (keyword/0) - Options passed to the store adapter's setup functions The default value is [].

  • :repository_data (RDF.Graph.input/0) - Additional RDF data to merge into the repository before storing The default value is [].

  • :extension - Extension module for application-specific setup logic The default value is nil.

  • :extension_opts (keyword/0) - Options passed to the extension module callbacks The default value is [].

  • :store_repository_metadata (boolean/0) - If false, skips storing repository metadata in the triple store The default value is true.

Examples

# Simple teardown with defaults
:ok = Gno.Service.Setup.teardown(service)

# Teardown with extension
:ok = Gno.Service.Setup.teardown(service,
  extension: MyApp.Setup,
  extension_opts: [history: true, roles: [:admin, :user]]
)

validate(service, opts \\ [])

@spec validate(
  Gno.Service.t(),
  keyword()
) :: :ok | {:error, term()}

Validates the setup state including basic integrity and extension validations.