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

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: Rewrote bundle logic (and associated updates). 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 // TemplateBundle is the base template ButlerLogBundle. Generated bundle s
14 // will be derived from a copy of this bundle.
15 //
16 // The TemplateBundle may not have any log entries. If it does, they wil l
17 // not be retained.
18 TemplateBundle protocol.ButlerLogBundle
19
20 // Threshold is the size of the LogBundle
21 Threshold int64
22
23 // NewSizer is the Sizer instance to use to help with Bundler accounting .
24 // If nil, a FastSizer will be used.
25 NewSizer func(*protocol.ButlerLogBundle) Sizer
26 }
27
28 // Sizer is a stateful instance that tracks the size of LogDog ButlerLogBundle
29 // protobufs as they are constructed.
30 //
31 // A Sizer may overestimate the size, but it should strive to never
32 // underestimate the size.
33 type Sizer interface {
34 // Size returns the current size.
35 Size() int64
36
37 // AppendBundleEntry adds a ButlerLogBundle_Entry and an optional LogEnt ry
38 // to the Sizer.
39 Append(*protocol.ButlerLogBundle_Entry, *protocol.LogEntry)
40
41 // Undo reversed the most recent Append.
iannucci 2015/09/01 03:03:21 reverses? Can it be called more than once?
dnj 2015/09/02 01:58:14 Nope.
42 Undo()
43 }
44
45 // Bundler aggregates multiple Butler log bundle entries together into a single
46 // log bundle. A Bundler is not goroutine-safe.
47 //
48 // A Bundler can vet incoming data, rejecting it if its serialized protobuf
49 // exceeds a size threshold. For efficiency, the Bundler performs a conservative
50 // estimate of the sizes.
51 type Bundler interface {
52 // Append adds a single stream's bundle entry to the Bundler.
53 //
54 // The Bundler formally takes ownership of this entry and its fields
55 // (including its logs). The caller must not modify it after Append().
56 Append(*protocol.ButlerLogBundle_Entry)
57
58 // GetBundle converts the current set of buffered log data into a series of
59 // ButlerLogBundle instances.
60 //
61 // If the supplied threshold value is greater than zero, each returned b undle
62 // will only contain enough log messages such that its serialized protob uf
63 // byte count is less or equal to the threshold.
64 //
65 // Note: It may seem useful to have a single-bundle return function. How ever,
66 // in practice, the Bundler is used by the Butler to extract all bundles at
67 // once. Implementing the single-bundle use case would result in a lot o f
68 // unnecessary intermediate size computations.
69 //
70 // Bundle may return nil if the Bundler has no accumulated data.
71 GetBundles() []*protocol.ButlerLogBundle
72
73 // Size returns the Bundler's current size.
74 Size() int64
75
76 // Empty returns true if the Bundler has no buffered log data.
77 Empty() bool
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698