Cloud Native Programming with Golang
eBook - ePub

Cloud Native Programming with Golang

Mina Andrawos, Martin Helmich, Jelmer Snoeck

Buch teilen
  1. 404 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Cloud Native Programming with Golang

Mina Andrawos, Martin Helmich, Jelmer Snoeck

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Discover practical techniques to build cloud-native apps that are scalable, reliable, and always available.

Key Features

  • Build well-designed and secure microservices. Enrich your microservices with continous integration and monitoring.
  • Containerize your application with Docker
  • Deploy your application to AWS. Learn how to utilize the powerful AWS services from within your application

Book Description

Awarded as one of the best books of all time by BookAuthority, Cloud Native Programming with Golang will take you on a journey into the world of microservices and cloud computing with the help of Go.

Cloud computing and microservices are two very important concepts in modern software architecture. They represent key skills that ambitious software engineers need to acquire in order to design and build software applications capable of performing and scaling. Go is a modern cross-platform programming language that is very powerful yet simple; it is an excellent choice for microservices and cloud applications. Go is gaining more and more popularity, and becoming a very attractive skill.

This book starts by covering the software architectural patterns of cloud applications, as well as practical concepts regarding how to scale, distribute, and deploy those applications. You will also learn how to build a JavaScript-based front-end for your application, using TypeScript and React. From there, we dive into commercial cloud offerings by covering AWS. Finally, we conclude our book by providing some overviews of other concepts and technologies that you can explore, to move from where the book leaves off.

What you will learn

  • Understand modern software applications architectures
  • Build secure microservices that can effectively communicate with other services
  • Get to know about event-driven architectures by diving into message queues such as Kafka, Rabbitmq, and AWS SQS.
  • Understand key modern database technologies such as MongoDB, and Amazon's DynamoDB
  • Leverage the power of containers
  • Explore Amazon cloud services fundamentals
  • Know how to utilize the power of the Go language to access key services in the Amazon cloud such as S3, SQS, DynamoDB and more.
  • Build front-end applications using ReactJS with Go
  • Implement CD for modern applications

Who this book is for

This book is for developers who want to begin building secure, resilient, robust, and scalable Go applications that are cloud native. Some knowledge of the Go programming language should be sufficient.To build the front-end application, you will also need some knowledge of JavaScript programming.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Cloud Native Programming with Golang als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Cloud Native Programming with Golang von Mina Andrawos, Martin Helmich, Jelmer Snoeck im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Programming Languages. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2017
ISBN
9781787127968

AWS II–S3, SQS, API Gateway, and DynamoDB

In this chapter, we'll continue covering the massive topic of Amazon Web Services. In this chapter, we'll cover the S3 service, SQS service, AWS API Gateway service, and DynamoDB service. Every single one of these services is a powerful tool in your arsenal to build production applications deployed on the cloud.
We will cover the following topics in this chapter:
  • The AWS S3 storage service
  • The SQS message queue service
  • The AWS API gateway service
  • The DynamoDB database service

Simple Storage Service (S3)

Amazon S3 is an AWS service responsible for storing and analyzing data. The data typically includes files of all sorts and shapes (including music files, photos, text files, and video files). S3, for example, can be utilized to store code files for static data. Let's take a tour of how to use the S3 service in AWS.

Configuring S3

