// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using EpicGames.Horde.Storage; using EpicGames.Serialization; namespace Jupiter.Implementation { public interface IRefService { Task<(RefRecord, BlobContents?)> GetAsync(NamespaceId ns, BucketId bucket, RefId key, string[]? fields = null, bool doLastAccessTracking = true, CancellationToken cancellationToken = default); Task<(ContentId[], BlobId[])> PutAsync(NamespaceId ns, BucketId bucket, RefId key, BlobId blobHash, CbObject payload, Action? onBlobFound = null, bool allowOverwrite = false, CancellationToken cancellationToken = default); Task<(ContentId[], BlobId[])> FinalizeAsync(NamespaceId ns, BucketId bucket, RefId key, BlobId blobHash, Action? onBlobFound = null, CancellationToken cancellationToken = default); IAsyncEnumerable GetNamespacesAsync(CancellationToken cancellationToken = default); IAsyncEnumerable GetBucketsAsync(NamespaceId ns, CancellationToken cancellationToken = default); IAsyncEnumerable GetRecordsInBucketAsync(NamespaceId ns, BucketId bucket, CancellationToken cancellationToken = default); Task DeleteAsync(NamespaceId ns, BucketId bucket, RefId key, CancellationToken cancellationToken = default); Task DropNamespaceAsync(NamespaceId ns, CancellationToken cancellationToken = default); Task DeleteBucketAsync(NamespaceId ns, BucketId bucket, CancellationToken cancellationToken = default); Task ExistsAsync(NamespaceId ns, BucketId bucket, RefId key, CancellationToken cancellationToken = default); Task> GetReferencedBlobsAsync(NamespaceId ns, BucketId bucket, RefId key, bool ignoreMissingBlobs, CancellationToken cancellationToken = default); Task UpdateTTL(NamespaceId ns, BucketId bucket, RefId refId, uint ttl, CancellationToken cancellationToken = default); } public class ObjectHashMismatchException : Exception { public ObjectHashMismatchException(NamespaceId ns, BucketId bucket, RefId name, BlobId suppliedHash, BlobId actualHash) : base($"Object {name} in bucket {bucket} and namespace {ns} did not reference hash {suppliedHash} was referencing {actualHash}") { } } }