Skip to content

Commit 8e30d9f

Browse files
committed
docs(all-services): update the readme
GH-00
1 parent 473f361 commit 8e30d9f

3 files changed

Lines changed: 1034 additions & 954 deletions

File tree

services/orchestrator-service/README.md

Lines changed: 95 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,30 @@
1818
<a href="https://loopback.io/" target="_blank">
1919
<img alt="Pb Loopback" src="https://img.shields.io/badge/Powered%20by-Loopback 4-brightgreen" />
2020
</a>
21+
<a href="https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V22.md" target="_blank">
22+
<img alt="Node version" src="https://img.shields.io/badge/node-%3E%3D22%20%7C%7C%2024-brightgreen" />
23+
</a>
2124
</p>
2225

2326
## Overview
2427

25-
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
2637

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:
2841

2942
![Example Architecture with Orchestrator Service in Use](./docs/orchestrator.png)
3043

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).
3245

3346
## Installation
3447

@@ -38,14 +51,14 @@ npm i @sourceloop/ctrl-plane-orchestrator-service
3851

3952
## Getting Started
4053

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:
4255

4356
1. [Bind Component](#bind-component)
4457
2. [Implement Consumers](#implement-consumers)
4558

4659
### Bind Component
4760

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.
4962

5063
```ts
5164
import {OrchestratorServiceComponent} from '@sourceloop/ctrl-plane-orchestrator-service';
@@ -60,26 +73,29 @@ export class MyApplication extends BootMixin(
6073
}
6174
```
6275

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.
6477

65-
#### Usage
78+
### Default Event Types
6679

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:
6981

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 |
7391

7492
### Implement Consumers
7593

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.
7995

8096
```ts
8197
import {consumer, IConsumer, QueueType} from 'loopback4-message-bus-connector';
82-
import {DefaultEventTypes} from '@arc-saas/orchestrator-service';
98+
import {DefaultEventTypes} from '@sourceloop/ctrl-plane-orchestrator-service';
8399
import {AnyObject} from '@loopback/repository';
84100

85101
@consumer
@@ -94,20 +110,76 @@ export class TenantDeploymentConsumer implements IConsumer<AnyObject, string> {
94110
}
95111
```
96112

113+
### Service Providers
114+
115+
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.
118+
119+
```ts
120+
import {OrchestratorServiceBindings} from '@sourceloop/ctrl-plane-orchestrator-service';
121+
122+
export class CustomTierDetailsProvider implements Provider<TierDetailsFn> {
123+
value() {
124+
return async (tier: string) => {
125+
// Your custom implementation
126+
return {
127+
jobIdentifier: `${tier}-custom-job`,
128+
// Additional tier details
129+
};
130+
};
131+
}
132+
}
133+
134+
// In your application constructor:
135+
this.bind(OrchestratorServiceBindings.TIER_DETAILS_PROVIDER).toProvider(CustomTierDetailsProvider);
136+
```
137+
138+
- **`OrchestratorServiceBindings.BUILDER_SERVICE`**: Service for starting CI/CD jobs. Override this to integrate with your build system.
139+
140+
```ts
141+
export class CustomBuilderService implements BuilderServiceInterface {
142+
async startJob(jobIdentifier: string, params: AnyObject): Promise<void> {
143+
// Your custom implementation for starting jobs
144+
// e.g., trigger Jenkins, AWS CodeBuild, etc.
145+
}
146+
}
147+
148+
// In your application constructor:
149+
this.bind(OrchestratorServiceBindings.BUILDER_SERVICE).toClass(CustomBuilderService);
150+
```
151+
152+
## Configuration
153+
154+
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+
97163
## Example Implementations
98164

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
101175

102176
## Deployment
103177

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.
105179

106180
### Serverless Deployment
107181

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:
111183

112184
```typescript
113185
import {APIGatewayEvent, APIGatewayProxyEvent, Context} from 'aws-lambda';
@@ -173,14 +245,7 @@ docker build -t orchestrator-service .
173245

174246
6. Configure an API Gateway to trigger your Lambda function.
175247

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.
184249

185250
## License
186251

0 commit comments

Comments
 (0)