go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/logdog/appengine/coordinator/storage.go (about) 1 // Copyright 2017 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package coordinator 16 17 import ( 18 "context" 19 "time" 20 21 "go.chromium.org/luci/logdog/common/storage" 22 ) 23 24 // SigningStorage is an interface to storage used by the Coordinator. 25 type SigningStorage interface { 26 // Storage is the base Storage instance. 27 storage.Storage 28 29 // GetSignedURLs attempts to sign the storage's stream's RecordIO archive 30 // stream storage URL. 31 // 32 // If signing is not supported by this Storage instance, this will return 33 // a nil signing response and no error. 34 GetSignedURLs(context.Context, *URLSigningRequest) (*URLSigningResponse, error) 35 } 36 37 // URLSigningRequest is the set of URL signing parameters passed to a 38 // SigningStorage.GetSignedURLs call. 39 type URLSigningRequest struct { 40 // Lifetime is the signed URL expiration time. 41 Lifetime time.Duration 42 43 // Stream, if true, requests a signed log stream URL. 44 Stream bool 45 // Index, if true, requests a signed log stream index URL. 46 Index bool 47 } 48 49 // HasWork returns true if this signing request actually has work that is 50 // requested. 51 func (r *URLSigningRequest) HasWork() bool { 52 return (r.Stream || r.Index) && (r.Lifetime > 0) 53 } 54 55 // URLSigningResponse is the resulting signed URLs from a 56 // SigningStorage.GetSignedURLs call. 57 type URLSigningResponse struct { 58 // Expiration is the signed URL expiration time. 59 Expiration time.Time 60 61 // Stream is the signed URL for the log stream, if requested. 62 Stream string 63 // Index is the signed URL for the log stream index, if requested. 64 Index string 65 }