VOL-2098 Add probe argument to NewGrpcServer; Release 2.2.12
Change-Id: I76ceb9efe280c66c67edc5fef85cc8060c670a5e
diff --git a/VERSION b/VERSION
index ebbf6e5..98c938e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.12-dev
+2.2.12
diff --git a/pkg/grpc/server.go b/pkg/grpc/server.go
index 488d470..7796b83 100644
--- a/pkg/grpc/server.go
+++ b/pkg/grpc/server.go
@@ -79,12 +79,14 @@
port int,
certs *GrpcSecurity,
secure bool,
+ probe ReadyProbe,
) *GrpcServer {
server := &GrpcServer{
address: address,
port: port,
secure: secure,
GrpcSecurity: certs,
+ probe: probe,
}
return server
}
@@ -124,12 +126,6 @@
}
}
-// Attach a readiness probe to the server.
-// If the probe returns NotReady, the server will return UNAVAILABLE
-func (s *GrpcServer) AttachReadyProbe(p ReadyProbe) {
- s.probe = p
-}
-
func withServerUnaryInterceptor(s *GrpcServer) grpc.ServerOption {
return grpc.UnaryInterceptor(mkServerInterceptor(s))
}
diff --git a/pkg/grpc/server_test.go b/pkg/grpc/server_test.go
index a3afc09..df3911c 100644
--- a/pkg/grpc/server_test.go
+++ b/pkg/grpc/server_test.go
@@ -38,12 +38,12 @@
}
func TestNewGrpcServer(t *testing.T) {
- server := NewGrpcServer("127.0.0.1", 1234, nil, false)
+ server := NewGrpcServer("127.0.0.1", 1234, nil, false, nil)
assert.NotNil(t, server)
}
func TestMkServerInterceptorNoProbe(t *testing.T) {
- server := NewGrpcServer("127.0.0.1", 1234, nil, false)
+ server := NewGrpcServer("127.0.0.1", 1234, nil, false, nil)
assert.NotNil(t, server)
f := mkServerInterceptor(server)
@@ -62,7 +62,9 @@
}
func TestMkServerInterceptorReady(t *testing.T) {
- server := NewGrpcServer("127.0.0.1", 1234, nil, false)
+ probe := &MockReadyProbe{Ready: true}
+
+ server := NewGrpcServer("127.0.0.1", 1234, nil, false, probe)
assert.NotNil(t, server)
f := mkServerInterceptor(server)
@@ -71,9 +73,6 @@
req := "SomeRequest"
serverInfo := grpc.UnaryServerInfo{Server: nil, FullMethod: "somemethod"}
- probe := &MockReadyProbe{Ready: true}
- server.AttachReadyProbe(probe)
-
result, err := f(context.Background(),
req,
&serverInfo,
@@ -84,7 +83,9 @@
}
func TestMkServerInterceptorNotReady(t *testing.T) {
- server := NewGrpcServer("127.0.0.1", 1234, nil, false)
+ probe := &MockReadyProbe{Ready: false}
+
+ server := NewGrpcServer("127.0.0.1", 1234, nil, false, probe)
assert.NotNil(t, server)
f := mkServerInterceptor(server)
@@ -93,9 +94,6 @@
req := "SomeRequest"
serverInfo := grpc.UnaryServerInfo{Server: nil, FullMethod: "somemethod"}
- probe := &MockReadyProbe{Ready: false}
- server.AttachReadyProbe(probe)
-
result, err := f(context.Background(),
req,
&serverInfo,