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

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: Updated from review. Created 5 years, 3 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
« no previous file with comments | « no previous file | client/internal/logdog/butler/bundler/bundler_impl.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Deterministic, if true, ensures that logs are bundled deterministical ly.
24 Deterministic bool
25
26 // NewSizer is the Sizer instance to use to help with Bundler accounting .
27 // If nil, a FastSizer will be used.
28 NewSizer func(*protocol.ButlerLogBundle) Sizer
29
30 // DropCallback, if not nil, is invoked if log entries had to be dropped . This
31 // will only occur when the entries individually violate the threshold.
32 DropCallback func(*protocol.ButlerLogBundle_Entry)
33 }
34
35 // Sizer is a stateful instance that tracks the size of LogDog ButlerLogBundle
36 // protobufs as they are constructed.
37 //
38 // A Sizer may overestimate the size, but it should strive to never
39 // underestimate the size.
40 type Sizer interface {
41 // Size returns the current size.
42 Size() int64
43
44 // AppendBundleEntry adds a ButlerLogBundle_Entry and an optional LogEnt ry
45 // to the Sizer.
46 Append(*protocol.ButlerLogBundle_Entry, *protocol.LogEntry)
47
48 // Undo reversed the most recent Append.
49 Undo()
50 }
51
52 // Bundler aggregates multiple Butler log bundle entries together into a single
53 // log bundle. A Bundler is not goroutine-safe.
54 //
55 // A Bundler can vet incoming data, rejecting it if its serialized protobuf
56 // exceeds a size threshold. For efficiency, the Bundler performs a conservative
57 // estimate of the sizes.
58 type Bundler interface {
59 // Append adds a single stream's bundle entry to the Bundler.
60 //
61 // The Bundler formally takes ownership of this entry and its fields
62 // (including its logs). The caller must not modify it after Append().
63 Append(*protocol.ButlerLogBundle_Entry)
64
65 // GetBundle converts the current set of buffered log data into a series of
66 // ButlerLogBundle instances.
67 //
68 // If the supplied threshold value is greater than zero, each returned b undle
69 // will only contain enough log messages such that its serialized protob uf
70 // byte count is less or equal to the threshold.
71 //
72 // Note: It may seem useful to have a single-bundle return function. How ever,
73 // in practice, the Bundler is used by the Butler to extract all bundles at
74 // once. Implementing the single-bundle use case would result in a lot o f
75 // unnecessary intermediate size computations.
76 //
77 // Bundle may return nil if the Bundler has no accumulated data.
78 GetBundles() []*protocol.ButlerLogBundle
79
80 // Size returns the Bundler's current size.
81 Size() int64
82
83 // Empty returns true if the Bundler has no buffered log data.
84 Empty() bool
85 }
OLDNEW
« no previous file with comments | « no previous file | client/internal/logdog/butler/bundler/bundler_impl.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698