Skip to Content
Go言語による分散サービス ―信頼性、拡張性、保守性の高いシステムの構築
book

Go言語による分散サービス ―信頼性、拡張性、保守性の高いシステムの構築

by Travis Jeffery, 柴田 芳樹
August 2022
Beginner to intermediate
280 pages
3h 50m
Japanese
O'Reilly Japan, Inc.
Content preview from Go言語による分散サービス ―信頼性、拡張性、保守性の高いシステムの構築

2章プロトコルバッファによる構造化データ

分散サービスを構築する際には、ネットワークを介してサービス間の通信を行います。構造体などのデータをネットワーク経由で送信するには、データを送信可能な形式にエンコードする必要があり、多くのプログラマはJSONを選択しています。公開APIを構築する場合、すなわち、自分たちでクライアントを開発しないプロジェクトでは、人間が読むことができて、コンピュータも解析できるJSONが適しています。しかし、非公開のAPIを構築する場合、すなわち、自分たちでクライアントを開発するプロジェクトでは、話が異なります。つまり、JSONに比べて生産性が高く、速く、多くの機能を持ち、バグの少ないサービスを作ることができるデータの構造化と送信の機構を利用できます。

その機構は、プロトコルバッファ(Protocol Buffers:protobufとも呼ばれる)です。プロトコルバッファは、データを構造化してシリアライズするための、Googleが設計した言語とプラットフォームに依存しない拡張可能な機構です。protobufを使う利点は、次のとおりです。

  • 型の安全性を保証します。
  • スキーマ違反を防ぎます。
  • 高速なシリアライズを可能にします。
  • 後方互換性を提供します。

protobufではデータをどのように構造化するのかを定義し、そのprotobufをさまざまな言語のコードにコンパイルし、構造化されたデータをさまざまなデータストリームとの間で読み書きできます。プロトコルバッファは、二つのシステム間(マイクロサービスなど)の通信に適しています。そのため、Google社は、高性能なRPCフレームワークであるgRPCを構築した際にprotobufを使いました。

あなたがprotobufを使ったことがなければ、私と同じように「protobufは余計な作業が多いのではないか」という懸念を持つかもしれません。しかし、この章とこの本の残りの部分でprotobufを使ってみると、それほど悪いものではないことが分かると思います。JSONよりも多くの利点があり、結果的に多くの作業を省けます。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

エンジニアリングマネージャーのしごと ―チームが必要とするマネージャーになる方法

エンジニアリングマネージャーのしごと ―チームが必要とするマネージャーになる方法

James Stanier, 吉羽 龍太郎, 永瀬 美穂, 原田 騎郎, 竹葉 美沙
サイトリライアビリティワークブック ―SREの実践方法

サイトリライアビリティワークブック ―SREの実践方法

Betsy Beyer, Niall Richard Murphy, David K. Rensin, Kent Kawahara, Stephen Thorne, 澤田 武男, 関根 達夫, 細川 一茂, 矢吹 大輔, 玉川 竜司
スクラム実践者が知るべき97のこと

スクラム実践者が知るべき97のこと

Gunther Verheyen, 吉羽 龍太郎, 原田 騎郎, 永瀬 美穂
生成AI時代の価値のつくりかた ―実践者のマインド、スキル、データ、ユースケース

生成AI時代の価値のつくりかた ―実践者のマインド、スキル、データ、ユースケース

Rob Thomas, Paul Zikopoulos, Kate Soule, 本多 真二郎, オライリー・ジャパン編集部

Publisher Resources

ISBN: 9784873119977Other