MCPcopy Index your code
hub / github.com/cloudfoundry/cli / latestEnvelopeTimestamp

Function latestEnvelopeTimestamp

actor/sharedaction/logging.go:174–209  ·  view source on GitHub ↗
(client LogCacheClient, errs chan error, ctx context.Context, sourceID string)

Source from the content-addressed store, hash-verified

172}
173
174func latestEnvelopeTimestamp(client LogCacheClient, errs chan error, ctx context.Context, sourceID string) time.Time {
175
176 // Fetching the most recent timestamp could be implemented with client.Read directly rather than using logcache.Walk
177 // We use Walk because we want the extra retry behavior provided through Walk
178
179 // Wrap client.Read in our own function to allow us to specify our own read options
180 // https://github.com/cloudfoundry/go-log-cache/issues/27
181 r := func(ctx context.Context, sourceID string, _ time.Time, opts ...logcache.ReadOption) ([]*loggregator_v2.Envelope, error) {
182 os := []logcache.ReadOption{
183 logcache.WithLimit(1),
184 logcache.WithDescending(),
185 }
186 for _, o := range opts {
187 os = append(os, o)
188 }
189 return client.Read(ctx, sourceID, time.Time{}, os...)
190 }
191
192 var timestamp time.Time
193
194 logcache.Walk(
195 ctx,
196 sourceID,
197 logcache.Visitor(func(envelopes []*loggregator_v2.Envelope) bool {
198 timestamp = time.Unix(0, envelopes[0].Timestamp)
199 return false
200 }),
201 r,
202 logcache.WithWalkBackoff(newCliRetryBackoff(retryInterval, retryCount)),
203 logcache.WithWalkLogger(log.New(channelWriter{
204 errChannel: errs,
205 }, "", 0)),
206 )
207
208 return timestamp
209}
210
211func GetRecentLogs(appGUID string, client LogCacheClient) ([]LogMessage, error) {
212 logLineRequestCount := RecentLogsLines

Callers 1

GetStreamingLogsFunction · 0.85

Calls 2

newCliRetryBackoffFunction · 0.85
ReadMethod · 0.65

Tested by

no test coverage detected