Skip to content

Steps to migrate from node server to Google cloud functions #1

@Jaymassena

Description

@Jaymassena

A new client release is required to start using functions instead of the node server because the api has changed. The api is a combination of the database rules, the database schema, the function triggers and the function logic.

V2.0 Client: Submits tasks to the '/queue' path which is monitored by the node server.
V2.1 Client: Database writes trigger functions that handle all non-client logic. The only remaining task is creating new users which is now on the '/task/create-user' path.

The new client changes how it writes to the database to match the functionality expected from the cloud functions. Mostly this consists of writing to the database directly instead of composing tasks.

No Backwards Compatibility Support

Because of conflicts (see issues below) caused by having two logic implementations executing at the same time we are going to treat this as a forced update by setting /client/ios=229. Users will be required to update.

Deployment

  • Submit build 229 for approval.
  • When approved, release to store
  • Set /client/ios=229
  • Deploy rules and functions for patchr-ios
  • Shut down node server: When support for old clients ends, we will shut down the node server and that will stop any billing from Heroku.
  • Remove '/queue' from database if needed.
  • Remove security tests that target the old version.

Issues

  • New stuff has to work for app store reviewers so how does that work? I guess we should see just what happens with new functions and rules deployed side-by-side with node server. Reviewer should work fine but users with old clients will face potential conflicts per below.

  • Both node server and functions will be triggered by any writes to '/unreads/{userId}/{groupId}/{channelId}/{messageId}'. Node server always recounts all the unreads and sets the counter. The cloud function increments or decrements the counter in a transaction based on whether the write was a create or a delete. This could produce the wrong count depending on the execution order.

  • Node server performs updates based on tasks. Those updates can in turn trigger functions that will execute logic that duplicates or conflicts with the logic executed by the task.

Node server triggers

  • '/unreads' child added/changed/removed
  • '/queue/*' child added

Function triggers

  • '/group-messages/{groupId}/{channelId}/{messageId}' create/change/delete
  • '/group-channels/{groupId}/{channelId}' create/change/delete
  • '/groups/{groupId}' create/change/delete
  • '/invites/{groupId}/{userId}/{inviteId}' create
  • '/unreads/{userId}/{groupId}/{channelId}/{messageId}' create/change/delete
  • '/group-channel-members/{groupId}/{channelId}/{userId}' create/change/delete
  • '/group-members/{groupId}/{userId}' create/change/delete
  • '/users/{userId}/profile' change/delete
  • '/users/{userId}/username' create/change/delete
  • '/counters/{userId}/unreads' delete
  • '/tasks/create-user/{taskId}' create

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions