This is a recurring newsletter of content around Ballerina and related technology topics such as integration, microservices, distributed systems, and cloud computing.
Issue #1 - March 3, 2021
Services and Network Communication in Swan Lake
Ballerina is built to inherently make network communication easier, by making networking concepts like client objects, services, resource functions, and listeners a part of the syntax. This allows you to use the language-provided constructs to write network programs that just work. The new Swan Lake release introduces many improvements around the services abstraction in the language, and in protocol implementations. Let’s look at some of these!
A Ballerina service’s structure and its semantics are defined by the type of the listener. An example of this is shown in the definition of an HTTP service below.
Read this DZone article on HTTP Deep-Dive with Ballerina: Services to learn the basics of creating an HTTP service and how Ballerina provides a convenient abstraction for defining complex operations.
Ballerina also has a first-class construct to create an HTTP client object and provide the necessary host and configuration information. Read this DZone article on HTTP Deep-Dive With Ballerina: Client Communication where we explore Ballerina’s feature-complete functionality that allows you to implement any HTTP client scenario.
WebSocket is another communication protocol, which is used for efficient full-duplex communication between web browsers and servers over TCP. It fulfills the requirements of dynamic websites while fixing shortcomings of techniques like HTTP. Ballerina’s easy-to-use networking abstractions can also be used to create WebSocket clients and services. Read this Hackernoon article on An Introduction to WebSockets with Ballerina to learn more.
GraphQL has become a prominent technology when implementing data APIs. It provides an efficient and intuitive approach for querying data over the network. It solves potential problems such as data over-fetching and network latency that can arise in a services-based solution. Ballerina provides built-in support for quickly and easily implementing GraphQL services, allowing users to concentrate on the business logic. Learn more in this DZone article on GraphQL Made Easy With Ballerina.
For network operations to function optimally, it’s critical to support non-blocking I/O-based communication. Ballerina has a unique concurrency model, based on a lightweight thread model, which supports user-space scheduling for concurrent executions. This makes it possible to implement an efficient non-blocking I/O functionality right from the language primitives. Dive into more details with this DZone article on Ballerina Concurrency Model and Non-Blocking I/O.
If you’d like to have a discussion with our engineering team on Ballerina concepts and how you can use it in your projects, join our next community call. In our previous call, we discussed in detail about Ballerina Swan Lake’s services and network communication. Sign up here to get notified.
We hope you found this information useful. We’ll catch you again soon!
If you wish to disable cookies you can do so from your browser.