Skip to content

Commit

Permalink
🏗️ refactor: move protobuf to serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafaghadimi committed May 30, 2024
1 parent d80b971 commit 8ac463e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "Protocol Buffer"
---
# Protocol Buffer

## Introduction

**Protocol Buffers**, often abbreviated as **protobuf**, are a language-agnostic binary serialization method developed by Google. They are designed to be smaller, faster, and simpler than traditional methods like XML or JSON. Protocol Buffers allow you to define simple data structures in a special format, and then use the generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.

## Structure

A Protocol Buffer message is a logical record of information, containing a series of name-value pairs. Here's how you define a message in Protocol Buffers:

```protobuf
message Person {
string name = 1;
int32 id = 2;
bool has_ponycopter = 3;
}
```

Each field in the message definition has a unique number. These numbers are used to identify your fields in the message binary format, and should not be changed once your message type is in use.

## Usecase

Protocol Buffers are particularly effective in the following scenarios:

1. **Storing Data**: Protocol Buffers could be used to store data in a compact binary format. This is especially useful in situations where the amount of data is large.

2. **Communication Protocol**: They can be used to define the data for service interfaces. They are a key component of an RPC (Remote Procedure Call) system where client applications can call methods on a server application on a different machine as if it was a local object.

3. **Cross Platform Data Stream**: Since Protocol Buffers are language agnostic, they are a great choice for cross-platform systems. They support a wide range of languages including C++, Java, Python, and more.

Remember, Protocol Buffers are not always the best fit for every situation. They are not designed to handle large amounts of text-based data like XML or JSON, and do not support creating complex nested data structures as conveniently as JSON.

0 comments on commit 8ac463e

Please sign in to comment.