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

Side by Side Diff: logdog/client/butlerlib/streamproto/properties.go

Issue 2456953003: LogDog: Update client/bootstrap to generate URLs. (Closed)
Patch Set: Winders Created 4 years, 1 month 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
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package streamproto 5 package streamproto
6 6
7 import ( 7 import (
8 "time" 8 "time"
9 9
10 "github.com/luci/luci-go/common/clock/clockflag" 10 "github.com/luci/luci-go/common/clock/clockflag"
11 "github.com/luci/luci-go/common/proto/google" 11 "github.com/luci/luci-go/common/proto/google"
12 "github.com/luci/luci-go/logdog/api/logpb" 12 "github.com/luci/luci-go/logdog/api/logpb"
13 "github.com/luci/luci-go/logdog/common/types" 13 "github.com/luci/luci-go/logdog/common/types"
14
15 "github.com/golang/protobuf/proto"
14 ) 16 )
15 17
16 // Properties is the set of properties needed to define a LogDog Butler Stream. 18 // Properties is the set of properties needed to define a LogDog Butler Stream.
17 type Properties struct { 19 type Properties struct {
18 // The log stream's descriptor. 20 // The log stream's descriptor.
19 // 21 //
20 // Note that the Prefix value, if filled, will be overridden by the Butl er's 22 // Note that the Prefix value, if filled, will be overridden by the Butl er's
21 // Prefix. 23 // Prefix.
22 » logpb.LogStreamDescriptor 24 » *logpb.LogStreamDescriptor
23 25
24 // Tee is the tee configuration for this stream. If empty, the stream wi ll 26 // Tee is the tee configuration for this stream. If empty, the stream wi ll
25 // not be tee'd. 27 // not be tee'd.
26 Tee TeeType 28 Tee TeeType
27 29
28 // Timeout, if specified, is the stream timeout. If a read happens witho ut 30 // Timeout, if specified, is the stream timeout. If a read happens witho ut
29 // filling the buffer, it will prematurely return after this period. 31 // filling the buffer, it will prematurely return after this period.
30 Timeout time.Duration 32 Timeout time.Duration
31 33
32 // Deadline, if set, specifies the maximum amount of time that data from this 34 // Deadline, if set, specifies the maximum amount of time that data from this
33 // Stream can be buffered before being sent to its Output. 35 // Stream can be buffered before being sent to its Output.
34 // 36 //
35 // Note that this value is best-effort, as it is subject to the constrai nts 37 // Note that this value is best-effort, as it is subject to the constrai nts
36 // of the underlying transport medium. 38 // of the underlying transport medium.
37 Deadline time.Duration 39 Deadline time.Duration
38 } 40 }
39 41
40 // Validate validates that the configured Properties are valid and sufficient to 42 // Validate validates that the configured Properties are valid and sufficient to
41 // create a Butler stream. 43 // create a Butler stream.
42 // 44 //
43 // It skips stream Prefix validation and instead asserts that it is empty, as 45 // It skips stream Prefix validation and instead asserts that it is empty, as
44 // it should not be populated when Properties are defined. 46 // it should not be populated when Properties are defined.
45 func (p *Properties) Validate() error { 47 func (p *Properties) Validate() error {
46 if err := p.LogStreamDescriptor.Validate(false); err != nil { 48 if err := p.LogStreamDescriptor.Validate(false); err != nil {
47 return err 49 return err
48 } 50 }
49 return nil 51 return nil
50 } 52 }
51 53
54 // Clone returns a fully-independent clone of this Properties object.
55 func (p *Properties) Clone() *Properties {
56 clone := *p
57 clone.LogStreamDescriptor = proto.Clone(p.LogStreamDescriptor).(*logpb.L ogStreamDescriptor)
58 return &clone
59 }
60
52 // Flags is a flag- and JSON-compatible collapse of Properties. It is used 61 // Flags is a flag- and JSON-compatible collapse of Properties. It is used
53 // for stream negotiation protocol and command-line interfaces. 62 // for stream negotiation protocol and command-line interfaces.
54 type Flags struct { 63 type Flags struct {
55 Name StreamNameFlag `json:"name,omitempty"` 64 Name StreamNameFlag `json:"name,omitempty"`
56 ContentType string `json:"contentType,omitempty"` 65 ContentType string `json:"contentType,omitempty"`
57 Type StreamType `json:"type,omitempty"` 66 Type StreamType `json:"type,omitempty"`
58 Timestamp clockflag.Time `json:"timestamp,omitempty"` 67 Timestamp clockflag.Time `json:"timestamp,omitempty"`
59 Tags TagMap `json:"tags,omitempty"` 68 Tags TagMap `json:"tags,omitempty"`
60 BinaryFileExtension string `json:"binaryFileExtension,omitempty" ` 69 BinaryFileExtension string `json:"binaryFileExtension,omitempty" `
61 70
62 Tee TeeType `json:"tee,omitempty"` 71 Tee TeeType `json:"tee,omitempty"`
63 Timeout clockflag.Duration `json:"timeout,omitempty"` 72 Timeout clockflag.Duration `json:"timeout,omitempty"`
64 Deadline clockflag.Duration `json:"deadline,omitempty"` 73 Deadline clockflag.Duration `json:"deadline,omitempty"`
65 } 74 }
66 75
67 // Properties converts the Flags to a standard Properties structure. 76 // Properties converts the Flags to a standard Properties structure.
68 // 77 //
69 // If the values are not valid, this conversion will return an error. 78 // If the values are not valid, this conversion will return an error.
70 func (f *Flags) Properties() *Properties { 79 func (f *Flags) Properties() *Properties {
71 contentType := types.ContentType(f.ContentType) 80 contentType := types.ContentType(f.ContentType)
72 if contentType == "" { 81 if contentType == "" {
73 contentType = f.Type.DefaultContentType() 82 contentType = f.Type.DefaultContentType()
74 } 83 }
75 84
76 p := &Properties{ 85 p := &Properties{
77 » » LogStreamDescriptor: logpb.LogStreamDescriptor{ 86 » » LogStreamDescriptor: &logpb.LogStreamDescriptor{
78 Name: string(f.Name), 87 Name: string(f.Name),
79 ContentType: string(contentType), 88 ContentType: string(contentType),
80 StreamType: logpb.StreamType(f.Type), 89 StreamType: logpb.StreamType(f.Type),
81 Timestamp: google.NewTimestamp(time.Time(f.Timestamp )), 90 Timestamp: google.NewTimestamp(time.Time(f.Timestamp )),
82 BinaryFileExt: f.BinaryFileExtension, 91 BinaryFileExt: f.BinaryFileExtension,
83 Tags: f.Tags, 92 Tags: f.Tags,
84 }, 93 },
85 Tee: f.Tee, 94 Tee: f.Tee,
86 Timeout: time.Duration(f.Timeout), 95 Timeout: time.Duration(f.Timeout),
87 Deadline: time.Duration(f.Deadline), 96 Deadline: time.Duration(f.Deadline),
88 } 97 }
89 return p 98 return p
90 } 99 }
OLDNEW
« no previous file with comments | « logdog/client/butlerlib/streamclient/stream_test.go ('k') | logdog/client/butlerlib/streamproto/properties_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698