The S3 service stores files in buckets. Each bucket can hold files directly or can include a number of folders, and, in turn, each folder can hold a number of files.
We will use the AWS web console to configure S3, similar to what we did with EC2. The first step will be to navigate to the AWS web console and then select S3:
This will open the Amazon S3 console; from there, we can click on Create bucket to create a new bucket to store data folders:
This will start a wizard that will walk you through the different steps needed to properly create a bucket. This will give you the power to set the bucket name, enable versioning or logging, set tags, and set permissions. Once done, a new bucket will get created for you. The bucket name has to be unique so that it won't get conflicted with buckets used by other AWS users.
I created a bucket called mnandbucket; it will show up in the list of buckets in my S3 main web page. If you have more buckets than what the page can show, you can search for buckets in the search bar:
Once we enter a bucket, we can then create folders and upload files:
Perfect! With that, we have a practical idea of what S3 is about.
You can download this file from https://www.packtpub.com/sites/default/files/downloads/CloudNativeprogrammingwithGolang_ColorImages.pdf.
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Cloud-Native-Programming-with-Golang.
S3 storage can be utilized to store our application files for later use. So, for example, say we built our events microservice to run in a Linux environment, and the filename for the application is simply events. We can then simply store the file in an S3 folder; then, whenever we need an EC2 instance to obtain the file, we can use the AWS command-line tools in the Ec2 instance to achieve that.
We first need to ensure that the AWS roles are properly defined to allow our EC2 instance to access the S3 storage as was covered earlier. Then, from there, to copy the file from S3 to our EC2 instance, we will need to issue the following command from our EC2 instance:
aws s3 cp s3://<my_bucket>/<my_folder>/events my_local_events_copy
The preceding command will retrieve the events file from the S3 storage, then copy it to a new file called my_local_events_copy, which will live in the current folder. <my_bucket> and <my_folder> represent the bucket and the folder where the events file exists on the S3 storage, respectively.
After we copy an executable file to EC2, we will need to give it access to execute via the Linux chmod command. This is achieved utilizing the following command:
chmod u+x <my_executable_file>
In the preceding command, <my_executable_file> is the file that we would like to obtain enough access in our EC2 instance to execute.

Simple Queue Service (SQS)

As mentioned earlier, SQS is the message queue provided by AWS. Applications that can interact with SQS can send and receive messages within the AWS ecosystem.
Let's start by discussing how to configure an SQS from the Amazon console. As usual, the first step is to log in to the Amazon console and then select our service from the main dashboard. The service name in this case will be called Simple Queue Service:
From there, we will need to either click on Getting started or on Create New Queue. The queue creation page will offer us the ability to configure the behavior of the new queue. For example, we can set the maximum message size allowed, the number of days we can retain a message, or even the wait time to receive a message:
Once you are satisfied with your settings, click on Create Queue—I picked the name eventqueue.
This will create a new AWS SQS queue that we can utilize in our code. Now, it's time to discuss how we can write code to interact with our new queue.
Perfect! With our queue created, we are ready to write some code to send and receive messages via the newly created AWS SQS queue. Let's start with exploring the code we need to write in order to send some data.
The docs for the AWS SDK Go SQS package can be found at https://godoc.org/github.com/aws/aws-sdk-go/service/sqs.
As any other AWS service, there are two first key steps we will need to get out of the way:
  • Obtaining or creating a session object
  • Creating a service client for our desired AWS service
The preceding steps are covered via the following code:
 sess, err := session.NewSession(&aws.Config{
Region: aws.String("us-west-1"),
})
if err != nil {
log.Fatal(err)
}
sqsSvc := sqs.New(sess)
The preceding code sets the region via the code when calling the NewSession() constructor; however, we have the choice to use a shared configuration instead, as mentioned in the preceding chapter. I made use of log.Fatal() in this code since it's only testing code, so if anything fails, I would want to exit with the error message reported.
Next, we will need to obtain the message queue URL. The URL is important because it serves as a unique identifier for the message queue in the SDK method calls. We can obtain the URL either from the AWS console SQS page, where the URL of our queue will show in the Details tab when the queue is selected or via code by utilizing the queue name we chose when creating our queue. In my case, I called my queue eventqueue; so, let's take a look at how we can obtain the URL from that name through our code:
 QUResult, err := sqsSvc.GetQueueUrl(&sqs.GetQueueUrlInput{
QueueName: aws.String("eventqueue"),
})
if err != nil {
log.Fatal(err)
}
The QUResult object is of the *GetQueueUrlOutput type, which is a pointer to a struct that contains a field called QueueUrl of the *string type. This field should have our queue URL if the GetQu...

Inhaltsverzeichnis