Exemple #1
0
 /// <summary>
 /// List and get all blobs matching the provided blob name prefix.
 /// </summary>
 /// <remarks>
 /// <para>This method is sideeffect-free, except for infrastructure effects like thread pool usage.</para>
 /// </remarks>
 public static IEnumerable <T> ListBlobs <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> locationPrefix, int skip = 0, IDataSerializer serializer = null)
 {
     return(provider.ListBlobs <T>(locationPrefix.ContainerName, locationPrefix.Path, skip, serializer));
 }
Exemple #2
0
 /// <summary>
 /// Inserts or updates a blob depending on whether it already exists or not.
 /// If the insert or update lambdas return empty, the blob will be deleted (if it exists).
 /// </summary>
 /// <remarks>
 /// <para>
 /// The provided lambdas can be executed multiple times in case of
 /// concurrency-related retrials, so be careful with side-effects
 /// (like incrementing a counter in them).
 /// </para>
 /// <para>
 /// This method is idempotent if and only if the provided lambdas are idempotent
 /// and if the object returned by the insert lambda is an invariant to the update lambda
 /// (if the second condition is not met, it is idempotent after the first successful call).
 /// </para>
 /// </remarks>
 /// <returns>The value returned by the lambda. If empty, then the blob has been deleted.</returns>
 public static Maybe <T> UpsertBlobOrDelete <T>(
     this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <Maybe <T> > insert, Func <T, Maybe <T> > update, IDataSerializer serializer = null)
 {
     return(provider.UpsertBlobOrDelete(location.ContainerName, location.Path, insert, update, serializer));
 }
Exemple #3
0
 /// <summary>
 /// List the blob locations (with the provided type) of all blobs matching the provided blob name prefix.
 /// </summary>
 /// <remarks>
 /// <para>This method is sideeffect-free, except for infrastructure effects like thread pool usage.</para>
 /// </remarks>
 public static IEnumerable <IBlobLocationAndType <T> > ListBlobLocations <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> blobLocationPrefix)
 {
     return(provider.ListBlobNames(blobLocationPrefix.ContainerName, blobLocationPrefix.Path)
            .Select(name => new BlobLocationAndType <T>(blobLocationPrefix.ContainerName, name)));
 }
Exemple #4
0
 /// <summary>
 /// Updates a blob if it already exists.
 /// If the insert or update lambdas return empty, the blob will not be changed.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The provided lambdas can be executed multiple times in case of
 /// concurrency-related retrials, so be careful with side-effects
 /// (like incrementing a counter in them).
 /// </para>
 /// <para>This method is idempotent if and only if the provided lambdas are idempotent.</para>
 /// </remarks>
 /// <returns>The value returned by the lambda, or empty if the blob did not exist or no change was applied.</returns>
 public static Maybe <T> UpdateBlobIfExistOrSkip <T>(
     this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <T, Maybe <T> > update, IDataSerializer serializer = null)
 {
     return(provider.UpsertBlobOrSkip(location.ContainerName, location.Path, () => Maybe <T> .Empty, update, serializer));
 }
Exemple #5
0
 /// <summary>
 /// Inserts or updates a blob depending on whether it already exists or not.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The provided lambdas can be executed multiple times in case of
 /// concurrency-related retrials, so be careful with side-effects
 /// (like incrementing a counter in them).
 /// </para>
 /// <para>
 /// This method is idempotent if and only if the provided lambdas are idempotent
 /// and if the object returned by the insert lambda is an invariant to the update lambda
 /// (if the second condition is not met, it is idempotent after the first successful call).
 /// </para>
 /// </remarks>
 /// <returns>The value returned by the lambda.</returns>
 public static T UpsertBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <T> insert, Func <T, T> update, IDataSerializer serializer = null)
 {
     return(provider.UpsertBlobOrSkip <T>(location.ContainerName, location.Path, () => insert(), t => update(t), serializer).Value);
 }
Exemple #6
0
 public static void PutBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, IDataSerializer serializer = null)
 {
     provider.PutBlob(location.ContainerName, location.Path, item, serializer);
 }
Exemple #7
0
 /// <summary>Push the blob only if etag is matching the etag of the blob in BlobStorage</summary>
 public static bool PutBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, string etag, IDataSerializer serializer = null)
 {
     return(provider.PutBlob(location.ContainerName, location.Path, item, etag, serializer));
 }
Exemple #8
0
 public static Task <BlobWithETag <T> > GetBlobAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, IDataSerializer serializer = null)
 {
     return(provider.GetBlobAsync <T>(location.ContainerName, location.Path, CancellationToken.None, serializer));
 }
Exemple #9
0
 public static Maybe <T> GetBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, out string etag, IDataSerializer serializer = null)
 {
     return(provider.GetBlob <T>(location.ContainerName, location.Path, out etag, serializer));
 }
Exemple #10
0
 public static Task <BlobWithETag <T> > UpdateBlobIfExistAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location,
                                                                   Func <T, T> update, IDataSerializer serializer = null)
 {
     return(provider.UpsertBlobOrSkipAsync(location.ContainerName, location.Path, () => Maybe <T> .Empty, t => update(t), CancellationToken.None, serializer));
 }
Exemple #11
0
 public static Task <BlobWithETag <T> > UpdateBlobIfExistOrDeleteAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location,
                                                                           Func <T, Maybe <T> > update, IDataSerializer serializer = null)
 {
     return(provider.UpdateBlobIfExistOrDeleteAsync(location.ContainerName, location.Path, update, CancellationToken.None, serializer));
 }
Exemple #12
0
 public static Task <BlobWithETag <T> > UpsertBlobAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location,
                                                            Func <T> insert, Func <T, T> update, CancellationToken cancellationToken, IDataSerializer serializer = null)
 {
     return(provider.UpsertBlobOrSkipAsync <T>(location.ContainerName, location.Path, () => insert(), t => update(t), cancellationToken, serializer));
 }
Exemple #13
0
 public static Task <string> PutBlobAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, string expectedEtag, IDataSerializer serializer = null)
 {
     return(provider.PutBlobAsync(location.ContainerName, location.Path, item, typeof(T), true, expectedEtag, CancellationToken.None, serializer));
 }
Exemple #14
0
 public static Task <string> PutBlobAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, bool overwrite, CancellationToken cancellationToken, IDataSerializer serializer = null)
 {
     return(provider.PutBlobAsync(location.ContainerName, location.Path, item, typeof(T), overwrite, null, cancellationToken, serializer));
 }
 /// <summary>Push the blob only if etag is matching the etag of the blob in BlobStorage</summary>
 public static bool PutBlobStream(this IBlobStorageProvider provider, IBlobLocationAndType <Stream> location, Stream stream, string etag)
 {
     return(provider.PutBlobStream(location.ContainerName, location.Path, stream, etag));
 }
 public static void PutBlobStream(this IBlobStorageProvider provider, IBlobLocationAndType <Stream> location, Stream stream)
 {
     provider.PutBlobStream(location.ContainerName, location.Path, stream);
 }