Skip to main content

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:

OrderImporterWhy
Integer.MIN_VALUEDeploymentlogSystemComponentImporterRuns first: a component that was deployed
Integer.MIN_VALUE + 50AWSSystemComponentImporter, RhosSystemComponentImporterRuns 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 + 100AWSJeapRelationImporter, RhosJeapRelationImporterRelations, once the components they connect exist
defaultmessage type, Pact brokerIndependent 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 moduleActive whenImports
deploymentlogdeploymentlog.url is setSystems and components from the jEAP deployment log, with their deployed versions
prometheus-awsprometheus-aws.host is setComponents and their jEAP relations from an AWS-managed Prometheus workspace
prometheus-rhosprometheus-rhos.hosts is a non-empty listThe same from Prometheus instances on RHOS
messagetypemessages.message-contract-service-uri is setEvents, commands, their versions and their contracts, from the message type registries and the message contract service
pactbrokerpactbroker.url is setREST API relations, and the Pact contract that proves them
openapialwaysNot 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.

ImporterGets the system name from
deploymentlog, prometheus-awsThe component name up to the first -
prometheus-rhosThe namespace, matched against something-system-stage
pactbrokerThe 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 undeployed instead of being removed, so it is only tombstoned, not deleted. The metrics importers remove their own components whose lastSeen is 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:

ArtifactEndpointStored as
OpenAPI specPOST /api/openapi/{systemComponentName}OpenApiSpec, one per component, updated in place. OpenApiImporter parses it and derives the component's RestApi entries
Database schemaPOST /api/dbschemasSystemComponentDatabaseSchema, 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​

  1. Implement ArchRepoImporter in the instance or in a new module.
  2. Register it conditionally, so the instance opts in by configuration.
  3. Set the Importer provenance on everything created, and refresh lastSeen on everything still seen, so that removal keeps working.
  4. Give it an explicit getOrder() only if it creates elements another importer also creates.
  • 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