
## What causes this lambda to run?

A message published on the Kafka topic [`cdc.contentReview.reviewQueue`](https://prod-akhq.theorchard.io/ui/qa-cdc/topic/cdc.contentReview.reviewQueue/data?sort=Newest&partition=All).

## What does this lambda do?

Parses messages, batches them together, and then starts the execution of the AWS Step Functions State Machine: [`sfn-content-index-product-metadata`](https://github.com/theorchard/terraform-infra/blob/master/qa/lambda-content/index-product-metadata/sfn.json) with a payload of all the messages it processed.

Example Payload:

```json
{
    "data": {
        "indexing_inputs": [
            {
                "product_id": 1234,
                "payload": {},
                "operation_type": "add_to_index"
            }
        ]
    }
}
```

## Install

Requires: python3.11

```sh
make pip_dev
```

Direct dependencies are listed in `requirements-to-freeze.txt` and locked with
their own dependencies in `requirements.txt`. `requirements.txt` is imported into
`requirements-test.txt` and testing dependencies are listed. To bump versions
of dependencies, update the version in `requirements-to-freeze.txt` and run
`make pip_lock_versions` to regenerate `requirements.txt`.

## Development

```sh
# Run the function locally using a test event and print results
make dev

# Run linting
make lint

# Run tests
make test

# Build the docker image, launch it, and run linting and tests against it
make ci_unit_lint

# Rebuild your local env from scratch
make clean pip_dev
```

### Docker Stack

The docker stack offers an environment like the one on AWS for developing against.

```sh
# Bring the function up in a docker-compose stack. The container will mount
# src dir so it will update immediately as you develop.
make docker_up

# Send a mock event to the function
make docker_event

# Bring the stack down
make docker_down
```