Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated grpc methods #197

Merged
merged 6 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestChannelUnsuccessfulConnection(t *testing.T) {
t.Fatal("the node was not added to the configuration")
}
if node.conn == nil {
t.Fatal("connection should not be nil when NOT using WithBlock()")
t.Fatal("connection should not be nil")
}
}

Expand Down
2 changes: 0 additions & 2 deletions cmd/benchmark/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,8 @@ func main() {

mgrOpts := []gorums.ManagerOption{
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
gorums.WithDialTimeout(10 * time.Second),
gorums.WithSendBufferSize(*sendBuffer),
}

Expand Down
5 changes: 0 additions & 5 deletions doc/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,14 @@ package gorumsexample

import (
"log"
"time"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

func ExampleStorageClient() {
mgr := NewManager(
gorums.WithDialTimeout(500*time.Millisecond),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down Expand Up @@ -404,9 +401,7 @@ func ExampleStorageClient() {
}

mgr := NewManager(
gorums.WithDialTimeout(50*time.Millisecond),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
3 changes: 0 additions & 3 deletions examples/storage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"log"
"time"

"github.com/relab/gorums"
"github.com/relab/gorums/examples/storage/proto"
Expand All @@ -17,9 +16,7 @@ func runClient(addresses []string) {

// init gorums manager
mgr := proto.NewManager(
gorums.WithDialTimeout(1*time.Second),
gorums.WithGrpcDialOptions(
grpc.WithBlock(), // block until connections are made
grpc.WithTransportCredentials(insecure.NewCredentials()), // disable TLS
),
)
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ require (
golang.org/x/sync v0.6.0
golang.org/x/tools v0.19.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237
google.golang.org/grpc v1.62.1
google.golang.org/grpc v1.63.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
google.golang.org/protobuf v1.33.0
)

require (
github.com/golang/protobuf v1.5.4 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
Expand All @@ -16,8 +14,8 @@ golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8=
google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 h1:rNBFJjBCOgVr9pWD7rs/knKL4FRTKgpZmsRfV214zcA=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
Expand Down
3 changes: 0 additions & 3 deletions mgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"log"
"testing"
"time"

"github.com/relab/gorums"
"github.com/relab/gorums/tests/dummy"
Expand Down Expand Up @@ -73,9 +72,7 @@ func TestManagerAddNodeWithConn(t *testing.T) {
})
defer teardown()
mgr := gorums.NewRawManager(
gorums.WithDialTimeout(100*time.Millisecond),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
4 changes: 1 addition & 3 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ func (n *RawNode) dial() error {
n.conn.Close()
}
var err error
ctx, cancel := context.WithTimeout(context.Background(), n.mgr.opts.nodeDialTimeout)
defer cancel()
n.conn, err = grpc.DialContext(ctx, n.addr, n.mgr.opts.grpcDialOpts...)
n.conn, err = grpc.NewClient(n.addr, n.mgr.opts.grpcDialOpts...)
return err
}

Expand Down
29 changes: 9 additions & 20 deletions opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,32 @@ package gorums

import (
"log"
"time"

"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/metadata"
)

type managerOptions struct {
grpcDialOpts []grpc.DialOption
nodeDialTimeout time.Duration
logger *log.Logger
noConnect bool
backoff backoff.Config
sendBuffer uint
metadata metadata.MD
perNodeMD func(uint32) metadata.MD
grpcDialOpts []grpc.DialOption
logger *log.Logger
noConnect bool
backoff backoff.Config
sendBuffer uint
metadata metadata.MD
perNodeMD func(uint32) metadata.MD
}

func newManagerOptions() managerOptions {
return managerOptions{
backoff: backoff.DefaultConfig,
sendBuffer: 0,
nodeDialTimeout: 50 * time.Millisecond,
backoff: backoff.DefaultConfig,
sendBuffer: 0,
}
}

// ManagerOption provides a way to set different options on a new Manager.
type ManagerOption func(*managerOptions)

// WithDialTimeout returns a ManagerOption which is used to set the dial
// context timeout to be used when initially connecting to each node in its pool.
func WithDialTimeout(timeout time.Duration) ManagerOption {
return func(o *managerOptions) {
o.nodeDialTimeout = timeout
}
}

// WithGrpcDialOptions returns a ManagerOption which sets any gRPC dial options
// the Manager should use when initially connecting to each node in its pool.
func WithGrpcDialOptions(opts ...grpc.DialOption) ManagerOption {
Expand Down
2 changes: 0 additions & 2 deletions rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ func initServer() *gorums.Server {

func gorumsTestMgr() *dummy.Manager {
mgr := dummy.NewManager(
gorums.WithDialTimeout(time.Second),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
2 changes: 0 additions & 2 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ func TestServerCallback(t *testing.T) {
md := metadata.New(map[string]string{"message": "hello"})

mgr := gorums.NewRawManager(
gorums.WithDialTimeout(time.Second),
gorums.WithMetadata(md),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
3 changes: 0 additions & 3 deletions tests/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
fmt "fmt"
"testing"
"time"

gorums "github.com/relab/gorums"
"google.golang.org/grpc"
Expand Down Expand Up @@ -86,9 +85,7 @@ func TestConfig(t *testing.T) {
}
}
mgr := NewManager(
gorums.WithDialTimeout(100*time.Millisecond),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
2 changes: 0 additions & 2 deletions tests/correctable/correctable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration
defer teardown()

mgr := NewManager(
gorums.WithDialTimeout(time.Second),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
7 changes: 0 additions & 7 deletions tests/metadata/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"strconv"
"testing"
"time"

"github.com/relab/gorums"
"google.golang.org/grpc"
Expand Down Expand Up @@ -61,9 +60,7 @@ func TestMetadata(t *testing.T) {

mgr := NewManager(
gorums.WithMetadata(md),
gorums.WithDialTimeout(time.Second),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down Expand Up @@ -95,9 +92,7 @@ func TestPerNodeMetadata(t *testing.T) {

mgr := NewManager(
gorums.WithPerNodeMetadata(perNodeMD),
gorums.WithDialTimeout(time.Second),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand All @@ -123,9 +118,7 @@ func TestCanGetPeerInfo(t *testing.T) {
defer teardown()

mgr := NewManager(
gorums.WithDialTimeout(time.Second),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
3 changes: 0 additions & 3 deletions tests/oneway/oneway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"sync"
"testing"
"time"

"github.com/relab/gorums"
"github.com/relab/gorums/tests/oneway"
Expand Down Expand Up @@ -63,9 +62,7 @@ func setup(t testing.TB, cfgSize int) (cfg *oneway.Configuration, srvs []*oneway
}

mgr := oneway.NewManager(
gorums.WithDialTimeout(100*time.Millisecond),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
2 changes: 0 additions & 2 deletions tests/ordering/order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ func setup(t *testing.T, cfgSize int) (cfg *Configuration, teardown func()) {
return srv
})
mgr := NewManager(
gorums.WithDialTimeout(100*time.Millisecond),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
2 changes: 0 additions & 2 deletions tests/qf/qf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"testing"
"time"

"github.com/relab/gorums"
"google.golang.org/grpc"
Expand Down Expand Up @@ -196,7 +195,6 @@ func BenchmarkFullStackQF(b *testing.B) {
return srv
})
mgr := NewManager(
gorums.WithDialTimeout(10*time.Second),
gorums.WithGrpcDialOptions(
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
Expand Down
4 changes: 0 additions & 4 deletions tests/tls/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/tls"
"crypto/x509"
"testing"
"time"

"github.com/relab/gorums"
"google.golang.org/grpc"
Expand Down Expand Up @@ -47,11 +46,8 @@ func TestTLS(t *testing.T) {
defer teardown()

mgr := NewManager(
gorums.WithDialTimeout(100*time.Millisecond),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(cp, "")),
grpc.WithReturnConnectionError(),
),
)
_, err = mgr.NewConfiguration(gorums.WithNodeList(addrs))
Expand Down
2 changes: 0 additions & 2 deletions tests/unresponsive/unreponsive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ func TestUnresponsive(t *testing.T) {
defer teardown()

mgr := NewManager(
gorums.WithDialTimeout(100*time.Millisecond),
gorums.WithGrpcDialOptions(
grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
),
)
Expand Down
Loading