lostluck commented on a change in pull request #16957: URL: https://github.com/apache/beam/pull/16957#discussion_r837987480
########## File path: sdks/go/pkg/beam/core/runtime/harness/worker_status.go ########## @@ -0,0 +1,91 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package harness + +import ( + "context" + "io" + "runtime" + "sync" + "sync/atomic" + "time" + + "github.com/apache/beam/sdks/v2/go/pkg/beam/internal/errors" + "github.com/apache/beam/sdks/v2/go/pkg/beam/log" + fnpb "github.com/apache/beam/sdks/v2/go/pkg/beam/model/fnexecution_v1" + "google.golang.org/grpc" +) + +// workerStatusHandler stores the communication information of WorkerStatus API. +type workerStatusHandler struct { + conn *grpc.ClientConn + shutdown int32 +} + +func newWorkerStatusHandler(ctx context.Context, endpoint string) (*workerStatusHandler, error) { + sconn, err := dial(ctx, endpoint, 60*time.Second) + if err != nil { + return &workerStatusHandler{}, errors.Wrapf(err, "failed to connect: %v\n", endpoint) Review comment: nit: Conventionally, when a non-nil error is being returned, the other return values are not considered valid. If they're pointer types, they should return `nil` instead of a pointer to a zeroed value. If the returned non-error values are valid, the convention is to document this behavior, and why. Eg. The [`io.Reader`](https://pkg.go.dev/io#Reader) interface defines this kind of thing. The `n` is always valid, and an error of `io.EOF` is considered a success. In this case, it would be cleaner if nil is returned, and the failure case is properly handled by the caller. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
