microservices-demo/src/productcatalogservice
Megan O'Keefe 90f9287f3a
Adds option to disable Stackdriver Export (#293)
2020-02-20 15:26:44 -05:00
..
genproto pb: add "categories" field to Product (#60) 2018-10-01 21:33:25 -07:00
.dockerignore go: use dep in builds, remove relative imports 2018-08-04 11:21:03 -07:00
Dockerfile Update docker images for go to 1.12 (#203) 2019-04-01 10:50:44 -07:00
Gopkg.lock Updates go services to google-cloud-go 0.40.0 (#234) 2019-07-09 16:57:50 -04:00
Gopkg.toml Updates go services to google-cloud-go 0.40.0 (#234) 2019-07-09 16:57:50 -04:00
README.md productcatalog: introduce configurable latency (#134) 2019-01-29 16:08:24 -08:00
genproto.sh Add more license headers 2018-07-25 21:25:27 -07:00
products.json adservice: find relevant ads by category (#61) 2018-10-01 22:44:56 -07:00
server.go Adds option to disable Stackdriver Export (#293) 2020-02-20 15:26:44 -05:00
server_test.go go: use dep in builds, remove relative imports 2018-08-04 11:21:03 -07:00

README.md

productcatalogservice

Run the following command to restore dependencies to vendor/ directory:

dep ensure --vendor-only

Dynamic catalog reloading / artificial delay

This service has a "dynamic catalog reloading" feature that is purposefully not well implemented. The goal of this feature is to allow you to modify the products.json file and have the changes be picked up without having to restart the service.

However, this feature is bugged: the catalog is actually reloaded on each request, introducing a noticeable delay in the frontend. This delay will also show up in profiling tools: the parseCatalog function will take more than 80% of the CPU time.

You can trigger this feature (and the delay) by sending a USR1 signal and remove it (if needed) by sending a USR2 signal:

# Trigger bug
kubectl exec \
    $(kubectl get pods -l app=productcatalogservice -o jsonpath='{.items[0].metadata.name}') \
    -c server -- kill -USR1 1
# Remove bug
kubectl exec \
    $(kubectl get pods -l app=productcatalogservice -o jsonpath='{.items[0].metadata.name}') \
    -c server -- kill -USR2 1

Latency injection

This service has an EXTRA_LATENCY environment variable. This will inject a sleep for the specified time.Duration on every call to to the server.

For example, use EXTRA_LATENCY="5.5s" to sleep for 5.5 seconds on every request.