A brief introduction to protobuf and installation tutorial in Ubuntu 16.04 environment

A brief introduction to protobuf and installation tutorial in Ubuntu 16.04 environment

A brief introduction to protobuf

Protobuf is Google's open source serialization protocol framework, which has a structure similar to XML and JSON. Its notable features are binary and high efficiency. It is mainly used in communication protocols and data storage, and is considered a method of representing structured data.

Advantages of protobuf

  • Everyone is using it, at least the "pretentious" ones are using it [We have to keep up with the times]
  • Others say that the performance is good, binary format [big projects don't use this, it feels shameful]
  • Cross-platform support for various languages, backward and forward compatibility is very powerful [after all, Google is using it]

Disadvantages of protobuf

  • Binary format, ordinary people can't read it
  • Lack of self-description

XML is self-describing, but protobuf format is not. If you are given a binary file, you cannot tell what it does.

Protobuf usage steps

  • Define your own data structure format (.pro) source file
  • Compile the source file using the compiler provided by protobuf
  • Use protobuf go's api to read and write information

For example, define a structured data person, including name and email attributes

Defined in xml

<person>
 <name>zhangsan</name>
 <email>[email protected]</email>
<person>

protobuf defines this

person{
 name:"zhangsan"
 email:"[email protected]"
}

This is defined in json

{
 "person":{
  "name":"zhangsan",
  "email":"[email protected]"
 }
}

Syntax of protobuf

Message definition

A message type defines a request or response message format and can contain multiple types.

Service

If you need to use the message type on RPC, you need to define an RPC service interface in the .proto file. The protocol buffer compiler will generate service interface code based on the selected language.

Protobuf is installed in Ubuntu [version 16.04]

Official address: https://github.com/google/protobuf/blob/master/src/README.md

The installation command line is as follows:

$ sudo apt-get install autoconf automake libtool curl make g++ unzip
$ git clone https://github.com/google/protobuf.git
$ cd protobuf
$ git submodule update --init --recursive
$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.

Screenshot after make

宛十八微服務

The compilation went smoothly without any problems. Let's check the version below.

$ protoc --version12

宛十八微服務

Summarize

The above is a brief introduction to protobuf and the installation tutorial in Ubuntu 16.04 environment. I hope it will be helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Detailed tutorial on installing Protobuf 3 on Ubuntu

<<:  Detailed explanation of the configuration method of MySQL master-slave replication read-write separation

>>:  Detailed explanation of common usage methods of weixin-js-sdk in vue

Recommend

How to implement Echats chart large screen adaptation

Table of contents describe accomplish The project...

Detailed explanation of the use of Vue's new built-in components

Table of contents 1. Teleport 1.1 Introduction to...

Sample code for implementing image drawer effect with CSS3

As usual, let’s first post the picture effect: Th...

Ubuntu 20.04 connects to wifi (2 methods)

I recently installed Ubuntu 20.04 and found that ...

CSS tips for controlling animation playback and pause (very practical)

Today I will introduce a very simple trick to con...

Linux/Mac MySQL forgotten password command line method to change the password

All prerequisites require root permissions 1. End...

MySQL Series 3 Basics

Table of contents Tutorial Series 1. Introduction...

Solution for VMware Workstation Pro not running on Windows

After the National Day holiday, did any of you fi...

CSS3 to achieve menu hover effect

Result: html <nav id="nav-1"> <...

Solve the problem of installing Theano on Ubuntu 19

Solution: Directly in the directory where you dow...

An example of using CSS methodologies to achieve modularity

1. What are CSS methodologies? CSS methodologies ...

Detailed tutorial on installing harbor private warehouse using docker compose

Overview What is harbor? The English word means: ...

How to use Vue's idea to encapsulate a Storage

Table of contents background Function Purpose Ide...

Use of JavaScript sleep function

Table of contents 1.sleep function 2. setTimeout ...

How is MySQL transaction isolation achieved?

Table of contents Concurrent scenarios Write-Writ...