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

Side by Side Diff: logdog/common/storage/storage.go

Issue 2435883002: LogDog: Fix archival Get/Tail implementations. (Closed)
Patch Set: LogDog: Fix archival Get/Tail implementations. Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package storage 5 package storage
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "time" 9 "time"
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // GetRequest is a request to retrieve a series of LogEntry records. 54 // GetRequest is a request to retrieve a series of LogEntry records.
55 type GetRequest struct { 55 type GetRequest struct {
56 // Project is the project name of the stream. 56 // Project is the project name of the stream.
57 Project config.ProjectName 57 Project config.ProjectName
58 // Path is the stream path to retrieve. 58 // Path is the stream path to retrieve.
59 Path types.StreamPath 59 Path types.StreamPath
60 // Index is the entry's stream index. 60 // Index is the entry's stream index.
61 Index types.MessageIndex 61 Index types.MessageIndex
62 62
63 // Limit is the maximum number of records to return before stopping iter ation. 63 // Limit is the maximum number of records to return before stopping iter ation.
64 » // If zero, no maximum limit will be applied. 64 » // If <= 0, no maximum limit will be applied.
65 // 65 //
66 // The Storage instance may return fewer records than the supplied Limit as an 66 // The Storage instance may return fewer records than the supplied Limit as an
67 // implementation detail. 67 // implementation detail.
68 Limit int 68 Limit int
69 // KeysOnly, if true, allows (but doesn't require) the Storage instance to 69 // KeysOnly, if true, allows (but doesn't require) the Storage instance to
70 // omit entry data in its get callback. For scanning operations, this ca n be 70 // omit entry data in its get callback. For scanning operations, this ca n be
71 // much cheaper/faster than full data queries. 71 // much cheaper/faster than full data queries.
72 KeysOnly bool 72 KeysOnly bool
73 } 73 }
74 74
75 // GetCallback is invoked for each record in the Get request. If it returns 75 // GetCallback is invoked for each record in the Get request. If it returns
76 // false, iteration should stop. 76 // false, iteration should stop.
77 type GetCallback func(types.MessageIndex, []byte) bool 77 //
78 // The MessageIndex may be -1 if the message index isn't known. In this case,
79 // the caller will have to unmarshal the log entry data to determine its index.
80 type GetCallback func(*Entry) bool
78 81
79 // Storage is an abstract LogDog storage implementation. Interfaces implementing 82 // Storage is an abstract LogDog storage implementation. Interfaces implementing
80 // this may be used to store and retrieve log records by the collection service 83 // this may be used to store and retrieve log records by the collection service
81 // layer. 84 // layer.
82 // 85 //
83 // All of these methods must be synchronous and goroutine-safe. 86 // All of these methods must be synchronous and goroutine-safe.
84 // 87 //
85 // All methods may return errors.Transient errors if they encounter an error 88 // All methods may return errors.Transient errors if they encounter an error
86 // that may be transient. 89 // that may be transient.
87 type Storage interface { 90 type Storage interface {
(...skipping 14 matching lines...) Expand all
102 // requested based on availability or implementation details; consequent ly, 105 // requested based on availability or implementation details; consequent ly,
103 // receiving fewer than requsted records does not necessarily mean that more 106 // receiving fewer than requsted records does not necessarily mean that more
104 // records are not available. 107 // records are not available.
105 // 108 //
106 // Returns nil if retrieval executed successfully, ErrDoesNotExist if 109 // Returns nil if retrieval executed successfully, ErrDoesNotExist if
107 // the requested stream does not exist, and an error if an error occurre d 110 // the requested stream does not exist, and an error if an error occurre d
108 // during retrieval. 111 // during retrieval.
109 Get(GetRequest, GetCallback) error 112 Get(GetRequest, GetCallback) error
110 113
111 // Tail retrieves the latest log in the stream. If the stream has no log s, it 114 // Tail retrieves the latest log in the stream. If the stream has no log s, it
112 » // will return ErrDoesNotExist. 115 » // will fail with ErrDoesNotExist.
113 » Tail(config.ProjectName, types.StreamPath) ([]byte, types.MessageIndex, error) 116 » //
117 » // The MessageIndex may be -1 if the message index isn't known. In this case,
118 » // the caller will have to unmarshal the log entry data to determine its
119 » // index.
120 » Tail(config.ProjectName, types.StreamPath) (*Entry, error)
114 121
115 // Config installs the supplied configuration parameters into the storag e 122 // Config installs the supplied configuration parameters into the storag e
116 // instance. 123 // instance.
117 Config(Config) error 124 Config(Config) error
118 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698