0.0.1 • Published 5 years ago
nw-classic-integration v0.0.1
nw-classic-integration
Classic Integration Microservice is series of API endpoints used by Classic to push Events to New Wave.
List of events can be found here: https://confluence.nw.adesa.com/display/NW/Business+Events+Payload
Logic Flow
- Classic calls API and passes information
- This service searches for mapping for classic ids against Redis/DynamoDB(eventually Postgres)
- If found - get it. If not - generate uuid and put to mappings table (DynamoDB - eventually Postgres)
- Map Classic values to New Wave Event
- In Event we put our ids (uuids) and don't put classicids
- Serialize Event using ProtoBufs
- Put Event on Kinesis stream
TODO
- Error Handling
RUN LOCALLY
Prepare
Run the following once per dev environment
- Install localstack
- Make sure you have
.nprmrc
in your home folder (mac) with the following line@nw:registry=http://nexus.nw.adesa.com/repository/npm-group/
- Run the command
npm i -g @nw/localstack
to install localstack globally
- Make sure you have
- Run the command
localstack kinesis topic create -n nw-auction-local
to create kinesis topic. Repeat for every topic you need - View "dev:test:bdd" in package.json for localstack commands
Execute
Run the following command for every new terminal you open
export KINESIS_ENDPOINT=http://localhost:4567
sets the kinesis endpoint to be local (port fits localstack)export AWS_REGION=us-east-1
provides default region for kinesis client (for aws sdk)export AUCTION_STREAM_NAME='nw-auction-local'
provides default stream name for auctionsexport WATCHLIST_STREAM_NAME='nw-watchlist-local'
provides default stream name for auctionsnpm run localstack:all:up
runs all localstack componentslocalstack kinesis topic create -n nw-auction-local
creates required topic on kinesisnpm run dev:test:bdd
to actually execute the tests
DEPLOY TO AWS
- serverless deploy --stage <dev,uat,etc.>
- Example endpoint:
- Sample JSON
Sample CURL Request:
- curl -H "Content-Type: application/json" -X POST -d '{"eventType":"vehicle_added_watchlist","body":{"vehicleId":"220308346","vin":"12345678901234567","userId":"kluo_atco","firstName":"Kitty","lastName":"Luo"}}' https://sb7gd1sej3.execute-api.us-east-1.amazonaws.com/dev/api/classic/import
HTTP Codes:
- 200 - Success. Event was posted to kinesis
- 500 - Server Error. Server wasn't able to process event (check error message)
- 501 - Event is not implemented
- 504 - Gateway Timeout. Server times out due to lambda cold start time, network connectivity, etc.
0.0.1
5 years ago