[SI] Balleria 簡介

進行系統整合時, 通當會以3 tier 形式實現. 當條件發動(e.g. API called 或文件夾有檔案)時, 透過中介軟件(middleware) 叫用對方執行有關一系列指令. 從而達到效果. 但Middleware 那一層, 通常都不能夠General purpose 地共用, 因而會有類似動作但須要叫用不用middleware 發生. 而Ballerina 則可以解決這問題.

Ballerina 是一種Dataflow programming language 進行類似IFTTT (IF This Then That) 的動作. 相對其他middleware 架構, 其serverless 設計可以於runtime 時才建立service 可有效減低成本及保安漏洞.

而其官方IDE 是web 介面, 透過執行以下指令叫用:

%BallerinaRoot%/bin/composer

官方IDE 最大特色是它會建立sequence diagram, 可直觀地見到流程; 若不想使用web 介面的話, IntelliJ 亦有官方plugin可用.

以下是一個 利用 Ballerina 寫HelloWorld Service 的例子:

package helloWorldService;

import ballerina.net.http;

@http:configuration {basePath:"/hello"}
service<http> helloWorld {

    @http:resourceConfig {
        methods:["GET"],
        path:"/"
    }
    resource sayHello (http:Request req, http:Response resp) {
        resp.setStringPayload("Hello, World!");
        _ = resp.send();
    }
}

雖然 Ballerina 提供了實用的功能, 但始終是一門新的語言, 暫且觀望一下會否被其他取代到吧!!!

參考資料

  1. Ballerina
    https://ballerinalang.org/
  2. Ballerina Services in Serverless World, Isuru Perera, Medium,
    https://medium.com/@chrishantha/ballerina-services-in-serverless-world-b54c5e7382a0
  3. Have your first dance with Ballerina, Heshan Molligoda, Medium, 
    https://medium.com/@hpmolligoda/have-your-first-dance-with-ballerina-587cf639b2f7
  4. A Reference Architecture for Deploying WSO2 Middleware on Kubernetes,  Imesh Gunaratn, DZone,
    https://dzone.com/articles/a-reference-architecture-for-deploying-wso2-middle?fromrel=true
About C.H. Ling 260 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.