go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/logdog/client/butler/output/null/null.go (about) 1 // Copyright 2019 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 null 16 17 import ( 18 "sync" 19 20 "github.com/golang/protobuf/proto" 21 22 "go.chromium.org/luci/logdog/api/logpb" 23 "go.chromium.org/luci/logdog/client/butler/bootstrap" 24 "go.chromium.org/luci/logdog/client/butler/output" 25 ) 26 27 // Output implements the butler output.Output interface, but sends the data 28 // nowhere. 29 // 30 // Output does collect stats, however. 31 type Output struct { 32 statsMu sync.RWMutex 33 stats output.StatsBase 34 } 35 36 var _ output.Output = (*Output)(nil) 37 38 // SendBundle implements output.Output 39 func (o *Output) SendBundle(b *logpb.ButlerLogBundle) error { 40 o.statsMu.Lock() 41 defer o.statsMu.Unlock() 42 o.stats.F.SentMessages += int64(len(b.Entries)) 43 o.stats.F.SentBytes += int64(proto.Size(b)) 44 return nil 45 } 46 47 // MaxSendBundles implements output.Output 48 func (o *Output) MaxSendBundles() int { 49 return 1 50 } 51 52 // Stats implements output.Output 53 func (o *Output) Stats() output.Stats { 54 o.statsMu.RLock() 55 defer o.statsMu.RUnlock() 56 statsCp := o.stats 57 return &statsCp 58 } 59 60 // URLConstructionEnv implements output.Output 61 func (o *Output) URLConstructionEnv() bootstrap.Environment { 62 return bootstrap.Environment{ 63 Project: "null", 64 Prefix: "null", 65 } 66 } 67 68 // MaxSize returns a large number instead of 0 because butler has bugs. 69 func (o *Output) MaxSize() int { return 1024 * 1024 * 1024 } 70 71 // Close implements output.Output 72 func (o *Output) Close() {}