github.com/matrixorigin/matrixone@v1.2.0/pkg/fileservice/object_storage.go (about) 1 // Copyright 2023 Matrix Origin 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 fileservice 16 17 import ( 18 "context" 19 "io" 20 "time" 21 ) 22 23 type ObjectStorage interface { 24 // List lists objects with specified prefix 25 List( 26 ctx context.Context, 27 prefix string, 28 fn func(isPrefix bool, key string, size int64) (bool, error), 29 ) ( 30 err error, 31 ) 32 33 // Stat returns informations about an object 34 Stat( 35 ctx context.Context, 36 key string, 37 ) ( 38 size int64, 39 err error, 40 ) 41 42 // Exists reports whether specified object exists 43 Exists( 44 ctx context.Context, 45 key string, 46 ) ( 47 bool, 48 error, 49 ) 50 51 // Write writes an object 52 Write( 53 ctx context.Context, 54 key string, 55 r io.Reader, 56 size int64, 57 expire *time.Time, 58 ) ( 59 err error, 60 ) 61 62 // Read returns an io.Reader for specified object range 63 Read( 64 ctx context.Context, 65 key string, 66 min *int64, 67 max *int64, 68 ) ( 69 r io.ReadCloser, 70 err error, 71 ) 72 73 // Delete deletes objects 74 Delete( 75 ctx context.Context, 76 keys ...string, 77 ) ( 78 err error, 79 ) 80 }