// Copyright 2024 Versity Software // This file is licensed under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. package meta import "os" // MetadataStorer defines the interface for managing metadata. // When object == "", the operation is on the bucket. type MetadataStorer interface { // RetrieveAttribute retrieves the value of a specific attribute for an object or a bucket. // Returns the value of the attribute, or an error if the attribute does not exist. RetrieveAttribute(f *os.File, bucket, object, attribute string) ([]byte, error) // StoreAttribute stores the value of a specific attribute for an object or a bucket. // If attribute already exists, new attribute should replace existing. // Returns an error if the operation fails. StoreAttribute(f *os.File, bucket, object, attribute string, value []byte) error // DeleteAttribute removes the value of a specific attribute for an object or a bucket. // Returns an error if the operation fails. DeleteAttribute(bucket, object, attribute string) error // ListAttributes lists all attributes for an object or a bucket. // Returns list of attribute names, or an error if the operation fails. ListAttributes(bucket, object string) ([]string, error) // DeleteAttributes removes all attributes for an object or a bucket. // Returns an error if the operation fails. DeleteAttributes(bucket, object string) error // RenameObject renames all stored metadata from oldObject to newObject // within the given bucket. This must be called whenever the data // directory for an object is renamed so that metadata stays in sync. RenameObject(bucket, oldObject, newObject string) error } // RootDirSetter is implemented by metadata storers that keep metadata on the // bucket and object files themselves and therefore need to know where those // files live. A backend that does not change the process working directory // to its root calls WithRootDir with the absolute path of the root before // using the storer; the returned storer resolves bucket names against that // directory instead of the working directory. Storers that keep metadata // elsewhere (SideCar, NoMeta) do not implement it. // // A type that embeds XattrMeta inherits its WithRootDir, which returns a bare // XattrMeta and so drops the outer type; such a type must provide its own // WithRootDir. type RootDirSetter interface { WithRootDir(rootdir string) MetadataStorer }