index

Symbols

$PASSWORD variable 171

Numerics

2PC (two-phase commit) 18

A

actors, in hexagonal architecture 48

adapters

implementing 54 – 57

in hexagonal architecture 48 – 49

payment

implementing 71 – 72

overview 69 – 70

using in gRPC 73 – 75

ALTS (Application Layer Transport Security) 6

api package 52

API server 132

APIPort interface 53, 74

app:order label 138

app:payment label 138

application core, implementing 51 – 53

application logging 168 – 169

Application struct 53

applications

in hexagonal architecture 48

running 61 – 63

automatic mock generation 111 – 112

automation, for source code generation 40 – 42

average value of numbers 156

B

BackoffExponentialWithJitter option 87

BackoffLinearWithJitter option 87

backward compatibility 43 – 45

adding new fields 43

adding/removing oneof fields 44 – 45

moving fields out of or into oneof fields 45

upgrading client but not server 44

upgrading server but not client 43 – 44

bidirectional streaming 6, 27

blue-green deployment 146 – 147

C

CA (certificate authority) 97

Called() method 109

canary deployment 144, 147

cancellation function 84

CD (continuous deployment) pipeline 127

cert pool 99

certificate authority (CA) 97

certificate generation 97 – 98

certificate management 141 – 144

certificate usage in Ingress 143

certificates on client side 144

ClusterIssuer 142 – 143

installation 142

CertificateRequests CRD 142

Certificates CRD 142

Challenges CRD 142

Charge method 72

choreography-based saga 19 – 21

CI/CD pipeline

production-grade use cases 11

testing in 124

circuit breaker pattern 87 – 92

client

certificates on side of 144

configuration for payment stub 72 – 73

handling errors on side of 78 – 79

load balancing on side of 67 – 68

upgrading client but not server 44

upgrading server but not client 43 – 44

client-side load balancing 66

CLIs (command-line interfaces) 48

cluster level logging 158

ClusterIP type 137

ClusterIssuer 142 – 143

ClusterIssuers CRD 142

code generation 5

command channel notation 21

command-line interfaces (CLIs) 48

connecting wires, in interservice communication 27 – 28

container runtime 10 – 11

context function 84

context.Background() parent context 84

continuous deployment (CD) pipeline 127

control plane 130

-cover parameter 111, 123

coverage, test 123 – 124

coverage information 123 – 124

testing in CI pipeline 124

coverage.out report 124

-coverprofile param 111

CRDs (custom resource definitions) 141 – 142

Create endpoint 59 – 60, 74, 76 – 78, 120

Create function 24

Create method 37, 60, 68, 72

CreateOrder request 63

CreateOrderRequest message 32 – 33

CreatePaymentRequest message 24, 35

CreatePaymentResponse message 24

ctx parameter 28

custom resource definitions (CRDs) 141 – 142

D

-d parameter 63

data consistency, handling in microservice architecture 18

database layer, end-to-end tests 117 – 118

db call 108

db.Get() function verification 114

db.Save() testing 114

dependency injection 61 – 63

deployment 127 – 149

certificate management 141 – 144

certificate usage in Ingress 143

certificates on client side 144

ClusterIssuer 142 – 143

installation 142

Docker 128 – 130

Kubernetes 130 – 141

architecture 130 – 132

deployment 135 – 137

eagle view of microservices deployment 133 – 134

NGINX Ingress controller 140 – 141

pod 134

resources 132 – 133

Service resource 137 – 139

of monolithic applications 15 – 16

strategies for 144 – 149

blue-green deployment 146 – 147

canary deployment 147

final thoughts on deployment 148 – 149

RollingUpdate 145 – 146

Docker 128 – 130

Docker Compose service definitions 116 – 117

docker login command 130

docker-compose up operation 121

driven actor 48

driver actor 48

E

Elasticsearch, as logging backend 170 – 172

ELK stack (Elasticsearch-Logstash-Kibana) 158

encoding, protocol buffer 33 – 36

end-to-end tests 115 – 123

database layer 117 – 118

Docker Compose service definitions 116 – 117

folder structure for 117

Order service layer 119 – 120

Payment service layer 118 – 119

running tests against stack 120 – 123

specifications 116

enums 24

error handling

and resilient communication 92 – 95

gRPC error model 93

gRPC error response 93 – 95

in interservice communication 75 – 80

errors with details 77 – 78

handling errors on client side 78 – 79

returning error code and message 76 – 77

running Payment service 80

status codes 75 – 76

error message, gPRC 75

ErrorDetails section 93

F

fault tolerance 5 – 6

Fibonacci function 106

field names 32

field numbers 33

