You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `@sourceloop/ctrl-plane-orchestrator-service` is designed to provide the standard interfaces and endpoint to handle the events sent to/from a SaaS Control Plane. This acts as a orchestrator for the event targets/processors.
28
+
The `@sourceloop/ctrl-plane-orchestrator-service` is designed to provide standard interfaces and endpoints to handle events sent to/from a SaaS Control Plane. This service acts as an orchestrator for event targets/processors, enabling event-driven architecture patterns for multi-tenant SaaS applications.
29
+
30
+
### Key Features
31
+
32
+
-**Event Orchestration**: Central hub for processing events from various SaaS control plane services
33
+
-**Message Bus Integration**: Built-in support for multiple message buses (AWS EventBridge, SQS, BullMQ) via [loopback4-message-bus-connector](https://github.com/sourcefuse/loopback4-message-bus-connector)
34
+
-**Extensible Provider Pattern**: Override default providers for custom business logic
35
+
-**Standard Event Types**: Pre-defined event types for tenant provisioning and deployment workflows
36
+
-**OpenAPI Documentation**: Comprehensive API documentation for easy integration
26
37
27
-
Consider the following example architecture that uses Amazon EventBridge at the center to pass on the events, and this Orchestrator service is used as its initial target, so that the events can then be sent to the expected candidates to process the event.
38
+
### Architecture
39
+
40
+
Consider the following example architecture that uses Amazon EventBridge at the center to pass events, with the Orchestrator service as the initial target. Events can be sent to expected candidates for processing:
28
41
29
42

30
43
31
-
Above example is of a tenant provisioning event flow, as shown it originates from a control plane service called tenant management service and then when it's received to the Amazon EventBridge, it passes it to the orchestrator service which can run any bussiness logic before it's sent for processing (the example illustrates starting the codebuild or jenkins job conditionally based on the event). Further code examples in this README will take this same reference.
44
+
The above example shows a tenant provisioning event flow. It originates from a control plane service called tenant management service, is received by Amazon EventBridge, and then passed to the orchestrator service which can run business logic before sending it for processing (e.g., starting CodeBuild or Jenkins jobs conditionally based on the event).
32
45
33
46
## Installation
34
47
@@ -38,14 +51,14 @@ npm i @sourceloop/ctrl-plane-orchestrator-service
38
51
39
52
## Getting Started
40
53
41
-
You can start using `@sourceloop/ctrl-plane-orchestrator-service` in just 4 steps:
54
+
You can start using `@sourceloop/ctrl-plane-orchestrator-service` in just 2 steps:
42
55
43
56
1.[Bind Component](#bind-component)
44
57
2.[Implement Consumers](#implement-consumers)
45
58
46
59
### Bind Component
47
60
48
-
Bind the `OrchestratorServiceComponent` to your application constructor as shown below, this will load the built-in artifacts provided by the service in your application to use.
61
+
Bind the `OrchestratorServiceComponent` to your application constructor as shown below. This will load the built-in artifacts provided by the service in your application to use.
@@ -60,26 +73,29 @@ export class MyApplication extends BootMixin(
60
73
}
61
74
```
62
75
63
-
This microservice uses [message-bus-connector](https://github.com/sourcefuse/loopback4-message-bus-connector)component for consuming the events triggered through the [tenant-managenet](https://www.npmjs.com/package/@sourceloop/ctrl-plane-tenant-management-service) microservice. It supports multiple message buses.
76
+
This microservice uses [loopback4-message-bus-connector](https://github.com/sourcefuse/loopback4-message-bus-connector) for consuming events triggered through services like [tenant-management-service](https://www.npmjs.com/package/@sourceloop/ctrl-plane-tenant-management-service). It supports multiple message buses including AWS EventBridge, SQS, and BullMQ.
64
77
65
-
#### Usage
78
+
###Default Event Types
66
79
67
-
Bind the `EventStreamConnectorComponent` to your application constructor as shown below.
68
-
This will load the built-in artifacts provided by the Message Bus Connector, enabling event publishing and consumption across different backends like EventBridge, SQS, or BullMQ.
80
+
The service provides the following default event types that can be consumed:
69
81
70
-
```ts
71
-
this.component(EventStreamConnectorComponent);
72
-
```
82
+
| Event Type | Description |
83
+
|------------|-------------|
84
+
|`TENANT_PROVISIONING`| Triggered when a new tenant is being provisioned |
85
+
|`TENANT_DEPROVISIONING`| Triggered when a tenant is being deprovisioned |
86
+
|`TENANT_PROVISIONING_SUCCESS`| Triggered when tenant provisioning succeeds |
87
+
|`TENANT_PROVISIONING_FAILURE`| Triggered when tenant provisioning fails |
88
+
|`TENANT_DEPLOYMENT`| Triggered when tenant deployment starts |
89
+
|`TENANT_DEPLOYMENT_SUCCESS`| Triggered when tenant deployment succeeds |
90
+
|`TENANT_DEPLOYMENT_FAILURE`| Triggered when tenant deployment fails |
73
91
74
92
### Implement Consumers
75
93
76
-
Each event type can have one or more Consumers, responsible for reacting to specific messages from the message bus.
77
-
Use the @consumer decorator to register them automatically.
78
-
Follow the example as below:
94
+
Each event type can have one or more Consumers, responsible for reacting to specific messages from the message bus. Use the `@consumer` decorator to register them automatically.
The component includes the following providers that can be overridden:
116
+
117
+
-**`OrchestratorServiceBindings.TIER_DETAILS_PROVIDER`**: Provider for fetching tier-specific details. Override this to supply custom logic for retrieving tier configuration.
The service supports the following environment variables (see `.env.example`):
155
+
156
+
```bash
157
+
NODE_ENV=development
158
+
LOG_LEVEL=info
159
+
```
160
+
161
+
Additional configuration for the message bus connector should be set up according to the [loopback4-message-bus-connector documentation](https://github.com/sourcefuse/loopback4-message-bus-connector).
162
+
97
163
## Example Implementations
98
164
99
-
For more detailed implementation examples, environment setup, and message bus usage (EventBridge, BullMQ, SQS),
100
-
please refer to [sandbox](https://github.com/sourcefuse/arc-saas-sandbox) application.
165
+
For more detailed implementation examples, environment setup, and message bus usage (EventBridge, BullMQ, SQS), please refer to the [sandbox](https://github.com/sourcefuse/arc-saas-sandbox) application.
166
+
167
+
## API Documentation
168
+
169
+
The service provides comprehensive API documentation via OpenAPI specification:
170
+
171
+
-**OpenAPI Spec**: See [openapi.md](./openapi.md) for detailed API documentation
172
+
-**Available Endpoints**:
173
+
-`GET /` - Home page with service information
174
+
-`GET /ping` - Health check endpoint
101
175
102
176
## Deployment
103
177
104
-
The @sourceloop/ctrl-plane-orchestrator-service can be deployed in various ways, including as a serverless application. Here's how you can set it up for serverless deployment, specifically for AWS Lambda.
178
+
The `@sourceloop/ctrl-plane-orchestrator-service` can be deployed in various ways, including as a serverless application. Here's how you can set it up for serverless deployment on AWS Lambda.
105
179
106
180
### Serverless Deployment
107
181
108
-
To deploy this service as a serverless application on AWS Lambda, follow these steps:
109
-
110
-
1. Add a `lambda.ts` file in your `src` directory. This file will serve as the Lambda entry point:
182
+
1. Add a `lambda.ts` file in your `src` directory as the Lambda entry point:
6. Configure an API Gateway to trigger your Lambda function.
175
247
176
-
This setup allows you to run your Orchestrator Service as a serverless application, leveraging AWS Lambda's scalability and cost-efficiency.
177
-
Remember to adjust your Lambda function's configuration (memory, timeout, etc.) based on your specific needs.
178
-
179
-
### API Documentation
180
-
181
-
#### API Details
182
-
183
-
Visit the [OpenAPI spec docs](./openapi.md) for more details on the APIs provided in this service.
248
+
This setup allows you to run your Orchestrator Service as a serverless application, leveraging AWS Lambda's scalability and cost-efficiency. Adjust your Lambda function's configuration (memory, timeout, etc.) based on your specific needs.
0 commit comments