Chapter 2. Service Registry content rules
This chapter introduces the optional rules used to govern Service Registry content and provides details on the available rule configuration:
2.1. Govern Service Registry content using rules
To govern the evolution of artifact content added to Service Registry, you can configure optional rules. All configured global rules or artifact-specific rules must pass before a new artifact version can be uploaded to Service Registry. Configured artifact-specific rules override any configured global rules.
The goal of these rules is to prevent invalid content from being added to Service Registry. For example, content can be invalid for the following reasons:
-
Invalid syntax for a given artifact type, for example,
AVRO
orPROTOBUF
. - Valid syntax, but semantics violate a specification.
- Incompatibility, when new content includes breaking changes relative to the current artifact version.
- Artifact reference integrity, for example, a duplicate or non-existent artifact reference mapping.
You can enable optional content rules using the Service Registry web console, REST API commands, or a Java client application.
2.1.1. When rules are applied
Rules are applied only when content is added to Service Registry. This includes the following REST operations:
- Adding an artifact
- Updating an artifact
- Adding an artifact version
If a rule is violated, Service Registry returns an HTTP error. The response body includes the violated rule and a message showing what went wrong.
2.1.2. Order of precedence of rules
The order of precedence for artifact-specific and global rules is as follows:
- If you enable an artifact-specific rule, and the equivalent global rule is enabled, the artifact rule overrides the global rule.
- If you disable an artifact-specific rule, and the equivalent global rule is enabled, the global rule applies.
- If you disable an artifact-specific rule, and the equivalent global rule is disabled, the rule is disabled for all artifacts.
-
If you set a rule value to
NONE
at the artifact level, you override the enabled global rule. In this case, the artifact rule value ofNONE
takes precedence for this artifact, but the enabled global rule continues to apply to any other artifacts that have the rule disabled at the artifact level.
2.1.3. How rules work
Each rule has a name and configuration information. Service Registry maintains the list of rules for each artifact and the list of global rules. Each rule in the list consists of a name and configuration for the rule implementation.
A rule is provided with the content of the current version of the artifact (if one exists) and the new version of the artifact being added. The rule implementation returns true or false depending on whether the artifact passes the rule. If not, Service Registry reports the reason why in an HTTP error response. Some rules might not use the previous version of the content. For example, compatibility rules use previous versions, but syntax or semantic validity rules do not.
Additional resources
For more details, see Chapter 10, Service Registry content rule reference.
2.1.4. Content rule configuration
Administrators can configure Service Registry global rules and artifact-specific rules. Developers can configure artifact-specific rules only.
Service Registry applies the rules configured for the specific artifact. If no rules are configured at that level, Service Registry applies the globally configured rules. If no global rules are configured, no rules are applied.
Configure artifact rules
You can configure artifact rules using the Service Registry web console or REST API. For details, see the following:
Configure global rules
Administrators can configure global rules in several ways:
-
Use the
admin/rules
operations in the REST API - Use the Service Registry web console
- Set default global rules using Service Registry application properties
Configure default global rules
Administrators can configure Service Registry at the application level to enable or disable global rules. You can configure default global rules at installation time without post-install configuration using the following application property format:
registry.rules.global.<ruleName>
The following rule names are currently supported:
-
compatibility
-
validity
-
integrity
The value of the application property must be a valid configuration option that is specific to the rule being configured.
You can configure these application properties as Java system properties or include them in the Quarkus application.properties
file. For more details, see the Quarkus documentation.