SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Cloud Native Programming Language that Makes it Easy
to Write Microservices that Integrate APIs
Christopher Davey
April 2019
Increasing demand is causing disaggregation
Everything is
An Endpoint
Functions
APIs
Data
SaaS apps
Legacy apps
Devices
Disaggregation leads to more endpoints
Integration in an increasingly disaggregated world
Transactions
Circuit Breaking
Protocols
Payloads
Events
Security
Workflow
Streams
Compensation
ESB, BPMN, EAI
Java / Spring
JavaScript / Node
The
Integration
Gap
ESB, BPMN, EAI
Java / Spring
JavaScript / Node
AGILE
INTEGRATION SIMPLE
Microservice with RESTful API
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) {
...
Service Composition
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);
GMail-Google Sheets Integration
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;
}
Network Abstractions
● 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
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.
Network-aware Type System
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
Basic types and other types
○ Other types
○ Unions
○ Optional
○ json
○ byte
○ anydata
○ any
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)
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;
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 }
]
};
Sequence Diagram
Microservice Deployment
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"
}
● 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
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
THANK YOU

Contenu connexe

Tendances

JSON Rules Language
JSON Rules LanguageJSON Rules Language
JSON Rules Language
giurca
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
Hiroshi Nakamura
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
Bo-Yi Wu
 

Tendances (20)

JSON Rules Language
JSON Rules LanguageJSON Rules Language
JSON Rules Language
 
RESTful Web API and MongoDB go for a pic nic
RESTful Web API and MongoDB go for a pic nicRESTful Web API and MongoDB go for a pic nic
RESTful Web API and MongoDB go for a pic nic
 
Eve - REST API for Humans™
Eve - REST API for Humans™Eve - REST API for Humans™
Eve - REST API for Humans™
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
Ruby HTTP clients
Ruby HTTP clientsRuby HTTP clients
Ruby HTTP clients
 
"The little big project. From zero to hero in two weeks with 3 front-end engi...
"The little big project. From zero to hero in two weeks with 3 front-end engi..."The little big project. From zero to hero in two weeks with 3 front-end engi...
"The little big project. From zero to hero in two weeks with 3 front-end engi...
 
Serverless Ballerina
Serverless BallerinaServerless Ballerina
Serverless Ballerina
 
New Features in PHP 5.3
New Features in PHP 5.3New Features in PHP 5.3
New Features in PHP 5.3
 
Android and REST
Android and RESTAndroid and REST
Android and REST
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Socket.io
Socket.ioSocket.io
Socket.io
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
Windows PowerShell
Windows PowerShellWindows PowerShell
Windows PowerShell
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overview
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
The Functional Web
The Functional WebThe Functional Web
The Functional Web
 
Synapseindia dot net development web applications with ajax
Synapseindia dot net development  web applications with ajaxSynapseindia dot net development  web applications with ajax
Synapseindia dot net development web applications with ajax
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat Application
 

Similaire à [WSO2 Integration Summit Madrid 2019] Integration + Ballerina

Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
Ismael Celis
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
Michael Peacock
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwr
deimos
 

Similaire à [WSO2 Integration Summit Madrid 2019] Integration + Ballerina (20)

[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
 
Rpi python web
Rpi python webRpi python web
Rpi python web
 
Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)
 
Ajax - a quick introduction
Ajax - a quick introductionAjax - a quick introduction
Ajax - a quick introduction
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On Rails
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Top 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformTop 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platform
 
Tools for Making Machine Learning more Reactive
Tools for Making Machine Learning more ReactiveTools for Making Machine Learning more Reactive
Tools for Making Machine Learning more Reactive
 
Data models in Angular 1 & 2
Data models in Angular 1 & 2Data models in Angular 1 & 2
Data models in Angular 1 & 2
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programming
 
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwr
 
Intro to Node
Intro to NodeIntro to Node
Intro to Node
 
Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400
 
08 ajax
08 ajax08 ajax
08 ajax
 

Plus de WSO2

Plus de WSO2 (20)

Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
WSO2CON 2024 - Elevating the Integration Game to the Cloud
WSO2CON 2024 - Elevating the Integration Game to the CloudWSO2CON 2024 - Elevating the Integration Game to the Cloud
WSO2CON 2024 - Elevating the Integration Game to the Cloud
 
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
 
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital Businesses
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

[WSO2 Integration Summit Madrid 2019] Integration + Ballerina

  • 1. Cloud Native Programming Language that Makes it Easy to Write Microservices that Integrate APIs Christopher Davey April 2019
  • 2. Increasing demand is causing disaggregation
  • 3. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps Devices Disaggregation leads to more endpoints
  • 4. Integration in an increasingly disaggregated world Transactions Circuit Breaking Protocols Payloads Events Security Workflow Streams Compensation
  • 5. ESB, BPMN, EAI Java / Spring JavaScript / Node
  • 6. The Integration Gap ESB, BPMN, EAI Java / Spring JavaScript / Node
  • 9.
  • 10. 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) { ...
  • 12. 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);
  • 14. 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; }
  • 16. ● 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
  • 17. 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.
  • 19. 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
  • 20. Basic types and other types ○ Other types ○ Unions ○ Optional ○ json ○ byte ○ anydata ○ any
  • 21. 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)
  • 22. 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;
  • 23. 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 } ] };
  • 25.
  • 26.
  • 28. 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" }
  • 29. ● 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
  • 30. 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