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

Unified Diff: server/logdog/storage/archive/storage.go

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Fix proto comment. 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 | « server/logdog/archive/archive.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: server/logdog/storage/archive/storage.go
diff --git a/server/logdog/storage/archive/storage.go b/server/logdog/storage/archive/storage.go
index 84ba12df14f02e5dbe6176ddb0755e8cfefdd4fb..be5f556f55f3a85f1d1e9f134feac0d4e489b78f 100644
--- a/server/logdog/storage/archive/storage.go
+++ b/server/logdog/storage/archive/storage.go
@@ -14,11 +14,10 @@ package archive
import (
"bytes"
- "errors"
+ "fmt"
"io"
"io/ioutil"
"sort"
- "strings"
"sync"
"golang.org/x/net/context"
@@ -61,10 +60,8 @@ type storageImpl struct {
*Options
context.Context
- streamBucket string
- streamPath string
- indexBucket string
- indexPath string
+ streamPath gs.Path
+ indexPath gs.Path
indexMu sync.Mutex
index *logpb.LogIndex
@@ -76,17 +73,18 @@ func New(ctx context.Context, o Options) (storage.Storage, error) {
s := storageImpl{
Options: &o,
Context: ctx,
- }
- s.indexBucket, s.indexPath = splitGSURL(o.IndexURL)
- if s.indexBucket == "" || s.indexPath == "" {
- return nil, errors.New("invalid index URL")
+ streamPath: gs.Path(o.StreamURL),
+ indexPath: gs.Path(o.IndexURL),
}
- s.streamBucket, s.streamPath = splitGSURL(o.StreamURL)
- if s.streamBucket == "" || s.streamPath == "" {
- return nil, errors.New("invalid stream URL")
+ if !s.streamPath.IsFullPath() {
+ return nil, fmt.Errorf("invalid stream URL: %q", s.streamPath)
+ }
+ if !s.indexPath.IsFullPath() {
+ return nil, fmt.Errorf("invalid index URL: %v", s.indexPath)
}
+
return &s, nil
}
@@ -112,7 +110,7 @@ func (s *storageImpl) Get(req storage.GetRequest, cb storage.GetCallback) error
return nil
}
- r, err := s.Client.NewReader(s.streamBucket, s.streamPath, gs.Options{
+ r, err := s.Client.NewReader(s.streamPath, gs.Options{
From: st.from,
To: st.to,
})
@@ -207,7 +205,7 @@ func (s *storageImpl) Tail(path types.StreamPath) ([]byte, types.MessageIndex, e
lle := idx.Entries[len(idx.Entries)-1]
// Get a Reader for the Tail entry.
- r, err := s.Client.NewReader(s.streamBucket, s.streamPath, gs.Options{
+ r, err := s.Client.NewReader(s.streamPath, gs.Options{
From: int64(lle.Offset),
})
if err != nil {
@@ -239,7 +237,7 @@ func (s *storageImpl) getIndex() (*logpb.LogIndex, error) {
defer s.indexMu.Unlock()
if s.index == nil {
- r, err := s.Client.NewReader(s.indexBucket, s.indexPath, gs.Options{})
+ r, err := s.Client.NewReader(s.indexPath, gs.Options{})
if err != nil {
log.WithError(err).Errorf(s, "Failed to create index Reader.")
return nil, err
@@ -266,14 +264,6 @@ func (s *storageImpl) getIndex() (*logpb.LogIndex, error) {
return s.index, nil
}
-func splitGSURL(u string) (string, string) {
- parts := strings.SplitN(strings.TrimPrefix(u, "gs://"), "/", 2)
- if len(parts) == 1 {
- return parts[0], ""
- }
- return parts[0], parts[1]
-}
-
type getStrategy struct {
// from is the beginning byte offset of the log entry stream.
from int64
« no previous file with comments | « server/logdog/archive/archive.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698