@@ -16,8 +16,7 @@ type Record struct {
1616 Conditions []data.ConditionType
1717
1818 sync.RWMutex
19- initialized chan struct {}
20- disposed chan struct {}
19+ disposed chan struct {}
2120
2221 PastEvents []data.Event
2322 EventsByID map [uuid.UUID ]data.Event
@@ -33,43 +32,11 @@ func NewRecord(id string, conditionTypes []data.ConditionType) *Record {
3332 conditions [i ] = data .NewCondition (cond , time.Time {}, nil , nil )
3433 }
3534 return & Record {
36- ID : id ,
37- Conditions : conditionTypes ,
38- initialized : make (chan struct {}),
39- disposed : make (chan struct {}),
40- EventsByID : map [uuid.UUID ]data.Event {},
41- LastStatus : data .NewHealthStatus (id , conditions ),
42- }
43- }
44-
45- // FlagInitialized will flag the record as initialized. It is meant to be called
46- // after the first event is processed, meaning the record is not empty anymore.
47- //
48- // This is used to allow waiting until a stream is started by creating its
49- // record in an uninitialized state first and calling `WaitInitialized`. The
50- // initialization flag is simply a channel that is closed, which will unblock
51- // all goroutines waiting to receive from it (`WaitInitialized`).
52- func (r * Record ) FlagInitialized () {
53- if ! r .IsInitialized () {
54- close (r .initialized )
55- }
56- }
57-
58- func (r * Record ) IsInitialized () bool {
59- select {
60- case <- r .initialized :
61- return true
62- default :
63- return false
64- }
65- }
66-
67- func (r * Record ) WaitInitialized (ctx context.Context ) error {
68- select {
69- case <- r .initialized :
70- return nil
71- case <- ctx .Done ():
72- return ctx .Err ()
35+ ID : id ,
36+ Conditions : conditionTypes ,
37+ disposed : make (chan struct {}),
38+ EventsByID : map [uuid.UUID ]data.Event {},
39+ LastStatus : data .NewHealthStatus (id , conditions ),
7340 }
7441}
7542
@@ -135,10 +102,7 @@ func (s *RecordStorage) StartCleanupLoop(ctx context.Context, ttl time.Duration)
135102
136103func (s * RecordStorage ) Get (id string ) (* Record , bool ) {
137104 if saved , ok := s .records .Load (id ); ok {
138- // Until Initialize is called, the record is considered inexistent
139- if record := saved .(* Record ); record .IsInitialized () {
140- return record , true
141- }
105+ return saved .(* Record ), true
142106 }
143107 return nil , false
144108}
0 commit comments