Skip to content

Commit

Permalink
Merge pull request #15 from signadot/add-client-keepalive
Browse files Browse the repository at this point in the history
add client keep alive params
  • Loading branch information
scott-cotton authored Nov 7, 2024
2 parents 8292af6 + 67c031e commit 873361c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion go-routesapi/cmd/sdroutes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/signadot/routesapi/go-routesapi"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"google.golang.org/protobuf/encoding/protojson"
)

Expand Down Expand Up @@ -40,7 +41,12 @@ func main() {
flag.StringVar(&sandboxName, "sandbox-name", "", "routes routing to sandbox with given name")
flag.BoolVar(&watch, "watch", false, "whether to watch")
flag.Parse()
conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.Dial(addr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: 5 * time.Second,
Timeout: 15 * time.Second,
}))
if err != nil {
log.Fatal(err)
}
Expand Down
8 changes: 7 additions & 1 deletion go-routesapi/watched/watched.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package watched
import (
"context"
"sync"
"time"

"github.com/signadot/routesapi/go-routesapi"
"github.com/signadot/routesapi/go-routesapi/internal/indices"
"github.com/signadot/routesapi/go-routesapi/internal/queue"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"google.golang.org/protobuf/proto"
)

Expand Down Expand Up @@ -43,7 +45,11 @@ type watched struct {
// NewWatched creates a Watched. The set of the workload rules returned from
// the returned Watched corresponds to those specified in q.
func NewWatched(ctx context.Context, cfg *Config, q *routesapi.WorkloadRoutingRulesRequest) (Watched, error) {
conn, err := grpc.Dial(cfg.Addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.Dial(cfg.Addr, grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: 5 * time.Second,
Timeout: 15 * time.Second,
}))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 873361c

Please sign in to comment.