Gno.CommitOperation (Gno v0.1.0)

Copy Markdown View Source

Configuration of a commit operation for a Gno.Service.

Defines the Gno.CommitMiddleware pipeline and handles different input changeset types. Implements Gno.CommitOperation.Type to provide the standard commit workflow executed by Gno.Commit.Processor:

  • Initializes changesets from various input formats
  • Computes effective changesets by querying current state
  • Builds and executes SPARQL updates
  • Handles empty changesets (configurable via on_no_effective_changes)
  • Performs rollback on failure

Properties

  • middlewares - ordered list of Gno.CommitMiddleware instances invoked at each state transition
  • on_no_effective_changes - what to do when the computed Gno.EffectiveChangeset contains no changes:
    • "error" (default) — return an error
    • "skip" — skip the transaction phase, proceed to post-commit
    • "proceed" — continue with an empty changeset through all phases

Summary

Functions

Builds a commit operation with the given ID and attributes.

Creates a new commit operation with an auto-generated blank node ID.

Returns the commit operation type module for the given IRI, or nil if not a commit operation type.

Checks if the given module is a Gno.CommitOperation.Type.

Types

t()

@type t() :: %Gno.CommitOperation{
  __additional_statements__: term(),
  __id__: term(),
  middlewares: term(),
  on_no_effective_changes: term()
}

Functions

build(id)

build(id, initial)

Builds a commit operation with the given ID and attributes.

build!(id)

build!(id, initial)

build_id(attributes)

from(value)

@spec from(Grax.Schema.t()) :: {:ok, t()} | {:error, any()}

from!(value)

@spec from!(Grax.Schema.t()) :: t()

load(graph, id, opts \\ [])

@spec load(
  RDF.Graph.t() | RDF.Description.t(),
  RDF.IRI.coercible() | RDF.BlankNode.t(),
  opts :: keyword()
) :: {:ok, t()} | {:error, any()}

load!(graph, id, opts \\ [])

@spec load!(
  RDF.Graph.t() | RDF.Description.t(),
  RDF.IRI.coercible() | RDF.BlankNode.t(),
  opts :: keyword()
) :: t()

new(attrs \\ [])

Creates a new commit operation with an auto-generated blank node ID.

new!(attrs \\ [])

type(iri)

Returns the commit operation type module for the given IRI, or nil if not a commit operation type.

type?(module)

@spec type?(module()) :: boolean()

Checks if the given module is a Gno.CommitOperation.Type.

Example

iex> Gno.CommitOperation.type?(Gno.CommitOperation)
true

iex> Gno.CommitOperation.type?(Gno.Commit)
false

iex> Gno.CommitOperation.type?(Gno.CommitLogger)
false

iex> Gno.CommitOperation.type?(NonExisting)
false