go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/resultdb/cmd/bqexporter/main.go (about) 1 // Copyright 2020 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package main 16 17 import ( 18 "flag" 19 20 "golang.org/x/time/rate" 21 22 "go.chromium.org/luci/server" 23 24 "go.chromium.org/luci/resultdb/internal" 25 "go.chromium.org/luci/resultdb/internal/artifactcontent" 26 "go.chromium.org/luci/resultdb/internal/services/bqexporter" 27 ) 28 29 func main() { 30 opts := bqexporter.DefaultOptions() 31 flag.BoolVar(&opts.UseInsertIDs, "insert-ids", opts.UseInsertIDs, 32 "Use InsertIDs when inserting data to BigQuery") 33 flag.IntVar(&opts.MaxBatchSizeApprox, "max-batch-size-approx", opts.MaxBatchSizeApprox, 34 "Maximum size of a batch in bytes, approximate") 35 flag.IntVar(&opts.MaxBatchTotalSizeApprox, "batch-total-size-approx", opts.MaxBatchTotalSizeApprox, 36 "Maximum total size of batches in bytes, approximate") 37 rateLimit := int(opts.RateLimit) 38 flag.IntVar(&rateLimit, "rate-limit", rateLimit, 39 "Maximum BigQuery request rate") 40 artifactcontent.RegisterRBEInstanceFlag(flag.CommandLine, &opts.ArtifactRBEInstance) 41 42 internal.Main(func(srv *server.Server) error { 43 opts.RateLimit = rate.Limit(rateLimit) 44 return bqexporter.InitServer(srv, opts) 45 }) 46 }