Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Protocol Buffers Handbook

You're reading from  Protocol Buffers Handbook

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781805124672
Pages 226 pages
Edition 1st Edition
Languages
Author (1):
Clément Jean Clément Jean
Profile icon Clément Jean

Table of Contents (13) Chapters

Preface Chapter 1: Serialization Primer Chapter 2: Protobuf is a Language Chapter 3: Describing Data with Protobuf Text Format Chapter 4: The Protobuf Compiler Chapter 5: Serialization Internals Chapter 6: Schema Evolution over Time Chapter 7: Implementing the Address Book in Go Chapter 8: Implementing the Address Book in Python Chapter 9: Developing a Protoc Plugin in Golang Chapter 10: Advanced Build Index Other Books You May Enjoy

Preface

In today’s distributed world, a lot of us are interacting with APIs. Usually, these APIs are REST APIs, which accept and return JSON. There are, however, alternatives to the bulky and hard-to-process JSON data format. The main alternative is Protobuf. This book’s goal is to teach you this more efficient data format in both theory and practice. From learning how to write proto files to learning how to write your own protoc plugin, passing by learning the internals of Protobuf serialization/deserialization, you will learn everything you need to know to become a Protobuf expert.

Who this book is for

This book is for both beginners and those who think that they already know how to use Protobuf. One of the main problems with Protobuf is that it looks simple on the surface, but becoming an expert takes a lot of time. Fortunately, I have condensed all my knowledge into this book, so you do not have to dig it up all by yourself. So, if you are interested in the internals of serialization/deserialization, how to use Protobuf for both small and large projects, and how to build tools around it, this book is for you.

What this book covers

Chapter 1, Serialization Primer, covers serialization and deserialization.

Chapter 2, Protobuf Is a Language, discusses Protobuf syntax.

Chapter 3, Describing Data with Protobuf Text Format, explains how and why to use Protobuf Text format.

Chapter 4, The Protobuf Compiler, discusses generating code and serializing/deserializing data with the compiler.

Chapter 5, Serialization Internals, explains every single part of the serialization/deserialization done by Protobuf.

Chapter 6, Schema Evolution over Time, covers how to evolve your Protobuf schema safely.

Chapter 7, Implementing an Address Book in Go, explains how to interact with generated code in Golang and build an address book.

Chapter 8, Implementing an Address Book in Python, explains how to interact with generated code in Python and build an address book.

Chapter 9, Developing a protoc Plugin in Go, shows you how to write a protoc plugin from scratch in Go.

Chapter 10, Advanced Build, covers the different ways to build your Protobuf projects.

To get the most out of this book

This book is in no way a Go or Python tutorial. You should be familiar with these languages before getting started. This will lower the mental load of having to learn both Protobuf and another programming language. I recommend you learn a bit of Go (see https://go.dev/learn/) since most of the code is in this language.

Software/hardware covered in the book

Operating system requirements

Python >= 3.10

Windows, macOS, or Linux

Go >= 1.21

Protoc >= 25.0

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Protocol-Buffers-Handbook. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “This should create a buf.yaml file in the proto directory.”

A block of code is set as follows:

syntax = "proto3";
message Encoding {
  int32 i32 = 1;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

type Person_PhoneNumber_Type int32
const (
  Person_PhoneNumber_TYPE_UNSPECIFIED  Person_PhoneNumber_Type = 0
  Person_PhoneNumber_TYPE_MOBILE  Person_PhoneNumber_Type = 1
  Person_PhoneNumber_TYPE_HOME  Person_PhoneNumber_Type = 2
  Person_PhoneNumber_TYPE_WORK  Person_PhoneNumber_Type = 3
)

Any command-line input or output is written as follows:

$ cat int32.txtpb | protoc --encode=Encoding encoding.proto | hexdump –C

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “The structure of the data is called the data format.”

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packtpub.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read Protocol Buffers Handbook, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?

Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

  1. Scan the QR code or visit the link below

https://packt.link/free-ebook/978-1-80512-467-2

  1. Submit your proof of purchase
  2. That’s it! We’ll send your free PDF and other benefits to your email directly
lock icon The rest of the chapter is locked
Next Chapter arrow right
You have been reading a chapter from
Protocol Buffers Handbook
Published in: Apr 2024 Publisher: Packt ISBN-13: 9781805124672
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}