Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

[WSO2 Integration Summit Madrid 2019] Integration + Ballerina

25 views

Published on

Increasingly, developers and architects are disaggregating their architectures to create more scalable and agile applications. As this happens, everything is becoming a programmable endpoint. Ballerina is a new programming language designed around this problem. This deck introduces the challenges and background of why Ballerina has been created, as well as demonstrate the core features of the language.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

[WSO2 Integration Summit Madrid 2019] Integration + Ballerina

  1. 1. Cloud Native Programming Language that Makes it Easy to Write Microservices that Integrate APIs Christopher Davey April 2019
  2. 2. Increasing demand is causing disaggregation
  3. 3. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps Devices Disaggregation leads to more endpoints
  4. 4. Integration in an increasingly disaggregated world Transactions Circuit Breaking Protocols Payloads Events Security Workflow Streams Compensation
  5. 5. ESB, BPMN, EAI Java / Spring JavaScript / Node
  6. 6. The Integration Gap ESB, BPMN, EAI Java / Spring JavaScript / Node
  7. 7. AGILE INTEGRATION SIMPLE
  8. 8. Microservice with RESTful API
  9. 9. import ballerina/http; listener http:Listener httpListener = new(9090); // RESTful service. @http:ServiceConfig { basePath: "/ordermgt" } service orderMgt on httpListener { // Resource that handles the HTTP GET requests that are directed to a specific @http:ResourceConfig { methods: ["GET"], path: "/order/{orderId}" } resource function findOrder(http:Caller caller, http:Request req, string orderId) { // Implementation } // Resource that handles the HTTP POST requests that are directed to the path @http:ResourceConfig { methods: ["POST"], path: "/order" } resource function addOrder(http:Caller caller, http:Request req) { ...
  10. 10. Service Composition
  11. 11. import ballerina/http; // Service endpoint listener http:Listener travelAgencyEP = new(9090); // Client endpoint to communicate with Airline reservation service http:Client airlineReservationEP = new("http://localhost:9091/airline"); ... // Travel agency service to arrange a complete tour for a user @http:ServiceConfig {basePath:"/travel"} service travelAgencyService on travelAgencyEP { ... // Send a post request to airline service with appropriate payload and get response http:Response inResAirline = check airlineReservationEP->post("/reserve", untaint outReqPayloadAirline);
  12. 12. GMail-Google Sheets Integration
  13. 13. gsheets4:Client spreadsheetClient = new({ clientConfig: { auth: { scheme: http:OAUTH2, config: { grantType: http:DIRECT_TOKEN, config: { accessToken: accessToken, refreshConfig: { clientId: clientId, clientSecret: clientSecret, refreshUrl: gsheets4:REFRESH_URL, refreshToken: refreshToken function getCustomerDetailsFromGSheet() returns string[][]|error { //Read all the values from the sheet. string[][] values = check spreadsheetClient->getSheetValues(spreadsheetId, sheetName); log:printInfo("Retrieved customer details from spreadsheet id: " + spreadsheetId + " ; sheet name: " + sheetName); return values; }
  14. 14. Network Abstractions
  15. 15. ● Endpoints: - Listener endpoints - For incoming network interactions - Protocols - HTTP/S - HTTP2 - GRPC - WebSocket - JMS .. - Client endpoints - For outgoing network interactions - HTTP. WebSub, GRPC - Database, FTP - Twitter, Salesforce Endpoints
  16. 16. https://ballerina.io/learn/by-example/ Ballerina by Example Ballerina by Example enables you to have complete coverage over the language, while emphasizing incremental learning. This is a series of commented example programs.
  17. 17. Network-aware Type System
  18. 18. Basic types and other types ○ Simple types ○ (), boolean, int, float, decimal, string ○ Structured types ○ tuple, array, map, record, table, xml ○ Behavioral types ○ error, function, future, object, stream, typedesc
  19. 19. Basic types and other types ○ Other types ○ Unions ○ Optional ○ json ○ byte ○ anydata ○ any
  20. 20. Union types ○ Type defined by union of two or more other types ○ Remember, a type is name for a set of values float | string v1 = "John"; float | string v2 = 457.68; float | string 0.51 1.01 457.68 -11.0 “John” “name” “” “bal” // The return type of 'post' is a union of 'http:Response' and 'error' http:Response | error response = orderEP -> post("/create", reqPayload)
  21. 21. XML // Simple XML literal xml x1 = xml`<name>Pol Katta</name>`; // XML with namespaces xmlns "http://wso2.com" as ns0; xml x2 = xml `<name id="123" status="single"> <ns0:fname>Pol</ns0:fname> <ns0:lname>Katta</ns0:lname> </name>`; // XML literal with interpolation string lastName = "Katta"; xml x3 = xml`<lname>${lastName}</lname>`; // Concat XML values xml x4 = x1 + x2 + x3;
  22. 22. JSON json is just a union - () | int | float | string | map<json> | json[] // JSON object json payload = { "orderdata" : { "id": 1, "name": "XYZ", "price": 2500 } }; //Access object values json orderid = payload.orderdata.id; //JSON arrays json orders = { "orderdata" : [ { "id": 1, "name": "XYZ", "price": 2500 }, { "id": 2, "name": "ABC", "price": 3000 } ] };
  23. 23. Sequence Diagram
  24. 24. Microservice Deployment
  25. 25. import ballerina/http; import ballerinax/docker; @docker:Config { registry:"ballerina.guides.io", name:"travel_agency_service", tag:"v1.0" } @docker:Expose{} listener http:Listener travelAgencyEP = new(9090); // http:Client endpoint definitions to communicate with other services @http:ServiceConfig {basePath:"/travel"} service travelAgencyService on travelAgencyEP { @kubernetes:Ingress { hostname:"ballerina.guides.io", name:"ballerina-guides-travel-agency-service", path:"/" } @kubernetes:Service { serviceType:"NodePort", name:"ballerina-guides-travel-agency-service" } @kubernetes:Deployment { image:"ballerina.guides.io/travel_agency_service:v1.0", name:"ballerina-guides-travel-agency-service" }
  26. 26. ● Ballerina natively understand Cloud Native platforms like Docker, Kubernetes and Istio. ● Ballerina removes gap between developers and Ops. ● Ballerina support agile development to deployment and improve productivity. Takeaways
  27. 27. How to get involved Learn more Open source Get support http://ballerina.io http://github.com/ballerina-platform/ Ballerina Dev Google Group Ballerina Slack Channel Stack Overflow #ballerina tag
  28. 28. THANK YOU

×