Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using System.Threading.Tasks;
11 : using Microsoft.Azure.Documents;
12 : using Microsoft.Azure.Documents.Client;
13 :
14 : namespace Cqrs.Azure.DocumentDb
15 : {
16 : /// <summary>
17 : /// A helper for Azure Document DB.
18 : /// </summary>
19 : public interface IAzureDocumentDbHelper
20 : {
21 : /// <summary>
22 : /// Gets a <see cref="Database"/> creating one if it doesn't already exist.
23 : /// </summary>
24 : /// <param name="client">The <see cref="DocumentClient"/> to use.</param>
25 : /// <param name="databaseName">The name of the database to get.</param>
26 1 : Task<Database> CreateOrReadDatabase(DocumentClient client, string databaseName);
27 :
28 : /// <summary>
29 : /// Gets a <see cref="DocumentCollection"/> creating one if it doesn't already exist.
30 : /// </summary>
31 : /// <param name="client">The <see cref="DocumentClient"/> to use.</param>
32 : /// <param name="database">The <see cref="Database"/> to look in.</param>
33 : /// <param name="collectionName">The name of the collection to get.</param>
34 : /// <param name="uniqiueIndexPropertyNames">Any unique properties the collection should enforce.</param>
35 1 : Task<DocumentCollection> CreateOrReadCollection(DocumentClient client, Database database, string collectionName, string[] uniqiueIndexPropertyNames = null);
36 :
37 : /// <summary>
38 : /// Execute the provided <paramref name="func"/> in a fault tolerant way.
39 : /// </summary>
40 : /// <param name="func">The <see cref="Func{T}"/> to execute.</param>
41 1 : T ExecuteFaultTollerantFunction<T>(Func<T> func);
42 :
43 : /// <summary>
44 : /// Execute the provided <paramref name="func"/> in a fault tolerant way.
45 : /// </summary>
46 : /// <param name="func">The <see cref="Action"/> to execute.</param>
47 1 : void ExecuteFaultTollerantFunction(Action func);
48 : }
49 : }
|