Connect Services
Declare a Relationship, the edge from a consumer Element to the provider it depends on, so the viewer and agents know what depends on what.
Before you start
Section titled “Before you start”- The consumer is in the Model. See Add a Service.
- The provider is in the Model, in your Project or another. See Relationships for which way a Relationship points.
1. Declare the Relationship under the consumer
Section titled “1. Declare the Relationship under the consumer”Add a relationships entry under the consumer, with to naming the provider. Name a provider in another Project by its Qualified id, project:id, as core:mainframe here:
payments-service: name: Payments Service description: Validates, posts and settles customer payments. technology: Java, Spring Boot relationships: - to: payments-db description: Stores payment state in technology: JDBC - to: core:mainframe description: Posts payments to the ledger in technology: XML/HTTPS - to: card-gateway description: Settles card payments through technology: ISO 8583Write the description as a verb phrase that completes “consumer … provider”. The other fields are in the Relationship reference.
2. Declare an event under the Subscriber
Section titled “2. Declare an event under the Subscriber”Skip this step for a call. For an event, declare the Relationship under the Subscriber, pointing to the Publisher. Add interaction: async, the broker Service as via, and the topic as channel:
fraud-detection: name: Fraud Detection description: Scores each payment for fraud and holds suspicious ones. technology: Python relationships: - to: payments-service description: Scores each initiated payment interaction: async via: platform:kafka channel: payments.initiated3. Check the Workspace
Section titled “3. Check the Workspace”archidocs check0 errors, 0 warningsCheck it worked
Section titled “Check it worked”Run archidocs dev and select the consumer. The Element panel lists the new Relationship, and the Views that show both ends draw it.
If it didn’t
Section titled “If it didn’t”check refuses via and channel on a Relationship without interaction: async:
services: orders: name: Orders events: name: Events type: broker mailer: name: Mailer relationships: - to: orders description: Emails a receipt for each placed order via: events channel: orders.placedarchidocs/shop/model.yaml:12:9 error via-on-sync `via` is only for an async Relationship; add `interaction: async` or remove `via`archidocs/shop/model.yaml:13:9 error via-on-sync `channel` is only for an async Relationship; add `interaction: async` or remove `channel`
2 errors, 0 warnings
Rule docs: via-on-sync https://archidocs.dev/docs/reference/rules/via-on-sync/That is via-on-sync: add interaction: async.
check reports unknown-element when to names an id that isn’t in the Model. Correct the id, or write the Qualified id of a provider in another Project. If the provider isn’t in the Model yet, leave the Relationship out and tell the provider’s Team.
check reports via-not-broker when via names a Service that isn’t type: broker.
With an agent
Section titled “With an agent”upsert_relationship adds or updates a Relationship. search_elements resolves a provider’s name, URL or host to its Qualified id.
Related
Section titled “Related”Documents the beta branch at cd98671, ahead of the latest release, v1.4.0.