{"id":23122609,"url":"https://github.com/folio-org/mod-inventory-storage","last_synced_at":"2026-05-27T19:00:55.349Z","repository":{"id":38370167,"uuid":"89595170","full_name":"folio-org/mod-inventory-storage","owner":"folio-org","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-25T09:11:51.000Z","size":9341,"stargazers_count":10,"open_issues_count":3,"forks_count":23,"subscribers_count":25,"default_branch":"master","last_synced_at":"2026-05-25T10:16:05.468Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/folio-org.png","metadata":{"files":{"readme":"README.MD","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-04-27T12:31:22.000Z","updated_at":"2026-05-25T09:11:01.000Z","dependencies_parsed_at":"2024-05-29T06:08:57.948Z","dependency_job_id":"2bea5a61-dfc5-4f12-853b-794044d936a1","html_url":"https://github.com/folio-org/mod-inventory-storage","commit_stats":null,"previous_names":[],"tags_count":169,"template":false,"template_full_name":null,"purl":"pkg:github/folio-org/mod-inventory-storage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folio-org%2Fmod-inventory-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folio-org%2Fmod-inventory-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folio-org%2Fmod-inventory-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folio-org%2Fmod-inventory-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/folio-org","download_url":"https://codeload.github.com/folio-org/mod-inventory-storage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folio-org%2Fmod-inventory-storage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33579668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T07:28:40.322Z","updated_at":"2026-05-27T19:00:55.335Z","avatar_url":"https://github.com/folio-org.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mod-inventory-storage\n\nCopyright (C) 2016-2023 The Open Library Foundation\n\nThis software is distributed under the terms of the Apache License,\nVersion 2.0. See the file \"[LICENSE](LICENSE)\" for more information.\n\n\u003c!-- TOC --\u003e\n* [mod-inventory-storage](#mod-inventory-storage)\n* [Goal](#goal)\n* [Prerequisites](#prerequisites)\n* [Preparation](#preparation)\n  * [Git Submodules](#git-submodules)\n  * [Postgres](#postgres)\n  * [Kafka](#kafka)\n* [Building](#building)\n* [Environment Variables](#environment-variables)\n* [Local Deployment using Docker](#local-deployment-using-docker)\n  * [Preparation](#preparation-1)\n  * [Start the infrastructure](#start-the-infrastructure)\n  * [Start the Module](#start-the-module)\n  * [Stop the Module](#stop-the-module)\n  * [Stop the infrastructure](#stop-the-infrastructure)\n* [Local Deployment using Homebrew on macOS](#local-deployment-using-homebrew-on-macos)\n* [Running](#running)\n  * [Preparation](#preparation-2)\n  * [Running Okapi](#running-okapi)\n  * [Registration](#registration)\n  * [Tenant Initialization](#tenant-initialization)\n  * [Sample Data](#sample-data)\n* [Making Requests](#making-requests)\n  * [Okapi Root Address](#okapi-root-address)\n* [Operating System Support](#operating-system-support)\n* [Additional Information](#additional-information)\n    * [Issue tracker](#issue-tracker)\n    * [ModuleDescriptor](#moduledescriptor)\n    * [API documentation](#api-documentation)\n    * [Code analysis](#code-analysis)\n    * [Download and configuration](#download-and-configuration)\n* [Appendix 1 - Docker Information](#appendix-1---docker-information)\n  * [When Using the Modules as Docker Containers](#when-using-the-modules-as-docker-containers)\n    * [Finding a Routable Address](#finding-a-routable-address)\n* [HRID Management](#hrid-management)\n* [Inventory view endpoint](#inventory-view-endpoint)\n* [Domain event pattern](#domain-event-pattern)\n  * [Domain events for items](#domain-events-for-items)\n  * [Domain events for delete all APIs](#domain-events-for-delete-all-apis)\n  * [Reindex of instances](#reindex-of-instances)\n  * [Iteration of instances](#iteration-of-instances)\n\u003c!-- TOC --\u003e\n\n# Goal\n\nFOLIO compatible inventory storage module.\n\nProvides PostgreSQL based storage to complement the [inventory module](http://github.com/folio-org/mod-inventory). Written in Java, using the raml-module-builder and uses Maven as its build system.\n\n# Prerequisites\n\n- Java 17 JDK\n- Maven 3.3.9\n- Docker ([minimum requirements](https://www.testcontainers.org/supported_docker_environment/))\n- Postgres 12 (running and listening on localhost:5432, logged in user must have admin rights)\n- Kafka 2.6 (running and listening on localhost:9092)\n- Node 6.4.0 (for API linting and documentation generation)\n- NPM 3.10.3 (for API linting and documentation generation)\n- Python 3.6.0 (for un-registering module during managed deployment scripts)\n\n# Preparation\n\n## Git Submodules\n\nThere are some common RAML definitions that are shared between FOLIO projects via Git submodules.\n\nTo initialise these please run `git submodule init \u0026\u0026 git submodule update` in the root directory.\n\nIf these are not initialised, the module will fail to build correctly, and other operations may also fail.\n\nMore information is available on the [developer site](https://dev.folio.org/guides/developer-setup/#update-git-submodules).\n\n## Postgres\n\nRun the `setup-test-db.sh` script in the root directory to setup Postgres with a database to be used in tests.\nThis is only required to run tests against an external Postgres instance, the default is to use an embedded Postgres instance.\n\n## Kafka\n\nMod-inventory-storage implements domain event pattern and requires kafka to be listening to\n`localhost:9092`. You can override kafka port and host by setting `KAFKA_PORT` and\n`KAFKA_HOST` environment variables.\n\nFor production deployments it is also required to set `REPLICATION_FACTOR`\nenv variable, this property has the following description:\n\u003e The replication factor controls how many servers will replicate each message that is written.\n\u003e If replication factor set to 3 then up to 2 servers can fail before access to the data will be lost.\n\nThe default configuration for this property is `1` for production environments\nit is usually `3`.\n\nThere is another important property - `number of partitions` for a topic - it has the following\ndescription:\n\u003e The partition count controls how many logs the topic will be sharded into.\n\nThese properties can be changed by setting env variable.\n\n* `KAFKA_DOMAIN_TOPIC_NUM_PARTITIONS` Default value - `50`\n* `KAFKA_CLASSIFICATION_TYPE_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_CALL_NUMBER_TYPE_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_LOCATION_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_LIBRARY_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_LOAN_TYPE_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_CAMPUS_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_INSTITUTION_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_REINDEX_RECORDS_TOPIC_NUM_PARTITIONS` Default value - `16`\n* `KAFKA_REINDEX_FILE_READY_TOPIC_NUM_PARTITIONS` Default value - `16`\n* `KAFKA_SUBJECT_SOURCE_TOPIC_NUM_PARTITIONS` Default value - `1`\n* `KAFKA_MATERIAL_TYPE_TOPIC_NUM_PARTITIONS` Default value - `1`\n\nThere is also possibility for customizing through properties the Kafka Topic\n`message retention` (in milliseconds) and `maximum message size` (in bytes). The default values of these configurations\nfor any topic are 604800000 milliseconds (or 1 week) and 1048576 bytes (or 1 MB) respectively\n\nThese are the defined topic properties for `message retention` and `maximum message size` for `reindex-records` topic\n\n* `KAFKA_REINDEX_RECORDS_TOPIC_MESSAGE_RETENTION` Default value - `86400000` (1 day)\n* `KAFKA_REINDEX_RECORDS_TOPIC_MAX_MESSAGE_SIZE` Default value - `10485760` (10 MB)\n\nin case, any of these topic properties are changed for `reindex-records` the topic needs to be recreated and module needs to be reinstalled.\n\nChanging maximum message size for kafka producer:\n* `KAFKA_REINDEX_PRODUCER_MAX_REQUEST_SIZE_BYTES` Default value - `10485760` (10 MB)\n\n# Building\n\nrun `mvn install` from the root directory.\n\nTo run the tests against both embedded and external databases, run `./build.sh` from the root directory.\n\n# Environment Variables\n\nThese environment variables configure Kafka, for details see [Kafka](#kafka):\n* `KAFKA_PORT`\n* `KAFKA_HOST`\n* `REPLICATION_FACTOR`\n* `KAFKA_DOMAIN_TOPIC_NUM_PARTITIONS`\n* `KAFKA_CLASSIFICATION_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_CALL_NUMBER_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_LOAN_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_REINDEX_RECORDS_TOPIC_NUM_PARTITIONS`\n* `KAFKA_REINDEX_FILE_READY_TOPIC_NUM_PARTITIONS`\n* `KAFKA_SUBJECT_SOURCE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_MATERIAL_TYPE_TOPIC_NUM_PARTITIONS`\n\n\nThese environment variables configure Kafka topic for specific business-related topics\n* `KAFKA_CLASSIFICATION_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_CALL_NUMBER_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_LOCATION_TOPIC_NUM_PARTITIONS`\n* `KAFKA_LIBRARY_TOPIC_NUM_PARTITIONS`\n* `KAFKA_LOAN_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_CAMPUS_TOPIC_NUM_PARTITIONS`\n* `KAFKA_INSTITUTION_TOPIC_NUM_PARTITIONS`\n* `KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_REINDEX_RECORDS_TOPIC_NUM_PARTITIONS`\n* `KAFKA_REINDEX_FILE_READY_TOPIC_NUM_PARTITIONS`\n* `KAFKA_SUBJECT_SOURCE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_MATERIAL_TYPE_TOPIC_NUM_PARTITIONS`\n* `KAFKA_REINDEX_RECORDS_TOPIC_MESSAGE_RETENTION`\n* `KAFKA_REINDEX_RECORDS_TOPIC_MAX_MESSAGE_SIZE`\n\nmod-inventory-storage also supports all Raml Module Builder (RMB) environment variables,\nfor details see [RMB](https://github.com/folio-org/raml-module-builder#environment-variables):\n* `DB_HOST`\n* `DB_PORT`\n* `DB_USERNAME`\n* `DB_PASSWORD`\n* `DB_DATABASE`\n* `DB_HOST_READER`\n* `DB_PORT_READER`\n* `DB_SERVER_PEM`\n* `DB_QUERYTIMEOUT`\n* `DB_CHARSET`\n* `DB_MAXPOOLSIZE`\n* `DB_MAXSHAREDPOOLSIZE` (buggy, do not use [RMB-1030](https://folio-org.atlassian.net/browse/RMB-1030))\n* `DB_CONNECTIONRELEASEDELAY`\n* `DB_RECONNECTATTEMPTS`\n* `DB_RECONNECTINTERVAL`\n* `DB_EXPLAIN_QUERY_THRESHOLD`\n* `DB_ALLOW_SUPPRESS_OPTIMISTIC_LOCKING`\n\nThese environment variables configure the module interaction with S3-compatible storage (AWS S3, Minio Server):\n* `S3_MARC_MIGRATION_URL`\n* `S3_MARC_MIGRATION_REGION`\n* `S3_MARC_MIGRATION_BUCKET`\n* `S3_MARC_MIGRATION_ACCESS_KEY_ID` (default value is an empty string - \"\")\n* `S3_MARC_MIGRATION_SECRET_ACCESS_KEY` (default value is an empty string - \"\")\n* `S3_MARC_MIGRATION_IS_AWS` (default value - `false`)\n* `S3_REINDEX_URL`\n* `S3_REINDEX_REGION`\n* `S3_REINDEX_BUCKET`\n* `S3_REINDEX_ACCESS_KEY_ID` (default value is an empty string - \"\")\n* `S3_REINDEX_SECRET_ACCESS_KEY` (default value is an empty string - \"\")\n* `S3_REINDEX_IS_AWS` (default value - `false`)\n* `S3_LOCAL_SUB_PATH` (default value - `mod-inventory-storage`)\n* `ECS_TLR_FEATURE_ENABLED` (default value - `false`)\n\n# Local Deployment using Docker\n\n## Preparation\n\nExecute `mvn clean package` to build the jar artefact needed for building a Docker image\n\n## Start the infrastructure\n\nClone `https://github.com/folio-org/folio-tools/`\n\nNavigate to the folder `infrastructure/local` directory within the cloned repository\n\nExecute `docker compose up -d` to start the infrastructure containers needed to run the module\n\n## Start the Module\n\nIn the root of this repository, execute `docker compose up -d` to deploy the module\n\n## Stop the Module\n\nIn the root of this repository, execute `docker compose down` to undeploy the module\n\n## Stop the infrastructure\n\nNavigate to the folder `infrastructure/local` directory within the clone of the folio-tools repository\n\nExecute `docker compose down` to stop the infrastructure containers\n\n# Local Deployment using Homebrew on macOS\n\nThe GitHub Actions file [.github/workflows/mac.yml](.github/workflows/mac.yml) for macOS uses Homebrew\nto setup the infrastructure, run the module, and install and check sample data.\n\n# Running\n\n## Preparation\n\n## Running Okapi\n\nMake sure that [Okapi](https://github.com/folio-org/okapi) is running on its default port of 9130 (see the [guide](https://github.com/folio-org/okapi/blob/master/doc/guide.md) for instructions).\n\nA script for building and running Okapi is provided. Run `../mod-inventory-storage/start-okapi.sh` from the root of the Okapi source.\n\nAs this runs Okapi using Postgres storage, some database preparation is required. This can be achieved by running `./create-okapi-database.sh` from the root of this repository.\n\n## Registration\n\nTo register the module with deployment instructions and activate it for a demo tenant, run `./start-managed-demo.sh` from the root directory.\n\nTo deactivate and unregister the module, run `./stop-managed-demo.sh` from the root directory.\n\n## Tenant Initialization\n\nThe module supports v2.0 of the Okapi `_tenant` interface. This version of the interface allows Okapi to pass tenant initialization parameters using the `tenantParameters` key. Currently, the only parameters supported are the `loadReference` and `loadSample` keys, which will cause the module to load reference data and sample data respectively for the tenant if set to `true`.  Here is an example of passing the `loadReference` parameter to the module via Okapi's `/_/proxy/tenants/\u003ctenantId\u003e/install` endpoint:\n\n    curl -w '\\n' -X POST -d '[ { \"id\": \"mod-inventory-storage-14.1.0\", \"action\": \"enable\" } ]' http://localhost:9130/_/proxy/tenants/my-test-tenant/install?tenantParameters=loadReference%3Dtrue\n\nThis results in a post to the module's `_tenant` API with the following structure:\n\n```json\n{\n  \"module_to\": \"mod-inventory-storage-14.1.0\",\n  \"parameters\": [\n    {\n      \"key\": \"loadReference\",\n      \"value\": \"true\"\n    }\n  ]\n}\n```\n\nSee the section [Install modules per tenant|https://github.com/folio-org/okapi/blob/master/doc/guide.md#install-modules-per-tenant] in the Okapi guide for more information.\n\n## Sample Data\n\nTo load some sample data, the `loadSample` tenant initialization parameter can be passed when installing the module:\n\n    curl -w '\\n' -X POST -d '[ { \"id\": \"mod-inventory-storage-14.1.0\", \"action\": \"enable\" } ]' http://localhost:9130/_/proxy/tenants/my-test-tenant/install?tenantParameters=loadReference%3Dtrue%2CloadSample%3Dtrue\n\nPlease note that loading sample data will not work without also loading reference data.\n\nThe sample data that would be loaded can be found in the `sample-data/` folder in the root directory.\n\n# Making Requests\n\nThese modules provide HTTP based APIs rather than any UI themselves.\n\nAs FOLIO is a multi-tenant system, many of the requests made to these modules are tenant aware (via the X-Okapi-Tenant header), which means most requests need to be made via a system which understands these headers (e.g. another module or UI built using [Stripes](https://github.com/folio-org/stripes-core)).\n\nTherefore, it is suggested that requests to the API are made via tools such as curl or [postman](https://www.getpostman.com/), or via a browser plugin for adding headers, such as [Requestly](https://chrome.google.com/webstore/detail/requestly/mdnleldcmiljblolnjhpnblkcekpdkpa).\n\n## Okapi Root Address\n\nIt is recommended that the modules are located via Okapi. Access via Okapi requires passing the X-Okapi-Tenant header (see the Okapi guide above for details).\n\nhttp://localhost:9130/instance-storage\nhttp://localhost:9130/item-storage\n\n# Operating System Support\n\nMost of the development for these modules, thus far, has been performed on OS X, with some on Ubuntu. Feedback for these, and particularly other operating systems is very welcome.\n\n# Additional Information\n\nOther [modules](https://dev.folio.org/source-code/#server-side).\n\nOther FOLIO Developer documentation is at [dev.folio.org](https://dev.folio.org/)\n\n### Issue tracker\n\nSee project [MODINVSTOR](https://issues.folio.org/browse/MODINVSTOR)\nat the [FOLIO issue tracker](https://dev.folio.org/guidelines/issue-tracker/).\n\n### ModuleDescriptor\n\nSee the built `target/ModuleDescriptor.json` for the interfaces that this module\nrequires and provides, the permissions, and the additional module metadata.\n\n### API documentation\n\nThis module's [API documentation](https://dev.folio.org/reference/api/#mod-inventory-storage).\n\n### Code analysis\n\n[SonarQube analysis](https://sonarcloud.io/dashboard?id=org.folio%3Amod-inventory-storage).\n\n### Download and configuration\n\nThe built artifacts for this module are available.\nSee [configuration](https://dev.folio.org/download/artifacts) for repository access,\nand the [Docker image](https://hub.docker.com/r/folioorg/mod-inventory-storage/).\n\n# Appendix 1 - Docker Information\n\n## When Using the Modules as Docker Containers\n\nFor the modules to communicate via Okapi Proxy, when running in Docker containers, the address for Okapi Proxy needs to be routable from inside the container.\n\nThis can be achieved by passing a parameter to the script used to start Okapi, as follows `../mod-metadata/start-okapi.sh http://192.168.X.X:9130`\n\nWhere 192.168.X.X is a routable IP address for the host from container instances and both repository clones are at the same directory level on your machine.\n\n### Finding a Routable Address\n\nFinding the appropriate IP address can be OS and Docker implementation dependent, so this is a very early guide rather than thorough treatment of the topic.\n\nIf these methods don't work for you, please do get in touch, so this section can be improved.\n\nOn Linux, `ifconfig docker0 | grep 'inet addr:'` should give output similar to `inet addr:192.168.X.X  Bcast:0.0.0.0  Mask:255.255.0.0`, , the first IP address is usually routable from within containers.\n\nOn Mac OS X (using Docker Native), `ifconfig en0 | grep 'inet '` should give output similar to `inet 192.168.X.X netmask 0xffffff00 broadcast 192.168.X.X`, the first IP address is usually routable from within containers.\n\n# HRID Management\n\nWhen instances, holdings records and items are added to inventory, they will be assigned a human\nreadable identifier (HRID) if one is not provided. The HRID is created using settings stored in and\nmanaged by this module via the `/hrid-settings-storage/hrid-settings` API.\n\nThe default settings, on enabling the module, are:\n|Type     |Prefix|Start Number|First HRID String|Max HRID String|\n|---------|------|------------|-----------------|---------------|\n|Instances|in    |1           |in00000001       |in99999999     |\n|Holdings |ho    |1           |ho00000001       |ho99999999     |\n|Items    |it    |1           |it00000001       |it99999999     |\n\nThe prefix is optional for each inventory type and is restricted to 10 alphanumeric characters as\nwell as `.` and `-`. The start number is required. A generated HRID will consist of the prefix,\nif supplied, prepended to `0` padded 8 digit string starting from the start number. Every HRID\ngenerated will increment the current number of that inventory type by 1. HRID strings are case\ninsensitive and must be unique or not present when adding a new inventory type.\n\nChanging the start number to a number lower than the current number is not supported and will\nlikely lead to generation of duplicate HRIDs. If an inventory type is added that contains a\nduplicate HRID, the module will reject the submission.\n\n# Inventory view endpoint\n\nRunning a query against the `/inventory-view/instances` API writes this log message:\n\n```\nWARN  CQL2PgJSON           loadDbSchema loadDbSchema(): No configuration for table instance_holdings_item_view found, using defaults\n```\n\nThis is a [known issue caused by RMB](https://issues.folio.org/browse/RMB-909) and can be ignored.\n\n# Domain event pattern\n\nThe pattern means that every time when an instance/item is created/updated/removed\na message is posted to kafka topic:\n* `inventory.instance` - for instances;\n* `inventory.item` - for items;\n* `inventory.holdings-record` - for holdings records.\n\nThe event payload has following structure:\n```javascript\n{\n  \"old\": {...}, // the instance/item before update or delete\n  \"new\": {...}, // the instance/item after update or create\n  \"type\": \"UPDATE|DELETE|CREATE|DELETE_ALL\", // type of the event\n  \"tenant\": \"diku\" // tenant name\n}\n```\n\n`X-Okapi-Url` and `X-Okapi-Tenant` headers are set from the request to the kafka message.\n\nKafka partition key for all the events is instance id (for items it is retrieved from\nassociated holding record).\n\n## Domain events for items\n\nThe `new` and `old` records also includes `instanceId` property,\non the same level with other item properties, which defined in the schema:\n```javascript\n{\n  \"instanceId\": \"\u003cthe instance id\u003e\",\n  // all other properties that defined in the schema\n}\n```\n\n## Domain events for delete all APIs\n\nThere are delete all APIs for items instances and holding records. For such\nAPIs we're issuing a special domain event:\n* Partition key: `00000000-0000-0000-0000-000000000000`\n* Event payload:\n```javascript\n{\n  \"type\": \"DELETE_ALL\",\n  \"tenant\": \"\u003cthe tenant name\u003e\"\n}\n```\n\n## Reindex of instances\n\nSome consumers need to pull all instances from an existing database. There is\n`instance-reindex` API for this. When a reindex job is submitted we initiate\nstreaming of all instance IDs and publishing domain events for them. The domain\nevent has following structure:\n* Topic: `inventory.instance`\n* Partition key: `The instance id`\n* Payload:\n```javascript\nx-okapi-tenant: \u003ctenant-id\u003e\nx-okapi-url: \u003cokapi-url\u003e\n\n{\n  \"type\": \"REINDEX\",\n  \"tenant\": \"\u003cthe-tenant-name\u003e\"\n}\n```\n\n## Iteration of instances\n\nThere are business cases when the whole instance collection should be traversed to obtain existing instances\n(and potentially related items/holdings) and processing them in asynchronous manner. Examples of such cases are:\n* creating search indices;\n* contributing instance catalog to external system.\n\nTo support the above there is _\"Instance Iteration API\"_ available via `/instance-storage/instances/iteration` URL.\nIt is similar to `instance-reindex` API but avoids some limitations of this API by:\n* allowing to specify a target Kafka topic for produced events;\n* allowing simultaneous execution of several jobs with different event types to serve the needs of\ndifferent business processes;\n* making the interface client agnostic (naming says nothing about business intention of the caller, like re-indexing).\n\nIt's expected that Instance Iteration API will substitute Instance Reindex API in the future.\n\nIteration API provides the following methods:\n* to start a new iteration job: `POST /instance-storage/instances/iteration`\n* to get status of a running job by its id: `GET /instance-storage/instances/iteration/{jobId}`\n* to cancel a job: `DELETE /instance-storage/instances/iteration/{jobId}`\n\nWhen an iteration job is being submitted the client can specify target topic and event type (optional):\n```javascript\n{\n  \"eventType\": \"\u003cevent-type\u003e\",\n  \"topicName\": \"\u003ctarget-topic-name\u003e\"\n}\n```\nIf event type is missing in the request it will be defaulted to `ITERATE`.\n\nOnce iteration job has been started, it initiates streaming of all instance IDs and publishing domain events for them.\nThe domain event has the following structure:\n* Topic: \u003ctarget-topic-name\u003e\n* Partition key: `The instance id`\n* Payload:\n```javascript\nx-okapi-tenant: \u003ctenant-id\u003e\nx-okapi-url: \u003cokapi-url\u003e\niteration-job-id: \u003cjob-id\u003e\n{\n  \"type\": \"\u003cevent-type\u003e\",\n  \"tenant\": \"\u003cthe-tenant-name\u003e\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffolio-org%2Fmod-inventory-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffolio-org%2Fmod-inventory-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffolio-org%2Fmod-inventory-storage/lists"}