> For the complete documentation index, see [llms.txt](https://motivlabs.gitbook.io/impulse-dev-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://motivlabs.gitbook.io/impulse-dev-manual/grpc/protocol-buffer-compiler.md).

# Protocol buffer compiler

While not mandatory, gRPC applications often leverage Protocol Buffers for service definitions and data serialization. All the services in Impulse uses version 3 of the protocol buffer language (proto3).

The protocol buffer compiler, protoc, is used to compile `.proto` files, which contain service and message definitions.

## How to install protoc

{% embed url="<https://grpc.io/docs/protoc-installation/>" %}

### Mac OS

#### Install Protocol buffer compiler, protoc

```shell
brew install protobuf
protoc --version  # Ensure compiler version is 3+
```

#### Install Go plugins for the protocol compiler

```shell
cd ~

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
```

#### Update your PATH so that the protoc compiler can find the plugins:

```shell
export PATH="$PATH:$(go env GOPATH)/bin"
```

## Compile .proto file

#### **Regular Microservices (Depends on the go-grpc)**

When compiling `.proto` files from a microservice it is important to notice there is a dependency with the `go-grpc` module, meaning, it needs to exist.

```shell
protoc --go_out=./generated --go_opt=paths=source_relative \
    --go-grpc_out=./generated --go-grpc_opt=paths=source_relative \
    grpc/*.proto --proto_path=../go-grpc --proto_path=.
```

#### Microservices with no dependencies with the go-grpc module

```shell
protoc --go_out=./generated --go_opt=paths=source_relative \
    --go-grpc_out=./generated --go-grpc_opt=paths=source_relative \
    grpc/*.proto --proto_path=.
```

#### **From the go-grpc module:**

For cases where the generic gRPC messages used by all the microservices existing in the `go-grpc` module need to be updated.

```shell
protoc --go_out=./generated --go_opt=paths=source_relative \
    --go-grpc_out=./generated --go-grpc_opt=paths=source_relative \
    grpc/*.proto --proto_path=.
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://motivlabs.gitbook.io/impulse-dev-manual/grpc/protocol-buffer-compiler.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
