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
system_graphs/1- Returns service-level system graphsworking_graphs/1- Returns service-local working graphs
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
endThe module automatically provides delegating implementations of all callbacks and convenience functions, all of which are overridable.
Summary
Functions
Default implementation of DCATR.Directory.Type.graphs/1 for service data.
Default implementation of DCATR.GraphResolver.resolve_graph_selector/2.
Default implementation of system_graphs/1.
Default implementation of working_graphs/1.
Types
@type schema() :: Grax.Schema.t()
@type t() :: module()
Callbacks
@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.
@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
@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.
@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
@spec system_graphs(schema()) :: [DCATR.SystemGraph.t()]
Default implementation of system_graphs/1.
Returns the system_graphs field.
@spec working_graphs(schema()) :: [DCATR.WorkingGraph.t()]
Default implementation of working_graphs/1.
Returns the working_graphs field.