DCATR.ServiceData.Type behaviour (DCAT-R.ex v0.1.0)

Copy Markdown View Source

Behaviour for defining custom service data catalogs with additional local graphs.

DCATR.ServiceData manages service-local graphs that are not part of the distributed repository (e.g., configuration, working graphs, service-specific metadata). This behaviour enables applications to create specialized service data catalogs with custom local graphs.

Graph Structure

ServiceData contains:

  • manifest - Service configuration (ServiceManifestGraph)
  • working_graphs - Temporary/experimental graphs local to the service
  • system_graphs - Service-level metadata and operational graphs

Callbacks

Inherits from DCATR.Directory.Type:

Inherits from DCATR.GraphResolver:

Standard Selectors

  • :service_manifest - Service configuration graph

Usage

Custom service data types should use DCATR.ServiceData.Type and define a Grax schema extending DCATR.ServiceData:

defmodule MyApp.ServiceData do
  use DCATR.ServiceData.Type

  schema MyApp.NS.ServiceData < DCATR.ServiceData do
    link cache_graph: MyApp.NS.cache(), type: MyApp.CacheGraph
    link log_graph: MyApp.NS.log(), type: MyApp.LogGraph
  end

  @impl true
  def resolve_graph_selector(data, :cache), do: data.cache_graph
  def resolve_graph_selector(data, :log), do: data.log_graph
  def resolve_graph_selector(data, selector), do: super(data, selector)

  @impl true
  def system_graphs(data) do
    [data.cache_graph, data.log_graph | super(data)]
  end
end

The module automatically provides delegating implementations of all callbacks and convenience functions, all of which are overridable.

Summary

Callbacks

Returns all service-local system graphs.

Returns all working graphs in the service data.

Types

schema()

@type schema() :: Grax.Schema.t()

t()

@type t() :: module()

Callbacks

system_graphs(service_data)

@callback system_graphs(service_data :: schema()) :: [DCATR.SystemGraph.t()]

Returns all service-local system graphs.

System graphs at the service level contain service-specific metadata, configuration, or operational data.

Override to include additional service-local system graphs.

working_graphs(service_data)

@callback working_graphs(service_data :: schema()) :: [DCATR.WorkingGraph.t()]

Returns all working graphs in the service data.

Working graphs are temporary or experimental graphs local to the service, not intended for distribution with the repository.

Override to include additional working graphs specific to your service data type.

Functions

graphs(service_data)

@spec graphs(schema()) :: [DCATR.Graph.t()]

Default implementation of DCATR.Directory.Type.graphs/1 for service data.

Returns all graph members: manifest, working graphs, and system graphs.

resolve_graph_selector(service_data, selector)

@spec resolve_graph_selector(schema(), DCATR.GraphResolver.selector()) ::
  DCATR.Graph.t() | nil | :undefined

Default implementation of DCATR.GraphResolver.resolve_graph_selector/2.

Resolves service-data-specific selectors.

Supported selectors:

  • :service_manifest - Service manifest graph

system_graphs(struct)

@spec system_graphs(schema()) :: [DCATR.SystemGraph.t()]

Default implementation of system_graphs/1.

Returns the system_graphs field.

working_graphs(struct)

@spec working_graphs(schema()) :: [DCATR.WorkingGraph.t()]

Default implementation of working_graphs/1.

Returns the working_graphs field.