Implementing_gRPC_in_Golang_Microservice

package
v0.0.0-...-20a384c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 4 Imported by: 0

README

Chapter 2 - Protobuf Primer

These text files in this folder represent the values that we want to serialize. With these we can create an instance of Account (defined in account.proto) or Wrappers (defined in wrappers.proto), and encode data to binary.

An example of encoding is the following:

Linux/Mac

cat account.txt | protoc --encode=Account account.proto | hexdump -C

Windows (Powershell)

(Get-Content account.txt | protoc --encode=Account account.proto) -join "`n" | Format-Hex

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AccountRight_name = map[int32]string{
		0: "ACCOUNT_RIGHT_UNSPECIFIED",
		1: "ACCOUNT_RIGHT_READ",
		2: "ACCOUNT_RIGHT_READ_WRITE",
		3: "ACCOUNT_RIGHT_ADMIN",
	}
	AccountRight_value = map[string]int32{
		"ACCOUNT_RIGHT_UNSPECIFIED": 0,
		"ACCOUNT_RIGHT_READ":        1,
		"ACCOUNT_RIGHT_READ_WRITE":  2,
		"ACCOUNT_RIGHT_ADMIN":       3,
	}
)

Enum value maps for AccountRight.

View Source
var File_account_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Account

type Account struct {
	Id       uint64       `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Username string       `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	Right    AccountRight `protobuf:"varint,3,opt,name=right,proto3,enum=AccountRight" json:"right,omitempty"`
	// contains filtered or unexported fields
}

func (*Account) Descriptor deprecated

func (*Account) Descriptor() ([]byte, []int)

Deprecated: Use Account.ProtoReflect.Descriptor instead.

func (*Account) GetId

func (x *Account) GetId() uint64

func (*Account) GetRight

func (x *Account) GetRight() AccountRight

func (*Account) GetUsername

func (x *Account) GetUsername() string

func (*Account) ProtoMessage

func (*Account) ProtoMessage()

func (*Account) ProtoReflect

func (x *Account) ProtoReflect() protoreflect.Message

func (*Account) Reset

func (x *Account) Reset()

func (*Account) String

func (x *Account) String() string

type AccountRight

type AccountRight int32
const (
	AccountRight_ACCOUNT_RIGHT_UNSPECIFIED AccountRight = 0
	AccountRight_ACCOUNT_RIGHT_READ        AccountRight = 1
	AccountRight_ACCOUNT_RIGHT_READ_WRITE  AccountRight = 2
	AccountRight_ACCOUNT_RIGHT_ADMIN       AccountRight = 3
)

func (AccountRight) Descriptor

func (AccountRight) Enum

func (x AccountRight) Enum() *AccountRight

func (AccountRight) EnumDescriptor deprecated

func (AccountRight) EnumDescriptor() ([]byte, []int)

Deprecated: Use AccountRight.Descriptor instead.

func (AccountRight) Number

func (AccountRight) String

func (x AccountRight) String() string

func (AccountRight) Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL