-
Notifications
You must be signed in to change notification settings - Fork 0
/
old_fake_loggregator_consumer.go
68 lines (52 loc) · 1.55 KB
/
old_fake_loggregator_consumer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package apifakes
import (
"github.com/cloudfoundry/loggregator_consumer"
"github.com/cloudfoundry/loggregatorlib/logmessage"
)
type OldFakeLoggregatorConsumer struct {
RecentCalledWith struct {
AppGUID string
AuthToken string
}
RecentReturns struct {
Messages []*logmessage.LogMessage
Err []error
callIndex int
}
TailFunc func(appGUID, token string) (<-chan *logmessage.LogMessage, error)
IsClosed bool
OnConnectCallback func()
closeChan chan bool
}
func NewFakeLoggregatorConsumer() *OldFakeLoggregatorConsumer {
return &OldFakeLoggregatorConsumer{
closeChan: make(chan bool, 1),
}
}
func (c *OldFakeLoggregatorConsumer) Recent(appGUID string, authToken string) ([]*logmessage.LogMessage, error) {
c.RecentCalledWith.AppGUID = appGUID
c.RecentCalledWith.AuthToken = authToken
var err error
if c.RecentReturns.callIndex < len(c.RecentReturns.Err) {
err = c.RecentReturns.Err[c.RecentReturns.callIndex]
c.RecentReturns.callIndex++
}
return c.RecentReturns.Messages, err
}
func (c *OldFakeLoggregatorConsumer) Close() error {
c.IsClosed = true
c.closeChan <- true
return nil
}
func (c *OldFakeLoggregatorConsumer) SetOnConnectCallback(cb func()) {
c.OnConnectCallback = cb
}
func (c *OldFakeLoggregatorConsumer) Tail(appGUID string, authToken string) (<-chan *logmessage.LogMessage, error) {
return c.TailFunc(appGUID, authToken)
}
func (c *OldFakeLoggregatorConsumer) WaitForClose() {
<-c.closeChan
}
func (c *OldFakeLoggregatorConsumer) SetDebugPrinter(debugPrinter loggregator_consumer.DebugPrinter) {
<-c.closeChan
}