field rules 32

field types 32

fields

adding new to messages 43

moving out of or into oneof fields 45

folders

project 50 – 51

structure for end-to-end tests 117

Format function 168

forward compatibility 43 – 45

adding new fields 43

adding/removing oneof fields 44 – 45

moving fields out of or into oneof fields 45

upgrading client but not server 44

upgrading server but not client 43 – 44

FROM keyword 128

G

Get endpoints 120

Get method 54, 56 – 57

go build command 128

go mod init command 51

Go source code, generating 25 – 27

go test command 106

gorm.DB reference 56

gRPC adapter, implementing 57 – 61

gRPC endpoint, calling 63 – 64

gRPC error model 93

gRPC error response 93 – 95

gRPC microservices 3 – 28

audience for book 8

benefits of 4 – 6

code generation and interoperability 5

fault tolerance 5 – 6

performance 4

security 6

streaming 6

microservice architecture 17 – 22

choreography-based saga 19 – 21

handling data consistency 18

orchestration-based saga 21 – 22

saga pattern 18 – 19

monolithic architecture 15 – 16

deployment 15 – 16

development 15

scaling 16

production-grade use cases 8 – 13

CI/CD pipeline 11

container runtime 10 – 11

microservices 9 – 10

monitoring and observability 11 – 12

public access 12 – 13

REST vs. RPC 6 – 7

scale cube 16 – 17

X-axis scaling 16

Y-axis scaling 17

Z-axis scaling 17

service discovery 22

when to use 7 – 8

gRPC service-to-service communication 66 – 68

grpc_retry package 87

grpcurl command 58, 144

H

hexagonal architecture

Order service implementation 49 – 64

calling gRPC endpoint 63 – 64

dependency injection and running application 61 – 63

implementing adapters 54 – 57

implementing application core 51 – 53

implementing gRPC adapter 57 – 61

implementing ports 53 – 54

initializing Go project 51

project folders 50 – 51

overview 47 – 49

-html option 124

I

idempotent operations 6

IDL (Interface Definition Language) 5

images, Docker 128 – 130

-import-path parameter 144

Ingress

certificate usage in 143

NGINX Ingress controller 140 – 141

init() function 168 – 169

initializing Go project 51

installation

cert-manager 142

Jaeger 162 – 163

instrumentation, OpenTelemetry 159

int type 33, 35

int64 type 52

integration tests 112 – 115

test suite preparation 112 – 113

working with Testcontainers 113 – 115

internal/adapters/grpc package 73

interoperability 5

interservice communication 31 – 46, 65 – 80

backward and forward compatibility 43 – 45

adding new fields 43

adding/removing oneof fields 44 – 45

moving fields out of or into oneof fields 45

upgrading client but not server 44

upgrading server but not client 43 – 44

depending on module and implementing ports and adapters 68 – 75

client configuration for payment stub 72 – 73

implementing payment adapter 71 – 72

implementing payment port 70

payment adapter overview 69 – 70

payment port overview 69

using payment adapter in gRPC 73 – 75

error handling 75 – 80

errors with details 77 – 78

handling errors on client side 78 – 79

returning error code and message 76 – 77

running Payment service 80

status codes 75 – 76

generating stubs 36 – 38

gRPC service-to-service communication 66 – 68

maintaining .proto files 38 – 42

automation for source code generation 40 – 42

proto project structure 38 – 40

protocol buffers 32 – 36

defining message type 32 – 33

protocol buffer encoding 33 – 36

using gRPC for 23 – 28

connecting wires 27 – 28

generating Go source code 25 – 27

working with protocol buffers 24 – 25

IP:port pair 138

Issuers CRD 142

J

Jaeger All in One 161 – 162

Jaeger installation 162 – 163

jaeger namespace 162

jaeger pod 165

Jaeger SPM (service performance monitoring) component 167

jaeger-prometheus Prometheus service name 162

K

Kibana as logging dashboard 172 – 174

kubectl apply command 136

kubectl command-line tool 132

Kubernetes

deployment 130 – 141

architecture 130 – 132

eagle view of microservices deployment 133 – 134

NGINX Ingress controller 140 – 141

overview 135 – 137

pod 134

resources 132 – 133

Service resource 137 – 139

observability in 161 – 174

application logging 168 – 169

Elasticsearch as logging backend 170 – 172

Jaeger All in One 161 – 162

Jaeger installation 162 – 163

Kibana as logging dashboard 172 – 174

logs collection 169 – 170

OpenTelemetry Collector 162

OpenTelemetry interceptor for Order service 163 – 165

Prometheus 162

understanding metrics of Order service 165 – 167

L

labels section 136

