# daemon-asset-copy

## Context
This daemon is used in the following areas of our infrastructure:
- state machine:
  - `workflow-transfer-assets`
  - `workflow-backfill-v2-assets`
  - `workflow-backfill-v2-artwork`

### workflow-transfer-assets state machine context
The `workflow-transfer-assets` state machine is downstream from the `find-assets-to-download` lambda which invokes the `workflow-transfer-assets` state machine.

## Local Development

### Pre-requisites

#### Install
* Install [docker](https://docs.docker.com/get-docker/)
* Clone this repository

#### Running Worker

##### Automatic Setup
The worker can be run out-of-the-box with default configurations using local containers for storage servers. Scripts in `./local_dev_kit/` automatically setup fixtures and run the app as follow.
* docker-compose waits for dependencies to be healthy
* `dev_entrypoint.sh` runs
	* `dev_setup.py` runs
		* clears/re-creates queue defined by `$TASK_SQS_QUEUE_NAME` envvar
		* creates buckets and files according to `dev_s3.json`
		* adds messages to SQS queue according comma separated list in `$MESSAGES` envvar that refers to files in `messages/`
	* `entrypoint.sh` runs (this is the normal app execution flow)

##### Manual Setup
By default no messages are added to the queue for the worker to consume, copy over the setup with test messages configured in `$MESSAGES`.

```bash
$ cp .env.shadow .env
```

##### Invoke Worker

```bash
$ docker compose up --build worker
```
:bulb: Change envvars in `.env` to test different messages according to your needs!

#### Run Tests

```bash
$ docker compose up --exit-code-from test --abort-on-container-exit --build test
```


#### Run Linting + Formatting

```bash
$ docker compose up --exit-code-from lint --abort-on-container-exit --build lint
```
:bulb: Source code is mounted to host machine, changes made by formatters are applied.

