camunda-community-hub / zeebe-client-node-js

Node.js client library for Zeebe Microservices Orchestration Engine
https://camunda-community-hub.github.io/zeebe-client-node-js/
Apache License 2.0
152 stars 38 forks source link

Add API surface area for multi-tenancy #330

Closed jwulf closed 11 months ago

jwulf commented 1 year ago

Multi-tenancy is coming.

This task is to add support to the API surface of the client, with no change to the implementation as yet (the gRPC protocol implementation has not landed yet).

The methods will not do anything in the client but will allow consumers of zeebe-node to use the methods during development.

See the Java client task here: https://github.com/camunda/zeebe/issues/13517

Schema changes

The following commands need a way to specify a tenant:

The following commands need a way to specify one or more tenants:

Out of scope

The following commands are unaffected:

jwulf commented 1 year ago

Required by the Desktop Modeler: https://github.com/camunda/camunda-modeler/issues/3716

jwulf commented 1 year ago

I am going to remove the method overloads for createProcessInstance and createProcessInstanceWithResult, leaving only the object parameter method.

So:

zbc.createProcessInstanceWithResult({
   bpmnProcessId: 'order-process',
   variables: {
     customerId: 123,
     invoiceId: 567
   }
})
zbc.createProcessInstance({
  bpmnProcessId: 'test-process',
  variables: {
    testData: 'something'
  }
})

The rationale for this is: adding tenantId to all the method signatures increases the complexity. To reduce complexity, I will remove method overloads.

jwulf commented 1 year ago

Published package 8.3.0-alpha4.

To do: deployProcess needs to be modified. Maybe it won't support tenantId, because it can take an object, a string, or an array of strings - which doesn't give us a single way to do it - other than a second argument.

jwulf commented 1 year ago

Opened a PR for the Modeler team to test integrating the new APIs in 8.3.0-alpha4: https://github.com/camunda/camunda-modeler/issues/3772

jwulf commented 1 year ago

Based on the Operate team's use of the Zeebe Node library, rather than breaking the deployProcess API in the library, I plan to mark it as deprecated, and add support for multi-tenancy to the deployResource API.

This means that users wanting to use the new feature will need to refactor code to use this API, and there will be no change for users who are using the older API and do not wish to use the new feature.

User refactoring is then both motivated by and rewarded by a new feature: multi-tenancy support.

nikku commented 1 year ago

To consider: Add defaultTenantId that can be provided on client instantiation. This would mirror what is currently planned for the Java API and make single tenant applications simpler (i.e. Camunda Desktop Modeler).

jwulf commented 1 year ago

This is a very good idea. If the constructor / env vars provide the tenantIdon client instantiation, then the tenantId can be added to any method invocation.

akeller commented 1 year ago

@jwulf can you add a status here for this work?

jwulf commented 11 months ago

The published 8.3.0-alpha8 and 8.3.0-alpha9 packages include the fix for full multi-tenancy support.

jwulf commented 11 months ago

I tested it with Desktop Modeler against Self-Managed multi-tenant, and it works. Will push 8.3.0 package early next week.

jwulf commented 11 months ago

Published in 8.3.0