latest tag 39

load balancing

client-side 67 – 68

server-side 66

LoadBalancer Service type 137 – 140, 144

.local domain name 143

logging

application 168 – 169

Elasticsearch as backend for 170 – 172

in observability 157 – 158

Kibana as dashboard for 172 – 174

log collections 169 – 170

M

math class 106

message fields 43

metrics

and OpenTelemetry 159 – 160

in observability 155 – 157

of Order service, understanding 165 – 167

microservice architecture 17 – 22

choreography-based saga 19 – 21

handling data consistency 18

orchestration-based saga 21 – 22

production-grade use cases 9 – 10

saga pattern 18 – 19

microservice project setup 47 – 64

hexagonal architecture 47 – 49

Order service implementation 49 – 64

calling gRPC endpoint 63 – 64

dependency injection and running application 61 – 63

implementing adapters 54 – 57

implementing application core 51 – 53

implementing gRPC adapter 57 – 61

implementing ports 53 – 54

initializing Go project 51

project folders 50 – 51

minikube tunnel command 143 – 144

mocks

automatic generation of 111 – 112

implementing 108 – 111

working with 107 – 108

modules, depending on 68 – 75

client configuration for payment stub 72 – 73

implementing payment adapter 71 – 72

implementing payment port 70

payment adapter overview 69 – 70

payment port overview 69

using payment adapter in gRPC 73 – 75

monitoring 11 – 12

monolithic architecture 15 – 16

deployment 15 – 16

development 15

scaling 16

mTLS (mutual TLS) 96

multistage builds 118, 128

N

New<Service_Name>Client naming convention 28

New<ServiceName>Client function 37

NewAdapter function 56

NewApplication method 53

NewOrder method 52

NewOrderClient(...) function 37

NGINX Ingress controller 140 – 141

nginx instance 134, 141

nginx-ingress chart 141

nginx.conf. NGINX configurations 141

node-level logging 157 – 158

NodePort option 141

NodePort service type 137 – 139

numbers, average value of 156

O

observability 153 – 174

in Kubernetes 161 – 174

application logging 168 – 169

Elasticsearch as logging backend 170 – 172

Jaeger All in One 161 – 162

Jaeger installation 162 – 163

Kibana as logging dashboard 172 – 174

logs collection 169 – 170

OpenTelemetry Collector 162

OpenTelemetry interceptor for Order service 163 – 165

Prometheus 162

understanding metrics of Order service 165 – 167

logs 157 – 158

metrics 155 – 157

OpenTelemetry 158 – 161

instrumentation 159

instrumentation locations 159

metric backend 159 – 160

service performance monitoring 160 – 161

production-grade use cases 11 – 12

traces 154 – 155

OK status 75

oneof fields

adding/removing 44 – 45

moving fields out of or into 45

OpenTelemetry 158 – 161

instrumentation 159

instrumentation locations 159

metric backend 159 – 160

service performance monitoring 160 – 161

OpenTelemetry Collector 162

OpenTelemetry interceptor for Order service 163 – 165

orchestration-based saga 21 – 22

Order data 19, 52

Order event 21

Order model 54 – 56, 60, 69

order operation 84

Order service 39 – 40, 42

end-to-end tests 119 – 120

implementation 49 – 64

calling gRPC endpoint 63 – 64

dependency injection and running application 61 – 63

implementing adapters 54 – 57

implementing application core 51 – 53

implementing gRPC adapter 57 – 61

implementing ports 53 – 54

initializing Go project 51

project folders 50 – 51

OpenTelemetry interceptor for 163 – 165

understanding metrics of 165 – 167

order_created event 20

order-service, deployment 135

Order:create() method 18

OrderClient interface 37

OrderDatabaseTestSuite type 113 – 114

OrderId struct 55

OrderItem model 54

Orders CRD 142

orders database 118

ORM (Object Relational Mapping) library 54

otelgrpc package 164

outputs section 171

P

payment adapter

implementing 71 – 72

overview 69 – 70

using in gRPC 73 – 75

Payment Create operation 166

Payment operation 18

payment port

implementing 70

overview 69

Payment service 39 – 40, 42

calls 108

end-to-end tests 118 – 119

running 80

payment stub, client configuration for 72 – 73

payment_created event 20

payment_failed event 20

payment-related calls 108

payment.Charge() call 110

payments database 118

PENDING state 20, 74

performance benefits of gRPC microservices 4

PlaceOrder 52 – 53, 59, 74, 78, 107 – 109, 154, 161

-plaintext parameter 63

pods, Kubernetes 134

ports

implementing 53 – 54

in hexagonal architecture 48

payment

