Persistence Layer

The Persistence Layer was created to allow us to push data to Makaira from one or multiple sources instead of just one like the traditional way where you push data directly to Makaira.

What is the difference between the Persistence layer data flow and the normal data flow?

Normal data flow

Persistence data flow

How to push data to the Persistence Layer?

Push data directly

You can push data to the Persistence Layer using this API: https://docs.makaira.io/reference/put_persistence-revisions

🚧

source_identifier must be specify in the request body in order for the Persistence Layer to distinguish between data sources

Push data using Makaira importers

The importer configuration should look like this:

πŸ‘

You can configure multiple importers if you have data from multiple sources

πŸ“˜

Optionally, you can create multiple importers if you have multiple languages in your datasource to speed up the import process

Create a Makaira importer to pull data from the Persistence Layer

🚧

Data must be imported into the Persistence Layer before doing this

The importer configuration should look like this:

How do I rebuild my data?

Tell the Persistence Layer that you are rebuilding your data

Use this API to trigger the rebuild: https://docs.makaira.io/reference/post_persistence-revisions-rebuild

πŸ“˜

You can either:

  • Trigger the rebuild for all doc types:
    {
        "entities": []
    }
    
  • Trigger a rebuild for some of the doc types. The example bellow will trigger a product rebuild:
    {
        "entities": [
            {
                "doc_type": "product",
                "languages": [
                    "de",
                  	"en"
                ]
            }
        ]
    }
    

Import the data

We will use the same API that we used to push data directly: https://docs.makaira.io/reference/put_persistence-revisions

But the request body will be a little bit different:

{
    "import_timestamp": "2023-01-01 00:00:00",
    "source_identifier": "your_source_identifier",
    "rebuild": true,
    "items": [
        {
            "source_revision": "1",
            "delete": false,
            "language_id": "de",
            "data": {
                # Your data
            }
        }
    ]
}

The difference here is "rebuild": true, this tells the Persistence Layer that this is a rebuilding request.

Let the Persistence Layer know that you are done importing data

To do that, please use this API: https://docs.makaira.io/reference/post_persistence-revisions-switch

πŸ“˜

Same with the rebuild process, you can either:

  • Trigger the switch for all doc types:
    {
        "entities": []
    }
    
  • Trigger a switch for some of the doc types. The example bellow will trigger a product switch:
    {
        "entities": [
            {
                "doc_type": "product",
                "languages": [
                    "de",
                  	"en"
                ]
            }
        ]
    }