Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: client/internal/logdog/butler/bundler/bundler.go

Issue 1276923003: logdog: Add bundler library. (Closed) Base URL: https://github.com/luci/luci-go@logdog-review-streamserver
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package bundler
6
7 import (
8 "github.com/luci/luci-go/common/logdog/protocol"
9 )
10
11 // Config contains configuration information for a Bundler instance.
12 type Config struct {
13 // Sizer is the Sizer instance to use to help with Bundler accounting.
tandrii(chromium) 2015/08/11 14:06:07 start comment with func name "// NewSizer
dnj (Google) 2015/08/11 16:24:00 Done.
14 // If nil, a FastSizer will be used.
15 NewSizer func(*protocol.ButlerLogBundle) Sizer
16 }
17
18 // Sizer is a stateful instance that tracks the size of LogDog ButlerLogBundle
19 // protobufs as they are constructed.
20 //
21 // A Sizer may overestimate the size, but it should strive to never
22 // underestimate the size.
23 type Sizer interface {
24 // Size returns the current size.
25 Size() int
tandrii(chromium) 2015/08/11 14:06:07 is int enough? maybe int64?
dnj (Google) 2015/08/11 16:24:00 Int should be enough, since in practice the size c
26
27 // AppendBundleEntry adds a ButlerLogBundle_Entry to the Sizer and retur ns
28 // its calculated size.
29 AppendBundleEntry(*protocol.ButlerLogBundle_Entry)
tandrii(chromium) 2015/08/11 14:06:07 this doesn't return
dnj (Google) 2015/08/11 16:24:01 It sure doesn't. Done.
30
31 // AppendLogEntry adds a LogEntry to the Sizer and returns its calculate d
32 // size.
33 AppendLogEntry(*protocol.ButlerLogBundle_Entry, *protocol.LogEntry)
tandrii(chromium) 2015/08/11 14:06:07 this doesn't return
dnj (Google) 2015/08/11 16:24:01 Acknowledged.
34 }
35
36 // Bundler aggregates multiple Butler log bundle entries together into a single
37 // log bundle. A Bundler is not goroutine-safe.
38 //
39 // A Bundler can vet incoming data, rejecting it if its serialized protobuf
40 // exceeds a size threshold. For efficiency, the Bundler performs a conservative
41 // estimate of the sizes.
42 type Bundler interface {
43 // Append adds a single stream's bundle entry to the Bundler.
44 Append(*protocol.ButlerLogBundle_Entry)
45
46 // Bundle converts the current set of buffered log data into a series of
tandrii(chromium) 2015/08/11 14:06:07 nit: s/Bundle/GetBundles
dnj (Google) 2015/08/11 16:24:00 Done.
47 // ButlerLogBundle instances. Afterwards, the Bundler will no longer con tain
48 // any buffered data.
49 //
50 // If the supplied threshold value is greater than zero, the returned bu ndle
51 // will only contain enough log messages such that its serialized protob uf
52 // byte count is less or equal to the threshold.
53 //
54 // Bundle may return nil if the Bundler has no accumulated data.
55 GetBundles(int) []*protocol.ButlerLogBundle
56
57 // Size returns the Bundler's current size.
58 Size() int
59
60 // Empty returns true if the Bundler has no buffered log data.
61 Empty() bool
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698