| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 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 logdog | 5 package logdog |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | |
| 9 | |
| 10 miloProto "github.com/luci/luci-go/common/proto/milo" | 8 miloProto "github.com/luci/luci-go/common/proto/milo" |
| 11 ) | 9 ) |
| 12 | 10 |
| 13 // Streams represents a group of LogDog Streams with a single entry point. | 11 // Streams represents a group of LogDog Streams with a single entry point. |
| 14 // Generally all of the streams are referenced by the entry point. | 12 // Generally all of the streams are referenced by the entry point. |
| 15 type Streams struct { | 13 type Streams struct { |
| 16 // MainStream is a pointer to the primary stream for this group of strea
ms. | 14 // MainStream is a pointer to the primary stream for this group of strea
ms. |
| 17 MainStream *Stream | 15 MainStream *Stream |
| 18 // Streams is the full map streamName->stream referenced by MainStream. | 16 // Streams is the full map streamName->stream referenced by MainStream. |
| 19 // It includes MainStream. | 17 // It includes MainStream. |
| 20 Streams map[string]*Stream | 18 Streams map[string]*Stream |
| 21 } | 19 } |
| 22 | 20 |
| 23 // GetFullPath returns the canonical URL of the logdog stream. | |
| 24 func (s *Stream) GetFullPath() string { | |
| 25 return fmt.Sprintf("https://%s/%s/+/%s", s.Server, s.Prefix, s.Path) | |
| 26 } | |
| 27 | |
| 28 // Stream represents a single LogDog style stream, which can contain either | 21 // Stream represents a single LogDog style stream, which can contain either |
| 29 // annotations (assumed to be MiloProtos) or text. Other types of annotations a
re | 22 // annotations (assumed to be MiloProtos) or text. Other types of annotations a
re |
| 30 // not supported. | 23 // not supported. |
| 31 type Stream struct { | 24 type Stream struct { |
| 32 // Server is the LogDog server this stream originated from. | 25 // Server is the LogDog server this stream originated from. |
| 33 Server string | 26 Server string |
| 34 // Prefix is the LogDog prefix for the Stream. | 27 // Prefix is the LogDog prefix for the Stream. |
| 35 Prefix string | 28 Prefix string |
| 36 // Path is the final part of the LogDog path of the Stream. | 29 // Path is the final part of the LogDog path of the Stream. |
| 37 Path string | 30 Path string |
| 38 // IsDatagram is true if this is a MiloProto. False implies that this is
a text log. | 31 // IsDatagram is true if this is a MiloProto. False implies that this is
a text log. |
| 39 IsDatagram bool | 32 IsDatagram bool |
| 40 // Data is the miloProto.Step of the Stream, if IsDatagram is true. Oth
erwise | 33 // Data is the miloProto.Step of the Stream, if IsDatagram is true. Oth
erwise |
| 41 // this is nil. | 34 // this is nil. |
| 42 Data *miloProto.Step | 35 Data *miloProto.Step |
| 43 // Text is the text of the Stream, if IsDatagram is false. Otherwise | 36 // Text is the text of the Stream, if IsDatagram is false. Otherwise |
| 44 // this is an empty string. | 37 // this is an empty string. |
| 45 Text string | 38 Text string |
| 46 | 39 |
| 47 // Closed specifies whether Text or Data may change in the future. | 40 // Closed specifies whether Text or Data may change in the future. |
| 48 // If Closed, they may not. | 41 // If Closed, they may not. |
| 49 Closed bool | 42 Closed bool |
| 50 } | 43 } |
| OLD | NEW |