Skip to content

Commit 4f786ec

Browse files
committed
fix: package comments, error return and deadlock
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
1 parent a930720 commit 4f786ec

File tree

11 files changed

+46
-17
lines changed

11 files changed

+46
-17
lines changed

api/interfaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package api defines public interfaces for the gRPC plugin components.
12
package api
23

34
import (

codec/codec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package codec provides a raw codec implementation for gRPC that passes through protobuf messages without re-encoding.
12
package codec
23

34
import (

go.work.sum

Lines changed: 27 additions & 9 deletions
Large diffs are not rendered by default.

health_server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ func (h *HealthCheckServer) Watch(_ *grpc_health_v1.HealthCheckRequest, stream g
9696

9797
func (h *HealthCheckServer) SetServingStatus(servingStatus grpc_health_v1.HealthCheckResponse_ServingStatus) {
9898
h.mu.Lock()
99+
defer h.mu.Unlock()
100+
99101
if h.shutdown {
100102
h.log.Info("health status changing is ignored, because health service is shutdown")
101103
return
@@ -112,7 +114,6 @@ func (h *HealthCheckServer) SetServingStatus(servingStatus grpc_health_v1.Health
112114
// put the most recent one
113115
upd <- servingStatus
114116
}
115-
h.mu.Unlock()
116117
}
117118

118119
func (h *HealthCheckServer) Shutdown() {

parser/parse.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package parser provides functionality to parse protobuf files and extract gRPC service definitions.
12
package parser
23

34
import (
@@ -40,7 +41,10 @@ type Method struct {
4041

4142
// File parses given proto file or returns error.
4243
func File(file string, importPath string) ([]Service, error) {
43-
reader, _ := os.Open(file)
44+
reader, err := os.Open(file)
45+
if err != nil {
46+
return nil, err
47+
}
4448
defer func() {
4549
_ = reader.Close()
4650
}()

plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package grpc implements a gRPC server plugin for RoadRunner that proxies requests to PHP workers.
12
package grpc
23

34
import (

protoc_plugins/protoc-gen-php-grpc/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23+
// Command protoc-gen-php-grpc is a protoc plugin that generates PHP interfaces for gRPC services.
2324
package main
2425

2526
import (

protoc_plugins/protoc-gen-php-grpc/php/generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23+
// Package php provides PHP code generation for gRPC service interfaces.
2324
package php
2425

2526
import (

protoc_plugins/protoc-gen-php-grpc/php/template.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,11 @@ func body(req *plugin.CodeGeneratorRequest, file *desc.FileDescriptorProto, serv
9595
return strings.ReplaceAll(name, "\\\\", "\\")
9696
},
9797
"resolve_name_const": func(packagePath, serviceName *string) string {
98-
9998
if defaultOrVal(packagePath) == "" {
10099
return defaultOrVal(serviceName)
101100
}
102101

103102
return *packagePath + "." + defaultOrVal(serviceName)
104-
105103
},
106104
}).Parse(phpBody))
107105

proxy/proxy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package proxy implements a gRPC service proxy that forwards requests to RoadRunner PHP workers.
12
package proxy
23

34
import (
@@ -192,7 +193,7 @@ func (p *Proxy) invoke(ctx context.Context, method string, in *codec.RawMessage)
192193
select {
193194
case pl := <-re:
194195
if pl.Error() != nil {
195-
return nil, err
196+
return nil, pl.Error()
196197
}
197198
// streaming is not supported
198199
if pl.Payload().Flags&frame.STREAM != 0 {

0 commit comments

Comments
 (0)