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

Side by Side Diff: client/cmd/logdog_cat/coordinatorSource.go

Issue 1672833003: LogDog: Add log rendering view. Base URL: https://github.com/luci/luci-go@master
Patch Set: Clean up, add tests, little reorg. Created 4 years, 10 months 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
« no previous file with comments | « appengine/logdog/coordinator/service.go ('k') | common/logdog/coordinator/stream_params.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "math"
9 "sync" 10 "sync"
10 "time" 11 "time"
11 12
12 "github.com/luci/luci-go/common/clock" 13 "github.com/luci/luci-go/common/clock"
13 "github.com/luci/luci-go/common/logdog/coordinator" 14 "github.com/luci/luci-go/common/logdog/coordinator"
14 "github.com/luci/luci-go/common/logdog/fetcher" 15 "github.com/luci/luci-go/common/logdog/fetcher"
15 "github.com/luci/luci-go/common/logdog/types" 16 "github.com/luci/luci-go/common/logdog/types"
16 log "github.com/luci/luci-go/common/logging" 17 log "github.com/luci/luci-go/common/logging"
17 "github.com/luci/luci-go/common/proto/logdog/logpb" 18 "github.com/luci/luci-go/common/proto/logdog/logpb"
18 "golang.org/x/net/context" 19 "golang.org/x/net/context"
(...skipping 16 matching lines...) Expand all
35 tidx types.MessageIndex 36 tidx types.MessageIndex
36 37
37 state coordinator.LogStream 38 state coordinator.LogStream
38 } 39 }
39 40
40 func (s *coordinatorSource) LogEntries(c context.Context, req *fetcher.LogReques t) ( 41 func (s *coordinatorSource) LogEntries(c context.Context, req *fetcher.LogReques t) (
41 []*logpb.LogEntry, types.MessageIndex, error) { 42 []*logpb.LogEntry, types.MessageIndex, error) {
42 s.Lock() 43 s.Lock()
43 defer s.Unlock() 44 defer s.Unlock()
44 45
45 » p := coordinator.NewGetParams().Limit(int(req.Bytes), req.Count).Index(r eq.Index) 46 » // Limit our constraints to int32.
47 » bytes, count := req.Bytes, req.Count
48 » if bytes > math.MaxInt32 {
49 » » bytes = math.MaxInt32
50 » }
51 » if count > math.MaxInt32 {
52 » » count = math.MaxInt32
53 » }
54
55 » p := coordinator.NewGetParams().Limit(int32(bytes), int32(count)).Index( req.Index)
46 56
47 // If we haven't terminated, use this opportunity to fetch/update our st ream 57 // If we haven't terminated, use this opportunity to fetch/update our st ream
48 // state. 58 // state.
49 if s.tidx < 0 { 59 if s.tidx < 0 {
50 p = p.State(&s.state) 60 p = p.State(&s.state)
51 } 61 }
52 62
53 for { 63 for {
54 logs, err := s.stream.Get(c, p) 64 logs, err := s.stream.Get(c, p)
55 switch err { 65 switch err {
(...skipping 28 matching lines...) Expand all
84 defer s.Unlock() 94 defer s.Unlock()
85 return s.state 95 return s.state
86 } 96 }
87 97
88 func (s *coordinatorSource) descriptor() (*logpb.LogStreamDescriptor, error) { 98 func (s *coordinatorSource) descriptor() (*logpb.LogStreamDescriptor, error) {
89 if d := s.state.Desc; d != nil { 99 if d := s.state.Desc; d != nil {
90 return d, nil 100 return d, nil
91 } 101 }
92 return nil, errors.New("no descriptor loaded") 102 return nil, errors.New("no descriptor loaded")
93 } 103 }
OLDNEW
« no previous file with comments | « appengine/logdog/coordinator/service.go ('k') | common/logdog/coordinator/stream_params.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698