Adding data stores to services
eventcatalog@2.59.0
To add data stores to your service you first have to define your data stores.
Once you have data stores defined in your Catalog you can reference them within your service using the writesTo
or/and readsFrom
fields.
Adding data stores to your service​
To add data stores to a service you need to define them in either the writesTo or readsFrom array within your service frontmatter API.
You need to add the id
and version
of the data store.
---
id: OrderService
... # other service frontmatter
writesTo:
# id of the data store this service writes to
- id: OrdersDatabase
# The version of the message you want to add (optional, if not provided latest will be used)
version: 0.0.1
readsFrom:
# id of the data store this service reads from
- id: ProductRedisCache
# The version of the data store you want to add (optional, if not provided latest will be used)
version: 1.0.1
---
<!-- Markdown contents... -->
The writesTo and readsFrom fields in your service tell EventCatalog which data stores this service either writes to or reads from.
When you define your data stores for your service you can define the version of them too. This can be powerful if you have multiple versions of your data stores. Example could be a new version of a data store that you are migrating to.
Using semver versioning​
eventcatalog@2.4.0
You can use semver syntax when referencing your data stores in your services.
---
id: PaymentDomain
... # other domain frontmatter
writesTo:
# Latest minor version of OrdersDatabase will be added
- id: OrdersDatabase
version: 0.x.1
# Minor and patches of this version will be linked
- id: ProductRedisCache
version: ^1.0.1
# Latest version of this data store will be shown by default.
- id: OrdersDatabase
---
<!-- Markdown contents... -->
You can choose not to provide a version for a data store. If no version is given latest is used by default.
Visualizing data stores within a service​
When data stores get added within your services EventCatalog will visualize this for you either using the NodeGraph
component or through the visualizer.
You can see an example of this here