Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[New Feature]: Introduce a bal tool to support consolidating multiple services into a single executable #1331

Open
azinneera opened this issue Feb 5, 2025 · 7 comments · Fixed by #1334
Assignees
Labels
Area/Platform Relates to the Ballerina platform Type/NewFeature

Comments

@azinneera
Copy link
Contributor

Description

Ballerina inherently supports microservices-style deployments, which are well-suited for microservice orchestration platforms like Kubernetes. However, many enterprise users deploy on VMs or Docker, where managing each service as a separate process increases complexity and resource overhead. We must provide a solution tailored to such scenarios by enabling consolidated deployments.

Describe your problem(s)

For users who follow a monolith-style deployment, the following must be supported OOTB:

  • Allow multiple services to run as a single runtime process.
  • Facilitate easy deployment in Docker-based and VM environments.
  • Provide intuitive configuration through CLI options or a configuration file.

Describe your solution(s)

The goal is to allow developers to specify services to consolidate into a single runtime process. For this, we will introduce a bal tool to generate the code required to group multiple services into one deployable artifact.

The tool:

  • Parses the Ballerina.toml file to identify the services to consolidate
  • Generates the consolidated.bal file with the shared listener and the service packages imported.
  • Builds a single deployment artifact (e.g., .jar or Docker image) containing all the services and a Config.toml containing all configurable variables.

Features

  • Developers can create a consolidated package using the below command:
    bal new -t ballerina/consolidate myConsolidatedPkg

    This command creates a new Ballerina package with the consolidate tool added in the Ballerina.toml file as follows:

    [package]
    org = "myOrg"
    name = "myConsolidatedPkg"
    version = "0.1.0"
    
    [[tool.consolidate]]
    id = "consolidate1"
    options.services = ["myOrg/svc1", "myOrg/svc2"]  # modify the values with the services to consolidate
  • Developers can Generate a single deployment artifact by executing the below command:
    bal build [--cloud]

A few other name suggestion for the tool:

Suggested name Ballerina.toml syntax
merge [[tool.merge]]
bundle [[tool.bundle]]
integrate [[tool.integrate]]

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@azinneera azinneera self-assigned this Feb 5, 2025
@sameerajayasoma sameerajayasoma transferred this issue from ballerina-platform/ballerina-lang Feb 5, 2025
@sameerajayasoma sameerajayasoma added the Area/Platform Relates to the Ballerina platform label Feb 5, 2025
@sameerajayasoma
Copy link
Contributor

@azinneera, Can you make it a proposal?

@keizer619
Copy link
Member

@azinneera @sameerajayasoma From suggested names i prefer bundle

@azinneera
Copy link
Contributor Author

Meeting Notes - 11/02/2025
Attendees: @azinneera, @anuruddhal, @Dilhasha, @hasithaa, @sameerajayasoma, @shafreenAnfar, @keizer619

Summary

The following changes were suggested and agreed with:

  • Instead of using bal new command to create the consolidator package, let's introduce a bal tool with a custom command. (e.g. bal consolidate)
    • This custom command will accept the services as the input and create a new package with the services added to the Ballerina.toml
    • The main reason for introducing the command is to support UI-based low-code editors
  • Come up with a better name instead of consolidator

@azinneera
Copy link
Contributor Author

azinneera commented Feb 18, 2025

Based on the meeting notes, a new custom command will be introduced to facilitate the following:

  1. Create a new package with services to consolidate
  2. Add/Remove new services to an existing package

The details can be found in the proposal.

@azinneera @sameerajayasoma From suggested names i prefer bundle

My suggestion is also the same. @sameerajayasoma @shafreenAnfar WDYT?

@github-project-automation github-project-automation bot moved this from In Progress to Done in Ballerina Team Main Board Feb 26, 2025
@azinneera azinneera reopened this Feb 26, 2025
@shafreenAnfar
Copy link
Contributor

Based on the ChatGPT description below, I feel consolidate is better 😐. As per the below description bundle is like taking multiple files and grouping them together whereas consolidate is like merging multiple files into one creating one large file.

Bundle typically refers to grouping things together in a way that they are often kept together as a unit. The items may still be distinct in their nature, but are packaged or grouped together for convenience or efficiency. For example, you might bundle products together for sale or bundle services in a package.

Consolidate suggests combining things into a single, unified whole. It often involves reducing the number of separate entities or items into a more streamlined or efficient form. Consolidation tends to emphasize the act of making something stronger or more coherent. For instance, you might consolidate multiple bank accounts into one or consolidate efforts to achieve a shared goal.

@sameerajayasoma
Copy link
Contributor

IMO, it is tough to figure out a single word for this tool. All of the above suggestions are too generic. Can we allow <part1>-<part2> pattern for this tool name? That way, we can figure out a descriptive name.

This tool takes a list of Ballerina package names as the input. Then, It generates a new Ballerina package that imports all of them, combining multiple independently developed services (integrations) into a single deployable binary that shares the same HTTP listener. It creates a modular monolith or ESB-style server from separate integration components.

The challenge is to figure out a descriptive name :)

@azinneera
Copy link
Contributor Author

azinneera commented Feb 28, 2025

IMO, it is tough to figure out a single word for this tool. All of the above suggestions are too generic. Can we allow <part1>-<part2> pattern for this tool name? That way, we can figure out a descriptive name.

This tool takes a list of Ballerina package names as the input. Then, It generates a new Ballerina package that imports all of them, combining multiple independently developed services (integrations) into a single deployable binary that shares the same HTTP listener. It creates a modular monolith or ESB-style server from separate integration components.

The challenge is to figure out a descriptive name :)

I tried some other names with the help of DeepSeek and these are a few recommendations with the reason:

  1. bal bundle
    Why: Universally understood by developers (e.g., webpack "bundles" modules).
    Directly implies grouping services into a single deployable artifact.

  2. bal server
    Why: Simple and declarative. The output is a unified server.
    Matches Ballerina’s HTTP listener-centric design.

  3. bal composite
    Why: Matches the tool's behavior (combining services into a single structure)

monolith, unify and assemble were among the suggestions too.

I am still +1 for bundle. To make the name descriptive, we can name it bal service-bundle (e.g. bal service-bundle new myorg/svc1,myorg/svc2) but would it be only services that the user wants to bundle?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area/Platform Relates to the Ballerina platform Type/NewFeature
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants