Skip to content

Commit

Permalink
Do less pings to grpc (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Nov 27, 2023
1 parent efd479c commit 030374a
Show file tree
Hide file tree
Showing 38 changed files with 371 additions and 315 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ proto:
.PHONY: mocks
mocks:
rm -rf test/mocks
docker run --rm --user $$(id -u):$$(id -g) -w /work -v ${PWD}:/work vektra/mockery:v2.22.1 --keeptree --all --dir pkg/apis --output test/mocks
docker run --rm --user $$(id -u):$$(id -g) -w /work -v ${PWD}:/work vektra/mockery:v2.38.0 --keeptree --all --dir pkg/apis --output test/mocks

.PHONY: test
test:
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module github.com/fi-ts/accounting-go

go 1.20
go 1.21

require (
github.com/stretchr/testify v1.8.2
golang.org/x/net v0.8.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.30.0
github.com/stretchr/testify v1.8.4
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
github.com/stretchr/objx v0.5.1 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
164 changes: 18 additions & 146 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/apis/v1/cluster.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/v1/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/v1/info.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/v1/ip.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/v1/network_traffic.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/v1/pod.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/v1/postgres.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/v1/s3.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/v1/volume.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package client

import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"os"
"time"

v1 "github.com/fi-ts/accounting-go/pkg/apis/v1"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
healthv1 "google.golang.org/grpc/health/grpc_health_v1"
Expand Down Expand Up @@ -41,7 +41,7 @@ func NewClient(ctx context.Context, hostname string, port int, certFile string,
}

if caFile != "" {
ca, err := ioutil.ReadFile(caFile)
ca, err := os.ReadFile(caFile)
if err != nil {
return nil, fmt.Errorf("could not read ca certificate: %w", err)
}
Expand All @@ -65,8 +65,8 @@ func NewClient(ctx context.Context, hostname string, port int, certFile string,
})

kacp := keepalive.ClientParameters{
Time: 10 * time.Second, // send pings every 10 seconds if there is no activity
Timeout: time.Second, // wait 1 second for ping ack before considering the connection dead
Time: 20 * time.Second, // send pings every 10 seconds if there is no activity
Timeout: 3 * time.Second, // wait 1 second for ping ack before considering the connection dead
PermitWithoutStream: true, // send pings even without active streams
}

Expand Down
2 changes: 1 addition & 1 deletion proto/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: v1
plugins:
# generate go structs for protocol buffer definition
- plugin: buf.build/protocolbuffers/go:v1.29.1
- plugin: buf.build/protocolbuffers/go:v1.31.0
out: ../
# generate gRPC stubs in golang
- plugin: buf.build/grpc/go:v1.3.0
Expand Down
27 changes: 21 additions & 6 deletions test/mocks/v1/ClusterServiceClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 21 additions & 6 deletions test/mocks/v1/ClusterServiceServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 21 additions & 6 deletions test/mocks/v1/IPServiceClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 030374a

Please sign in to comment.