| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 storage | 5 package storage |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "time" | 9 "time" |
| 10 | 10 |
| 11 "github.com/luci/luci-go/common/config" |
| 11 "github.com/luci/luci-go/common/logdog/types" | 12 "github.com/luci/luci-go/common/logdog/types" |
| 12 ) | 13 ) |
| 13 | 14 |
| 14 var ( | 15 var ( |
| 15 // ErrExists returned if an attempt is made to overwrite an existing rec
ord. | 16 // ErrExists returned if an attempt is made to overwrite an existing rec
ord. |
| 16 ErrExists = errors.New("storage: record exists") | 17 ErrExists = errors.New("storage: record exists") |
| 17 | 18 |
| 18 // ErrDoesNotExist returned if an attempt is made to read a record that | 19 // ErrDoesNotExist returned if an attempt is made to read a record that |
| 19 // doesn't exist. | 20 // doesn't exist. |
| 20 ErrDoesNotExist = errors.New("storage: record does not exist") | 21 ErrDoesNotExist = errors.New("storage: record does not exist") |
| (...skipping 10 matching lines...) Expand all Loading... |
| 31 // instance. | 32 // instance. |
| 32 type Config struct { | 33 type Config struct { |
| 33 // MaxLogAge is the maximium amount of time that a log entry must be kep
t for. | 34 // MaxLogAge is the maximium amount of time that a log entry must be kep
t for. |
| 34 // The Storage instance is welcome to delete any log entries that exceed
this | 35 // The Storage instance is welcome to delete any log entries that exceed
this |
| 35 // age. | 36 // age. |
| 36 MaxLogAge time.Duration | 37 MaxLogAge time.Duration |
| 37 } | 38 } |
| 38 | 39 |
| 39 // PutRequest describes adding a single storage record to BigTable. | 40 // PutRequest describes adding a single storage record to BigTable. |
| 40 type PutRequest struct { | 41 type PutRequest struct { |
| 42 // Project is the project name of the stream. |
| 43 Project config.ProjectName |
| 41 // Path is the stream path to retrieve. | 44 // Path is the stream path to retrieve. |
| 42 Path types.StreamPath | 45 Path types.StreamPath |
| 43 // Index is the entry's stream index. | 46 // Index is the entry's stream index. |
| 44 Index types.MessageIndex | 47 Index types.MessageIndex |
| 45 | 48 |
| 46 // Values are contiguous sequential records to add to the storage. The f
irst | 49 // Values are contiguous sequential records to add to the storage. The f
irst |
| 47 // index in values corresponds to Index. | 50 // index in values corresponds to Index. |
| 48 Values [][]byte | 51 Values [][]byte |
| 49 } | 52 } |
| 50 | 53 |
| 51 // GetRequest is a request to retrieve a series of LogEntry records. | 54 // GetRequest is a request to retrieve a series of LogEntry records. |
| 52 type GetRequest struct { | 55 type GetRequest struct { |
| 56 // Project is the project name of the stream. |
| 57 Project config.ProjectName |
| 53 // Path is the stream path to retrieve. | 58 // Path is the stream path to retrieve. |
| 54 Path types.StreamPath | 59 Path types.StreamPath |
| 55 // Index is the entry's stream index. | 60 // Index is the entry's stream index. |
| 56 Index types.MessageIndex | 61 Index types.MessageIndex |
| 57 | 62 |
| 58 // 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. |
| 59 // If zero, no maximum limit will be applied. | 64 // If zero, no maximum limit will be applied. |
| 60 // | 65 // |
| 61 // 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 |
| 62 // implementation detail. | 67 // implementation detail. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // receiving fewer than requsted records does not necessarily mean that
more | 103 // receiving fewer than requsted records does not necessarily mean that
more |
| 99 // records are not available. | 104 // records are not available. |
| 100 // | 105 // |
| 101 // Returns nil if retrieval executed successfully, ErrDoesNotExist if | 106 // Returns nil if retrieval executed successfully, ErrDoesNotExist if |
| 102 // the requested stream does not exist, and an error if an error occurre
d | 107 // the requested stream does not exist, and an error if an error occurre
d |
| 103 // during retrieval. | 108 // during retrieval. |
| 104 Get(GetRequest, GetCallback) error | 109 Get(GetRequest, GetCallback) error |
| 105 | 110 |
| 106 // Tail retrieves the latest log in the stream. If the stream has no log
s, it | 111 // Tail retrieves the latest log in the stream. If the stream has no log
s, it |
| 107 // will return ErrDoesNotExist. | 112 // will return ErrDoesNotExist. |
| 108 » Tail(types.StreamPath) ([]byte, types.MessageIndex, error) | 113 » Tail(config.ProjectName, types.StreamPath) ([]byte, types.MessageIndex,
error) |
| 109 | 114 |
| 110 // Config installs the supplied configuration parameters into the storag
e | 115 // Config installs the supplied configuration parameters into the storag
e |
| 111 // instance. | 116 // instance. |
| 112 Config(Config) error | 117 Config(Config) error |
| 113 } | 118 } |
| OLD | NEW |