implementing 70

overview 69

ports.DBPort interface 52

PR (pull request) 124

production-grade use cases 8 – 13

CI/CD pipeline 11

container runtime 10 – 11

microservices 9 – 10

monitoring and observability 11 – 12

public access 12 – 13

project folders 50 – 51

project structure, proto 38 – 40

Prometheus 162

promo_code option 45

-proto file 144

.proto files, maintaining 38 – 42

automation for source code generation 40 – 42

proto project structure 38

protocol buffer compiler 25

installation 36

using 36 – 38

protocol buffers 32 – 36

defining message type 32 – 33

encoding 33 – 36

in interservice communication 24 – 25

public access 12 – 13

R

replicas definition 136

replyTo channel 21

replyToChannel parameter 20

reserved keyword 33

resilient communication 81 – 102

error handling 92 – 95

gRPC error model 93

gRPC error response 93 – 95

resiliency patterns 82 – 92

circuit breaker pattern 87 – 92

retry pattern 85 – 87

timeout pattern 82 – 85

securing gRPC communication 95 – 101

certificate generation 97 – 98

gRPC TLS credentials 99 – 101

TLS handshake 95 – 96

ResourceExhausted response code 86 – 87

REST (Representational State Transfer) 6 – 7

retry pattern 85 – 87

RollingUpdate deployment 145 – 146

round-robin algorithm 67

route operation 141

RPC (Remote Procedure Call) 6 – 7

Run method 62

running application 61 – 63

S

saga pattern

choreography-based saga 19 – 21

orchestration-based saga 21 – 22

overview 18 – 19

Save method 54, 56 – 57

scale cube 16 – 17

X-axis scaling 16

Y-axis scaling 17

Z-axis scaling 17

scaling monolithic applications 16

SDKs (software development kits) 79

server

load balancing on side of 66

upgrading client but not server 44

upgrading, but not client 43 – 44

service discovery 22

service performance monitoring 160 – 161

Service resource, Kubernetes 137 – 139

Service types 137

Service YAML definition 137

service-level agreement (SLA) 155

service-level indicator (SLI) 155

service-level objective (SLO) 155 – 157

service-to-service communication 66 – 68

Service, LoadBalancer Type 137

<ServiceName>Client function 37

Service – pod relationship 147

SetupSuite section 120

Shipping operation 18

Shipping service 39 – 40, 42

Shipping stub 24

SLA (service-level agreement) 155

SLI (service-level indicator) 155

SLO (service-level objective) 155 – 157

software development kits (SDKs) 79

source code generation automation 40 – 42

spec section 136

stack, running tests against 120 – 123

status codes, in error handling 75 – 76

stubs

client and server 4

generating 36 – 38

Payment and Shipping 24

payment, client configuration for 72 – 73

-subj parameter 97

SUT (system under test) 105

svc.cluster.local suffix 162

T

TearDownSuite 120, 122

test suite preparation 112 – 113

Testcontainers 113 – 115

testing microservices 103 – 126

end-to-end tests 115 – 123

database layer 117 – 118

Docker Compose service definitions 116 – 117

folder structure for 117

Order service layer 119 – 120

Payment service layer 118 – 119

running tests against stack 120 – 123

specifications 116

integration tests 112 – 115

test suite preparation 112 – 113

working with Testcontainers 113 – 115

test coverage 123 – 124

coverage information 123 – 124

testing in CI pipeline 124

testing pyramid 104 – 105

unit tests 105 – 112

automatic mock generation 111 – 112

implementing mock 108 – 111

system under test 105

test workflow 106 – 107

working with mocks 107 – 108

testing pyramid 104 – 105

TestSetupSuite function 113

TestSetupTest method 112

TestTearDownSuite method 112

timeout pattern 82 – 85

TLS (Transport Layer Security) 4

gRPC credentials 99 – 101

handshake 95 – 96

to keyword 33

traces, in observability 154 – 155

two-phase commit (2PC) 18

U

UAT (user acceptance testing) 11

Unavailable response code 86 – 87

unit tests 105 – 112

automatic mock generation 111 – 112

implementing mock 108 – 111

system under test 105

test workflow 106 – 107

working with mocks 107 – 108

upgrading

client, but not server 44

server, but not client 43 – 44

V

VCS (Version Control System) 11

W

wires, connecting in interservice communication 27 – 28

WithBackoff configuration 87

WithCodes configuration 87

WithMax configuration 87

WithStreamingInterceptor interceptor usage 87

WithUnaryInterceptor interceptor usage 87

worker nodes 130

X

X-axis scaling 16

Y

Y-axis scaling 17

Z

Z-axis scaling 17