Importers
An importer reads one external source and writes what it finds into the architecture model. Importers are the extension point of the arch repo service: the library ships several, and an instance can add its own.
The extension point
public interface ArchRepoImporter {
default int getOrder() {
return Integer.MAX_VALUE - 100;
}
void importIntoModel(ArchitectureModel architectureModel, String environment);
}
UpdateService injects every ArchRepoImporter bean, sorts them by getOrder() ascending, and calls each one
with the same in-memory model. Nothing is written to the database in between - the caller saves the model once,
after the last importer has run.
environment is archrepo-config.environment lowercased, and is passed so that importers reading
environment-specific data (metrics, deployment versions) query the right stage.
Ordering
The default order is Integer.MAX_VALUE - 100, so an importer that does not care runs late. Importers that
create system components pin an explicit low value, because when two sources describe the same component the
one that runs last decides what it looks like:
| Order | Importer | Why |
|---|---|---|
Integer.MIN_VALUE | DeploymentlogSystemComponentImporter | Runs first: a component that was deployed |
Integer.MIN_VALUE + 50 | AWSSystemComponentImporter, RhosSystemComponentImporter | Runs after the deployment log and takes precedence, because metrics are a live signal from a running component while a deployment only says something was rolled out |
Integer.MIN_VALUE + 100 | AWSJeapRelationImporter, RhosJeapRelationImporter | Relations, once the components they connect exist |
| default | message type, Pact broker | Independent of component creation |
Conditional registration
There is no hard-coded importer list. Each jeap-archrepo-importer-* module carries an @AutoConfiguration
that registers its beans only when its configuration is present, so an instance activates an importer by
configuring it and nothing else:
| Importer module | Active when | Imports |
|---|---|---|
deploymentlog | deploymentlog.url is set | Systems and components from the jEAP deployment log, with their deployed versions |
prometheus-aws | prometheus-aws.host is set | Components and their jEAP relations from an AWS-managed Prometheus workspace |
prometheus-rhos | prometheus-rhos.hosts is a non-empty list | The same from Prometheus instances on RHOS |
messagetype | messages.message-contract-service-uri is set | Events, commands, their versions and their contracts, from the message type registries and the message contract service |
pactbroker | pactbroker.url is set | REST API relations, and the Pact contract that proves them |
openapi | always | Not an ArchRepoImporter: it parses specs pushed in over the REST API - see below |
See Configuration for the full properties of each.
Components go into systems that already exist
No importer creates a System. Each resolves a system name, looks it up as a name or alias, and skips the
element with an ERROR log when there is no match - a system that is deployed or publishes messages but is not
declared in archrepo.model is a configuration gap, and the error lets alerting pick it up. A system is created deliberately, through
archrepo.model configuration, applied before every full or single-importer run - see Configuration.
This is enforced: after onboarding the model is sealed, and an importer that adds or removes a system or a team
fails the whole update with an IllegalStateException.
A component found under a different system than the one an importer reports it for moves only to the system its name belongs to - its prefix, resolved as a name or alias, which is what changes when an alias moves. RHOS resolves the system from the namespace instead, so it can report a component for a system its name does not belong to, or for two systems; the component then stays where it is and the conflicting report is logged as an ERROR.
| Importer | Gets the system name from |
|---|---|
deploymentlog, prometheus-aws | The component name up to the first - |
prometheus-rhos | The namespace, matched against something-system-stage |
pactbroker | The middle segment of a department-system-component consumer or provider name |
Provenance and removal
Every element an importer creates carries an Importer enum value naming its source - GRAFANA,
DEPLOYMENT_LOG, MESSAGE_TYPE_REGISTRY, PACT_BROKER, OPEN_API or REST_CONTROLLER. That is what lets an
importer delete what has disappeared from its source without touching what another source contributed.
Relations and REST APIs record a set of importers rather than one, so an element several sources found only
disappears when the last of them stops reporting it.
Two removal styles coexist:
- Full replace. The message type importer and the Pact broker importer call
removeAllByImporter()for their own source at the start of the run and re-import everything. - Diff. The deployment log importer removes its own components that have vanished from the deployment log
entirely; one it still reports, but as undeployed from this environment, is kept and marked
undeployedinstead of being removed, so it is only tombstoned, not deleted. The metrics importers remove their own components whoselastSeenis more than 14 days old (isObsolete()).
ArchitectureModel.cleanup(), which UpdateService calls after the last importer, is a third thing again and
concerns only REST elements: it removes imported RestApiRelations not seen for three months and RestApi
entries no relation references any more. It does not touch components.
Operations collects all of this in one table.
Pushed sources
Not everything is polled. Components push two kinds of artifact into the model themselves:
| Artifact | Endpoint | Stored as |
|---|---|---|
| OpenAPI spec | POST /api/openapi/{systemComponentName} | OpenApiSpec, one per component, updated in place. OpenApiImporter parses it and derives the component's RestApi entries |
| Database schema | POST /api/dbschemas | SystemComponentDatabaseSchema, one per component, updated in place |
Both are plain Spring components rather than ArchRepoImporter plugins, because they run inside the request. See
API.
Writing an importer
- Implement
ArchRepoImporterin the instance or in a new module. - Register it conditionally, so the instance opts in by configuration.
- Set the
Importerprovenance on everything created, and refreshlastSeenon everything still seen, so that removal keeps working. - Give it an explicit
getOrder()only if it creates elements another importer also creates.
Related
- Concepts - the naming conventions the importers rely on
- Architecture - the model the importers write into
- Data model - the entities an importer fills
- Configuration - the properties that activate each importer
- Operations - what a run does, and what happens when one fails
- API - the pushed sources, and how to trigger an import manually