damondouglas commented on code in PR #27158: URL: https://github.com/apache/beam/pull/27158#discussion_r1237315061
########## .test-infra/pipelines/src/main/go/cmd/api_overuse_study/refresher/main.go: ########## @@ -0,0 +1,135 @@ +// 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. + +// Refresher executes a backend service whose single job is to refresh a quota. +// To execute, simply run as a normal go executable. The application relies on +// environment variables for ease and compatibility with conventional cloud +// deployments such as a Kubernetes deployment specification. +// The executable reports missing required environment variables and serves +// as its own self-documenting usage. +// +// See logging.LevelVariable for details on how to change the log level. +package main + +import ( + "context" + "strconv" + "time" + + "github.com/apache/beam/test-infra/pipelines/src/main/go/internal/cache" + "github.com/apache/beam/test-infra/pipelines/src/main/go/internal/environment" + "github.com/apache/beam/test-infra/pipelines/src/main/go/internal/logging" + "github.com/redis/go-redis/v9" + "sigs.k8s.io/controller-runtime/pkg/manager/signals" +) + +var ( + required = []environment.Variable{ + cache.Host, + cache.QuotaId, + cache.QuotaSize, + cache.QuotaRefreshInterval, + } + + size uint64 + interval time.Duration + + logger = logging.New( + context.Background(), + "github.com/apache/beam/.test-infra/pipelines/src/main/go/cmd/api_overuse_study/refresher", + logging.LevelVariable) + cacheRefresher cache.Refresher + subscriber cache.Subscriber + + env = logging.Any("env", environment.Map(required...)) Review Comment: Please see https://github.com/apache/beam/pull/27158#discussion_r1237308304. Though in all cases I should have `env = logging.Any("env", environment.Map(required...))`. It's private and really only meant for re-usable debugging. When you deploy resources in Kubernetes, unless you clearly show what is missing or not configured, can be cumbersome without a consistent method to report this in the logs. -- 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]
