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

Unified Diff: common/gcloud/gs/gs.go

Issue 1904503003: LogDog: Fix archived log stream read errors. (Closed) Base URL: https://github.com/luci/luci-go@hierarchy-check-first
Patch Set: Delete "offset()" method. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/logdog/coordinator/endpoints/logs/get_test.go ('k') | common/recordio/size.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/gcloud/gs/gs.go
diff --git a/common/gcloud/gs/gs.go b/common/gcloud/gs/gs.go
index be2bdee9a2844cedb787777cc1b284bde9b9a05c..70e50db6a61c1d21b937d035897cd3127b67a5b0 100644
--- a/common/gcloud/gs/gs.go
+++ b/common/gcloud/gs/gs.go
@@ -37,7 +37,11 @@ type Client interface {
io.Closer
// NewReader instantiates a new Reader instance for the named bucket/path.
- NewReader(p Path, o Options) (io.ReadCloser, error)
+ //
+ // The supplied offset must be >= 0, or else this function will panic.
+ //
+ // If the supplied length is <0, no upper byte bound will be set.
+ NewReader(p Path, offset, length int64) (io.ReadCloser, error)
// NewWriter instantiates a new Writer instance for the named bucket/path.
NewWriter(p Path) (Writer, error)
@@ -55,19 +59,6 @@ type Client interface {
Rename(src, dst Path) error
}
-// Options are the set of extra options to apply to the Google Storage request.
-type Options struct {
- // From is the range request starting index. If >0, the beginning of the
- // range request will be set.
- From int64
- // To is the range request ending index. If >0, the end of the
- // range request will be set.
- //
- // If no From index is set, this will result in a request indexed from the end
- // of the object.
- To int64
-}
-
// prodGSObject is an implementation of Client interface using the production
// Google Storage client.
type prodClient struct {
@@ -116,19 +107,16 @@ func (c *prodClient) NewWriter(p Path) (Writer, error) {
}, nil
}
-func (c *prodClient) NewReader(p Path, o Options) (io.ReadCloser, error) {
- if o.From < 0 {
- o.From = 0
- }
- if o.To <= 0 {
- o.To = -1
+func (c *prodClient) NewReader(p Path, offset, length int64) (io.ReadCloser, error) {
+ if offset < 0 {
+ panic(fmt.Errorf("offset (%d) must be >= 0", offset))
}
obj, err := c.handleForPath(p)
if err != nil {
return nil, err
}
- return obj.NewRangeReader(c, o.From, o.To)
+ return obj.NewRangeReader(c, offset, length)
}
func (c *prodClient) Rename(src, dst Path) error {
« no previous file with comments | « appengine/logdog/coordinator/endpoints/logs/get_test.go ('k') | common/recordio/size.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698