Processes
The client-service consists of a few processes the main one being the Web process which serves the main API.
Web
Fastify web-server which provides the main REST API for the client-service.
Output
As a response to the requests received via the REST API the web server produces a few different outputs in form of messages.
Client App-code Mismatch Requests
Produced by the validate-app-code hook when a mismatch is detected between the app-code in the request param and the app-code stored in the client-state token. Publishes a message to client-app-code-mismatch-requests PubSub topic.
Client State Client Updates
When any direct property of a client is changed a message is published to the client-state-client-updates
Workers / Change Client App Code
This worker consumes messages from the me-client-change-client-app-code subscription which in turn is bound to the client-app-code-mismatch-requests topic.
The whole point of the worker is react to requests where the app-code does not match the one stored in the client-state. This happens when a customer uses multiple app-codes within the same app to e.g. cope with multiple countries.
This needs to be handled to avoid bad state of the client data both in big-query client state and dynamo device storage.
Actions
-
Reset push-token and client using old app-code both in big-query client state and dynamo device storage.
-
Set push-token of client using new app-code in both big-query client state and dynamo device storage.
-
Reset contact for client using old app-code both in big-query client state and dynamo device storage.
-
Set contact for client using new app-code by publishing a login-message.
Workers / Anonymous Contact Resolver
Subscriber of the contact-changes topic with a filter=contact-field and is_anonymous set to true. Uses the contact-data service to resolve contact-id from the contact-field and if needed will create a new anonymous contact.