Protocol Buffers Handbook - Clément Jean - E-Book

Protocol Buffers Handbook E-Book

Clément Jean

0,0
28,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Explore how Protocol Buffers (Protobuf) serialize structured data and provides a language-neutral, platform-neutral, and extensible solution. With this guide to mastering Protobuf, you'll build your skills to effectively serialize, transmit, and manage data across diverse platforms and languages.
This book will help you enter the world of Protocol Buffers by unraveling the intricate nuances of Protobuf syntax and showing you how to define complex data structures. As you progress, you’ll learn schema evolution, ensuring seamless compatibility as your projects evolve. The book also covers advanced topics such as custom options and plugins, allowing you to tailor validation processes to your specific requirements. You’ll understand how to automate project builds using cutting-edge tools such as Buf and Bazel, streamlining your development workflow. With hands-on projects in Go and Python programming, you’ll learn how to practically apply Protobuf concepts. Later chapters will show you how to integrate data interchange capabilities across different programming languages, enabling efficient collaboration and system interoperability.
By the end of this book, you’ll have a solid understanding of Protobuf internals, enabling you to discern when and how to use and redefine your approach to data serialization.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 261

Veröffentlichungsjahr: 2024

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Protocol Buffers Handbook

Getting deeper into Protobuf internals and its usage

Clément Jean

Protocol Buffers Handbook

Copyright © 2024 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Kunal Sawant

Publishing Product Manager: Akash Sharma

Book Project Manager: Manisha Singh

Senior Editor: Kinnari Chohan

Technical Editor: Vidhisha Patidar

Copy Editor: Safis Editing

Proofreader: Kinnari Chohan

Indexer: Rekha Nair

Production Designer: Prashant Ghare

DevRel Marketing Coordinator: Sonia Chauhan

First published: May 2024

Production reference: 1190424

Published by Packt Publishing Ltd.

Grosvenor House

11 St Paul’s Square

Birmingham

B3 1RB, UK

ISBN 978-1-80512-467-2

www.packtpub.com

To my mother, Géraldine Seyte, and my father, Marc Jean, for their sacrifices and for exemplifying the power of determination and curiosity. To my wife, 李梦昕, for her unconditional love and support.

– Clément Jean

Contributors

About the author

Clément Jean is the CTO of Education for Ethiopia, a start-up focusing on educating K-12 students in Ethiopia. On top of that, he is also an online instructor (on Udemy, Linux Foundation, and others) teaching people about different kinds of technologies. In both his occupations, he deals with technologies such as Protobuf and gRPC and how to apply them to real-life use cases. His overall goal is to empower people through education and technology.

About the reviewer

Eugene Khabarov is a software engineer with more than 18 years of experience. For approximately half of his career, he worked with Microsoft SQL Server, and he spent the other half with Golang, building gRPC and REST APIs, parsers, and generators. Several years ago, he started automating build processes with Bazel. He is passionate about software architecture, code performance, and team productivity.

Table of Contents

Preface

1

Serialization Primer

Technical requirements

Serialization’s goals

How does it all work?

The different data formats

What about Protobuf?

Serialized data size

Availability of data

Readability of data

Type safety

Readability of schema

Summary

Quiz

Answers

2

Protobuf is a Language

Technical requirements

Top-level statements

Syntax

Edition

Package

Import

Option

User-defined types

enum

Message

Option

Field

Reserved

MapField

Oneof

Message

Services

Out-of-the-box types

Duration and timestamp

FieldMask

Any

Struct

Summary

Quiz

Answers

3

Describing Data with Protobuf Text Format

Technical requirements

Why use the text format?

Less boilerplate

Type safety

Headers and comments

Describing data

Scalar values

Messages

Maps

Oneofs

Enums

Summary

Quiz

Answers

4

The Protobuf Compiler

Technical requirements

Downloading and installing protoc

GitHub Releases page

curl and wget

Transpiling .proto files

Why code generation?

Generating C++ code

Generating Go code

How does the code map to the .proto file?

Specifying import paths

Encoding data to type with --encode

Decoding data to type with --decode

Decoding data to type without .proto files, with --decode_raw

What about the other flags?

Summary

Quiz

Answers

Challenge solutions

Challenge 1 – Descriptors

Challenge 2 – Plugins

5

Serialization Internals

Technical requirements

Variable-length integers (varints)

ZigZag encoding

Fixed-size integers

How to choose between integer types

Number range

Sign

Data distribution

Field metadata

Length-delimited encoding

Packed versus unpacked repeated fields

Maps

Summary

Quiz

Answers

6

Schema Evolution over Time

Technical requirements

Backward and forward compatibility

Backward compatibility

Forward compatibility

Some problems

Conclusion

Disabling tags – reserved tags

Disabling field names – reserved names

The evolution rules

Summary

Quiz

Answers

7

Implementing the Address Book in Go

Technical requirements

The project: address book

Defining the schema

Boilerplate code

Converting string to enum values

Reading/writing from/to a file

Adding entries

The business logic

The CLI

Listing entries

The business logic

The CLI

Hiding sensitive data

Summary

Challenge

8

Implementing the Address Book in Python

Technical requirements

The Address Book project

Defining the schema

Boilerplate code

Converting strings to enum values

Reading/writing from/to files

Adding entries

The business logic

The CLI

Listing entries

The business logic

The CLI

Hiding sensitive data

Interoperability between Go and Python

Summary

Challenge

9

Developing a Protoc Plugin in Golang

Technical requirements

The project

What are custom options?

A custom option

What are protoc plugins?

The plugin

Getting all the messages

Defining a Protoc plugin

Updating the AddressBook

Adding a protoc plugin option

Summary

Challenges

10

Advanced Build

Technical requirements

The sample project

Building manually with protoc – a summary

Using Makefile

Using Buf

Using Bazel

Summary

Challenge

Index

Other Books You May Enjoy