Book Image

Hands-On Swift 5 Microservices Development

Book Image

Hands-On Swift 5 Microservices Development

Overview of this book

The capabilities of the Swift programming language are extended to server-side development using popular frameworks such as Vapor. This enables Swift programmers to implement the microservices approach to design scalable and easy-to-maintain architecture for iOS, macOS, iPadOS, and watchOS applications. This book is a complete guide to building microservices for iOS applications. You’ll start by examining Swift and Vapor as backend technologies and compare them to their alternatives. The book then covers the concept of microservices to help you get started with developing your first microservice. Throughout this book, you’ll work on a case study of writing an e-commerce backend as a microservice application. You’ll understand each microservice as it is broken down into details and written out as code throughout the book. You’ll also become familiar with various aspects of server-side development such as scalability, database options, and information flow for microservices that are unwrapped in the process. As you advance, you’ll get to grips with microservices testing and see how it is different from testing a monolith application. Along the way, you’ll explore tools such as Docker, Postman, and Amazon Web Services. By the end of the book, you’ll be able to build a ready-to-deploy application that can be used as a base for future applications.
Table of Contents (19 chapters)

What this book covers

Chapter 1, Introduction of Microservices, starts off the book by introducing the concept of microservices and how they are used. Besides the concept itself, some real-life examples are examined and used to illustrate the value of microservices.

Chapter 2, Understanding Server-Side Swift, deals with the current state of Swift on the server, taking a deep look into the internals of Swift and its appeal for server development. The unique features of Swift 5 are also addressed in light of server development.

Chapter 3, Getting Started with the Vapor Framework, introduces Vapor as the leading framework for server-side Swift, exploring how Vapor operates and what Vapor applications look like.

Chapter 4, Planning an Online Store Application, starts the process of writing our example backend for an e-commerce app. We will plan it to demonstrate how microservice applications should be planned.

Chapter 5, Creating Your First Microservice, guides you on how to develop your first microservice. We will write a template service that we can use to develop the services of our demo application.

Chapter 6, Application Structure and Database Design, walks you through setting your system up for microservices, taking a quick look at Docker environments. How to run microservices is also discussed to allow easy microservice development.

Chapter 7, Writing the User Service, begins to put everything together by writing the first service of our e-commerce backend. A user service serves as the central user authority to verify users and in this chapter, we go into a detailed discussion about what this looks like.

Chapter 8, Testing Microservices, deals with the concept of testing microservices and how that is best done. We will look into unit and functional testing and which is used when.

Chapter 9, Product Management Service, covers writing our second microservice for the backend. Products are a central element in e-commerce and this chapter discusses what a service for such objects looks like.

Chapter 10, Understanding Microservices Communication, explains that when our microservices need to communicate, we want to maintain some rules. In this chapter, we look at what, exactly, inner microservice communication should look like and what to avoid.

Chapter 11, Order Management Service, uses the knowledge from the previous chapters to write a service that actually communicates with other services. We also address how external services can be integrated.

Chapter 12, Best Practices, discusses some general best practices for Swift, but specifically for microservices.

Chapter 13, Hosting Microservices, deals with the fact that hosting microservice applications is not the most trivial task. In this chapter, we explore what hosting microservice applications look like and what we need to do so.

Chapter 14, Docker and the Cloud, follows on from learning about the general hosting of microservices by looking at which cloud providers enable us to do it and how.

Chapter 15, Deploying Microservices in the Cloud, covers bringing our example backend online. We will walk through the entire setup on AWS ECS and will then set up a Continuous Deployment (CD) to automatically deploy our code.

Chapter 16, Scaling and Monitoring Microservices, discusses how we can scale microservices in cloud setups. We will take a look at the most common cloud providers and their strategies.