a cluster manager that controls a docker swarm. It is controlled remotely by cloudly.
Go to file
2024-05-09 00:05:16 +02:00
.vscode fix(core): update 2024-05-09 00:05:16 +02:00
test fix(core): update 2024-05-09 00:05:16 +02:00
ts fix(core): update 2024-05-09 00:05:16 +02:00
.dockerignore fix(core): update 2024-05-09 00:05:16 +02:00
.gitignore fix(core): update 2024-05-09 00:05:16 +02:00
cli.child.ts fix(core): update 2024-05-09 00:05:16 +02:00
cli.js fix(core): update 2024-05-09 00:05:16 +02:00
cli.ts.js fix(core): update 2024-05-09 00:05:16 +02:00
Dockerfile fix(core): update 2024-05-09 00:05:16 +02:00
license fix(core): update 2024-05-09 00:05:16 +02:00
npmextra.json fix(core): update 2024-05-09 00:05:16 +02:00
package.json fix(core): update 2024-05-09 00:05:16 +02:00
pnpm-lock.yaml fix(core): update 2024-05-09 00:05:16 +02:00
qenv.yml fix(core): update 2024-05-09 00:05:16 +02:00
readme.hints.md fix(core): update 2024-05-09 00:05:16 +02:00
readme.md fix(core): update 2024-05-09 00:05:16 +02:00
tsconfig.json fix(core): update 2024-05-09 00:05:16 +02:00

@servezone_private/coreflow

A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.

Install

To install @servezone_private/coreflow, you can use npm with the following command:

npm install @servezone_private/coreflow --save

Given that this is a private package, make sure you have access to the required npm registry and that you are authenticated properly.

Usage

Coreflow is designed as an advanced tool for managing Docker-based applications and services, enabling efficient scaling across servers, and handling multiple aspects of service provisioning and network traffic management. Below are examples and explanations to illustrate its capabilities and how you can leverage Coreflow in your infrastructure. Note that these examples are based on TypeScript and use ESM syntax.

Prerequisites

Before you start, ensure you have Docker and Docker Swarm configured in your environment as Coreflow operates on top of these technologies. Additionally, verify that your environment variables are properly set up for accessing Coreflow's functionalities.

Setting Up Coreflow

To get started, you need to import and initialize coreflow within your application. Here's an example of how to do this in a TypeScript module:

import { Coreflow } from '@servezone_private/coreflow';

// Initialize Coreflow
const coreflowInstance = new Coreflow();

// Start Coreflow
await coreflowInstance.start();

// Example: Add your logic here for handling Docker events
coreflowInstance.handleDockerEvents().then(() => {
  console.log('Docker events are being handled.');
});

// Stop Coreflow when done
await coreflowInstance.stop();

Configuring Service Connections

Coreflow manages applications and services, often requiring direct interactions with other services like a database, message broker, or external API. Coreflow simplifies these connections through its configuration and service discovery layers.

// Assuming coreflowInstance is already started as per previous examples
const serviceConnection = coreflowInstance.createServiceConnection({
  serviceName: "myDatabaseService",
  servicePort: 3306
});

serviceConnection.connect().then(() => {
  console.log('Successfully connected to the service');
});

Scaling Your Application

Coreflow excels in scaling applications across multiple servers. This involves not just replicating services, but also ensuring they are properly networked, balanced, and monitored.

const scalingPolicy = {
  serviceName: "apiService",
  replicaCount: 5, // Target number of replicas
  maxReplicaCount: 10, // Maximum number of replicas
  minReplicaCount: 2, // Minimum number of replicas
};

coreflowInstance.applyScalingPolicy(scalingPolicy).then(() => {
  console.log('Scaling policy applied successfully.');
});

Managing Network Traffic

One of Coreflow's key features is its ability to manage network traffic, ensuring that it is efficiently distributed among various services based on load, priority, and other custom rules.

import { TrafficRule } from '@servezone_private/coreflow';

const rule: TrafficRule = {
  serviceName: "webService",
  externalPort: 80,
  internalPort: 3000,
  protocol: "http",
};

coreflowInstance.applyTrafficRule(rule).then(() => {
  console.log('Traffic rule applied successfully.');
});

Continuous Deployment

Coreflow integrates continuous integration and deployment processes, allowing seamless updates and rollbacks for your services:

const deploymentConfig = {
  serviceName: "userAuthService",
  image: "myregistry.com/userauthservice:latest",
  updatePolicy: "rolling" // or "recreate"
};

coreflowInstance.deployService(deploymentConfig).then(() => {
  console.log('Service deployed successfully.');
});

Observability and Monitoring

To keep track of your applications' health and performances, Coreflow provides tools for logging, monitoring, and alerting.

coreflowInstance.monitorService("webService").on('serviceHealthUpdate', (healthStatus) => {
  console.log(`Received health update for webService: ${healthStatus}`);
});

By following these examples, you can utilize Coreflow to manage Docker-based applications, ensuring scalability, reliability, and efficiency across your infrastructure. undefined