Skip to content

Commit

Permalink
refactor: run the sync on a job rather than service
Browse files Browse the repository at this point in the history
  • Loading branch information
mpexm committed Oct 11, 2023
1 parent ec1c2aa commit b4a21f1
Show file tree
Hide file tree
Showing 46 changed files with 733 additions and 6,226 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,3 @@ jobs:
- name: App "job" - Tests
working-directory: ./job
run: yarn test

- name: App "service" - Install dependencies
working-directory: ./service
run: yarn install --frozen-lockfile

- name: App "service" - TypeScript
working-directory: ./service
run: yarn tsc --noEmit --incremental

- name: App "service" - Tests
working-directory: ./service
run: yarn test
41 changes: 3 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

The Bloomreach Discovery commercetools connector was created by [Orium](https://orium.com/), and provides the following features:

- Ability to initially load all products from commercetools to Bloomreach Discovery when the connector is installed
- Ability to automatically synchronize all products from commercetools to Bloomreach Discovery through a scheduled task

## Overview
Expand Down Expand Up @@ -45,48 +44,18 @@ Setup the required environment variables when you [create the deployment](https:
- `BLOOMREACH_DISCOVERY_DOMAIN_KEY`
- `BLOOMREACH_DISCOVERY_API_KEY`
- `BLOOMREACH_DISCOVERY_CATALOG_LOCALE`
- `COMMERCETOOLS_DEPLOYMENT_KEY`
- `BASIC_AUTH_SECRET`

> Here you have an example for deployment creation: [docs/03-create-deployment.md](docs/03-create-deployment.md)
### Post Deploy Steps (recommended)

During installation this connector sets up scheduled job that imports your commercetools product data into Bloomreach Discovery. This job is scheduled to run every 24 hours. However, after installation, we recommend triggering a manual first time sync in order to have your data imported into Bloomreach as soon as possible. Follow the steps below to trigger the first product sync.

1 - Execute a GET request to retrieve your Service URL:

```bash
curl --get https://connect.us-central1.gcp.commercetools.com/{{ CTP_CLIENT_ID }}/deployments/key={{ COMMERCETOOLS_DEPLOYMENT_KEY }} \
--header 'Authorization: Bearer {{ access_token }}' | json_pp | grep https://
```

> _Replace `{{ CTP_CLIENT_ID }}` and `{{ COMMERCETOOLS_DEPLOYMENT_KEY }}` with the values used when creating the deployment._
>
> _[How to get the {{ access_token }}?](https://docs.commercetools.com/api/authorization#client-credentials-flow)_
The url will look like this `https://service-2da6408a-5e4e-493e-a413-c248f2c37174.us-central1.gcp.preview.commercetools.app/service`

2 - After retrieving the Service URL, send a GET request to trigger the products sync.

```bash
curl -u {{ CTP_PROJECT_KEY }}:{{ BASIC_AUTH_SECRET }} \
https://service-2da6408a-5e4e-493e-a413-c248f2c37174.us-central1.gcp.preview.commercetools.app/service/bloomreach-discovery-catalog-ingestion
```

> _Replace `{{ CTP_PROJECT_KEY }}` and `{{ BASIC_AUTH_SECRET }}` with the values you used when creating the deployment._
>
> _Replace `https://service-2da6408a-5e4e-493e-a413-c248f2c37174.us-central1.gcp.preview.commercetools.app/service` with the service url you got in the previous step._
## Uninstalling the connector

In order to uninstall the connector, you’ll need to [send the appropriate HTTP request and delete it](https://docs.commercetools.com/connect/deployments#delete-deployment).

## Caveats
## FAQ

The connector is designed to load all products at once, which might result in extended HTTP request times, potentially exceeding predefined limits. We anticipate that it will handle a modest number of customers and products, likely no more than a few thousand, with an upper limit of approximately 10,000 records. The exact capacity may fluctuate due to various variables. Feel free to get in touch with us if this is a limitation for your project.
### When will the products get synced on Bloomreach?

## FAQ
- The connector [runs every day at 00:00 UTC](blob/main/connect.yaml#L6), so the products will be synced once per day. If you have just installed the connector, you'll need to wait until the next scheduled job at 00:00 UTC for the products to be synced.

### Where is the mapping for _products_ defined?

Expand All @@ -96,10 +65,6 @@ The connector is designed to load all products at once, which might result in ex

- By default, commercetools has built-in i18n support. In order to consume the catalog data, we must specify the desired [`LocalizedString`](https://docs.commercetools.com/api/types#localizedstring).

### What is the `BASIC_AUTH_SECRET` env variable for?

- The connector cronjob will sync products using an endpoint exposed by the connector itself. This endpoint is secured using a [basic http authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication), where the username is the `CTP_PROJECT_KEY` and the password the `BASIC_AUTH_SECRET`.

### What is the `COMMERCETOOLS_DEPLOYMENT_KEY` env variable for?

- When deploying a connector you'll be asked to define a "deployment key". This connector also needs the deployment key to be defined as an env variable to work properly.
Expand Down
34 changes: 0 additions & 34 deletions connect.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
deployAs:
- name: service
applicationType: service
endpoint: /service
configuration:
standardConfiguration:
- key: CTP_REGION
description: commercetools Composable Commerce API region
securedConfiguration:
- key: CTP_PROJECT_KEY
description: commercetools Composable Commerce project key
- key: CTP_CLIENT_ID
description: commercetools Composable Commerce client ID
- key: CTP_CLIENT_SECRET
description: commercetools Composable Commerce client secret
- key: CTP_SCOPE
description: commercetools Composable Commerce client scope
- key: BLOOMREACH_DISCOVERY_ACCOUNT_ID
description: Bloomreach Discovery Account Id
- key: BLOOMREACH_DISCOVERY_AUTH_KEY
description: Bloomreach Discovery Auth Key
- key: BLOOMREACH_DISCOVERY_DOMAIN_KEY
description: Bloomreach Discovery Domain Key
- key: BLOOMREACH_DISCOVERY_API_KEY
description: Bloomreach Discovery API Key
- key: BLOOMREACH_DISCOVERY_CATALOG_LOCALE
description: Bloomreach Discovery Catalog Locale
- key: COMMERCETOOLS_DEPLOYMENT_KEY
description: commercetools Deployment Key
- key: BASIC_AUTH_SECRET
description: Basic Auth Secret
- name: job
applicationType: job
endpoint: /job
Expand Down Expand Up @@ -57,7 +27,3 @@ deployAs:
description: Bloomreach Discovery API Key
- key: BLOOMREACH_DISCOVERY_CATALOG_LOCALE
description: Bloomreach Discovery Catalog Locale
- key: COMMERCETOOLS_DEPLOYMENT_KEY
description: commercetools Deployment Key
- key: BASIC_AUTH_SECRET
description: Basic Auth Secret
16 changes: 0 additions & 16 deletions docs/03-create-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ curl --location 'https://connect.us-central1.gcp.commercetools.com/composable-pr
{
"key": "BLOOMREACH_DISCOVERY_CATALOG_LOCALE",
"value": "en-US"
},
{
"key": "COMMERCETOOLS_DEPLOYMENT_KEY",
"value": "orium-ct-connect-bloomreach-discovery-deployment"
},
{
"key": "BASIC_AUTH_SECRET",
"value": "secret"
}
]
},
Expand Down Expand Up @@ -116,14 +108,6 @@ curl --location 'https://connect.us-central1.gcp.commercetools.com/composable-pr
{
"key": "BLOOMREACH_DISCOVERY_CATALOG_LOCALE",
"value": "en-US"
},
{
"key": "COMMERCETOOLS_DEPLOYMENT_KEY",
"value": "orium-ct-connect-bloomreach-discovery-deployment"
},
{
"key": "BASIC_AUTH_SECRET",
"value": "secret"
}
]
}
Expand Down
Loading

0 comments on commit b4a21f1

Please sign in to comment.