Behaviour for SPARQL triple store adapters.
Adapters implement endpoint discovery, SPARQL operation dispatch, and lifecycle management (setup/teardown/availability checks).
use Options
The use Gno.Store.Adapter macro provides default implementations and
supports endpoint URL construction via these options:
:query_endpoint_path- path appended to the base URL for SPARQL queries (e.g."query"):update_endpoint_path- path for SPARQL updates (e.g."update"):graph_store_endpoint_path- path for Graph Store Protocol operations (e.g."data"):dataset_endpoint_segment_template- a URI template for constructing the dataset-specific URL segment (e.g."/{dataset}")
Summary
Callbacks
Check store availability.
Check if store is set up (dataset exists and is functional).
Returns the store-specific IRI of the default graph.
Returns the default graph semantics of this store adapter type.
Store-specific preparation before repository initialization. E.g., creating datasets, setting permissions, etc.
Store-specific cleanup on setup failure.
Functions
Returns the Gno.Store.Adapter module for the given string.
Checks if the given module is a Gno.Store.Adapter module.
Returns the store adapter name for the given store adapter module.
Types
@type endpoint_url() :: String.t() | nil
@type graph_name() :: RDF.IRI.t() | nil
@type result() :: SPARQL.Query.Result.t() | RDF.Data.Source.t() | nil
@type t() :: %{ :__struct__ => type(), :__id__ => term(), :query_endpoint => RDF.IRI.t() | nil, :update_endpoint => RDF.IRI.t() | nil, :graph_store_endpoint => RDF.IRI.t() | nil, :scheme => String.t() | nil, :host => String.t() | nil, :port => integer() | nil, :userinfo => String.t() | nil, optional(atom()) => term() }
@type type() :: module()
Callbacks
@callback check_availability( t(), keyword() ) :: :ok | {:error, Gno.Store.UnavailableError.t()}
Check store availability.
@callback check_setup( t(), keyword() ) :: :ok | {:error, Gno.Store.UnavailableError.t()}
Check if store is set up (dataset exists and is functional).
@callback default_graph_iri() :: RDF.IRI.t() | nil
Returns the store-specific IRI of the default graph.
Used to restrict queries to the real default graph on stores with :union
semantics via the default-graph-uri SPARQL protocol parameter.
Returns nil for stores with :isolated semantics.
@callback default_graph_semantics() :: :isolated | :union
Returns the default graph semantics of this store adapter type.
:isolated— the default graph contains only explicitly inserted triples:union— the default graph is the union of all graphs
@callback determine_graph_store_endpoint(t()) :: {:ok, endpoint_url()} | {:error, any()}
@callback determine_query_endpoint(t()) :: {:ok, endpoint_url()} | {:error, any()}
@callback determine_update_endpoint(t()) :: {:ok, endpoint_url()} | {:error, any()}
@callback handle_sparql(Gno.Store.SPARQL.Operation.t(), t(), graph_name(), keyword()) :: {:ok, result()} | :ok | {:error, any()}
Store-specific preparation before repository initialization. E.g., creating datasets, setting permissions, etc.
Store-specific cleanup on setup failure.
Functions
Returns the Gno.Store.Adapter module for the given string.
Example
iex> Gno.Store.Adapter.type("Oxigraph")
Gno.Store.Adapters.Oxigraph
iex> Gno.Store.Adapter.type("Commit")
nil
iex> Gno.Store.Adapter.type("NonExisting")
nil
Checks if the given module is a Gno.Store.Adapter module.
Returns the store adapter name for the given store adapter module.
Example
iex> Gno.Store.Adapter.type_name(Gno.Store.Adapters.Fuseki)
"Fuseki"
iex> Gno.Store.Adapter.type_name(Gno.Store.Adapters.Oxigraph)
"Oxigraph"
iex> Gno.Store.Adapter.type_name(Gno.Repository)
** (RuntimeError) Invalid Gno.Store.Adapter type: Gno.Repository
iex> Gno.Store.Adapter.type_name(NonExisting)
** (RuntimeError) Invalid Gno.Store.Adapter type: NonExisting