Beispiel #1
0
        public static void AsyncOperation <T>(AsyncCall call, string operation, AmazonDynamoCallback <T> callback, object state)
        {
            DynamoDBAsyncState <T> result = new DynamoDBAsyncState <T>(operation, callback, state);

            ThreadPool.QueueUserWorkItem(s => Execute(call, result));
            return;
        }
 public static void LoadTableAsync(IAmazonDynamoDB ddbClient, string tableName,
                                   AmazonDynamoCallback <Table> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation(() =>
     {
         return(LoadTable(ddbClient, tableName));
     }, "LoadTableAsync", callback, state);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the ExecuteBatchWrite operation.
 /// <seealso cref="Amazon.DynamoDBv2.DataModel.DynamoDBContext.ExecuteBatchWrite"/>
 /// </summary>
 /// <param name="batches">Configured BatchWrite objects</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void ExecuteBatchWriteAsync(BatchWrite[] batches, AmazonDynamoCallback <VoidResponse> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <VoidResponse>(() =>
     {
         MultiTableBatchWrite superBatch = new MultiTableBatchWrite(batches);
         superBatch.ExecuteHelper(true);
         return(new VoidResponse());
     }, "ExecuteBatchWriteAsync", callback, state);
 }
Beispiel #4
0
 /// <summary>
 /// Initiates the asynchronous execution to get all the remaining results from DynamoDB.
 /// </summary>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 ///
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetRemaining
 ///         operation.</returns>
 public void GetRemainingAsync(AmazonDynamoCallback <List <T> > callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation(() =>
     {
         var documents  = DocumentSearch.GetRemainingHelper(true);
         List <T> items = SourceContext.FromDocumentsHelper <T>(documents, Config).ToList();
         return(items);
     }, "GetRemainingAsync", callback, state);
 }
 internal static void ExecCallback <T>(AmazonDynamoCallback <T> callback, AmazonDynamoResult <T> result)
 {
     _callbackQueue.Enqueue(new AmazonDynamoCallbackState <T>(callback, result));
 }
 public AmazonDynamoCallbackState(AmazonDynamoCallback <T> callback, AmazonDynamoResult <T> result)
 {
     this._callback = callback;
     this._result   = result;
 }
Beispiel #7
0
 /// <summary>
 /// Initiates the asynchronous execution of the UpdateItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.UpdateItem"/>
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="key">Key of the document.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void UpdateItemAsync(Document doc, IDictionary <string, DynamoDBEntry> key, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => UpdateHelper(doc, MakeKey(key), null, true), "UpdateItemAsync", callback, state);
 }
Beispiel #8
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// Returns the Document from DynamoDB in callback
 /// </summary>
 /// <param name="key">Key of the document.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void GetItemAsync(IDictionary <string, DynamoDBEntry> key, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => GetItemHelper(MakeKey(key), null, true), "GetItemAsync", callback, state);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the Load operation.
 /// <seealso cref="Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load"/>
 /// </summary>
 /// <typeparam name="T">Type to populate.</typeparam>
 /// <param name="keyObject">Key of the target item.</param>
 /// <param name="operationConfig">Overriding configuration.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void LoadAsync <T>(T keyObject, DynamoDBOperationConfig operationConfig, AmazonDynamoCallback <T> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <T>(() => LoadHelper <T>(keyObject, operationConfig, true), "LoadAsync", callback, state);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the Delete operation.
 /// <seealso cref="Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete"/>
 /// </summary>
 /// <typeparam name="T">Type of object.</typeparam>
 /// <param name="hashKey">Hash key element of the object to delete.</param>
 /// <param name="rangeKey">Range key element of the object to delete.</param>
 /// <param name="operationConfig">Config object which can be used to override that table used.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void DeleteAsync <T>(object hashKey, object rangeKey, DynamoDBOperationConfig operationConfig, AmazonDynamoCallback <VoidResponse> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <VoidResponse>(() => { DeleteHelper <T>(hashKey, rangeKey, operationConfig, true); return(new VoidResponse()); }, "DeleteAsync", callback, state);
 }
Beispiel #11
0
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 ///
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void DeleteItemAsync(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => DeleteHelper(MakeKey(hashKey, rangeKey), config, true), "DeleteItemAsync", callback, state);
 }
Beispiel #12
0
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 ///
 /// </summary>
 /// <param name="key">Key of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void DeleteItemAsync(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => DeleteHelper(MakeKey(key), config, true), "DeleteItemAsync", callback, state);
 }
Beispiel #13
0
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 ///
 /// </summary>
 /// <param name="key">Key of the document.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void DeleteItemAsync(IDictionary <string, DynamoDBEntry> key, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => { DeleteHelper(MakeKey(key), null, true); return(null); }, "DeleteItemAsync", callback, state);
 }
Beispiel #14
0
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 ///
 /// </summary>
 /// <param name="document">Document to delete.</param>
 /// <param name="config">Configuration to use.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void DeleteItemAsync(Document document, DeleteItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => DeleteHelper(MakeKey(document), config, true), "DeleteItemAsync", callback, state);
 }
Beispiel #15
0
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 ///
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void DeleteItemAsync(Primitive hashKey, Primitive rangeKey, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => { DeleteHelper(MakeKey(hashKey, rangeKey), null, true); return(null); }, "DeleteItemAsync", callback, state);
 }
Beispiel #16
0
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 ///
 /// </summary>
 /// <param name="document">Document to delete.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void DeleteItemAsync(Document document, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => { DeleteHelper(MakeKey(document), null, true); return(null); }, "DeleteItemAsync", callback, state);
 }
Beispiel #17
0
 /// <summary>
 /// Initiates the asynchronous execution of the UpdateItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.UpdateItem"/>
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void UpdateItemAsync(Document doc, Primitive hashKey, UpdateItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => UpdateHelper(doc, MakeKey(hashKey, null), config, true), "UpdateItemAsync", callback, state);
 }
Beispiel #18
0
 /// <summary>
 /// Initiates the asynchronous execution of the Execute operation.
 /// Executes a multi-table batch request against all configured batches.
 /// Results are stored in the respective BatchGet objects.
 /// </summary>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 ///
 /// <returns>void</returns>
 public void ExecuteAsync(AmazonDynamoCallback <VoidResponse> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <VoidResponse>(() =>
                                                         { ExecuteHelper(true); return(new VoidResponse()); },
                                                         "BatchGet-ExecuteAsync", callback, state);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the Save operation.
 /// Saves an object to DynamoDB using passed-in configs.
 ///
 /// Passed-in config overrides DynamoDBContextConfig on the context.
 /// Type must be marked up with DynamoDBTableAttribute and at least
 /// one public field/property with DynamoDBHashKeyAttribute.
 /// </summary>
 /// <typeparam name="T">Type to save as.</typeparam>
 /// <param name="value">Object to save.</param>
 /// <param name="operationConfig">Overriding configuration.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void SaveAsync <T>(T value, DynamoDBOperationConfig operationConfig, AmazonDynamoCallback <VoidResponse> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <VoidResponse>(() => { SaveHelper <T>(value, operationConfig, true); return(new VoidResponse()); }, "SaveAsync", callback, state);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the Load operation.
 /// <seealso cref="Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load"/>
 /// </summary>
 /// <typeparam name="T">Type to populate.</typeparam>
 /// <param name="hashKey">Hash key element of the target item.</param>
 /// <param name="rangeKey">Range key element of the target item.</param>
 /// <param name="operationConfig">Overriding configuration.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void LoadAsync <T>(object hashKey, object rangeKey, DynamoDBOperationConfig operationConfig, AmazonDynamoCallback <T> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <T>(() => LoadHelper <T>(hashKey, rangeKey, operationConfig, true), "LoadAsync", callback, state);
 }
Beispiel #21
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetRemaining operation.
 /// Retrieves all the remaining results
 /// Returns List of Documents matching the search parameters in callback
 /// </summary>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void GetRemainingAsync(AmazonDynamoCallback <List <Document> > callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <List <Document> >(() => GetRemainingHelper(true), "GetRemainingAsync", callback, state);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the Delete operation.
 /// <seealso cref="Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete"/>
 /// </summary>
 /// <typeparam name="T">Type of object.</typeparam>
 /// <param name="value">Object to delete.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void DeleteAsync <T>(T value, AmazonDynamoCallback <VoidResponse> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <VoidResponse>(() => { DeleteHelper <T>(value, null, true); return(new VoidResponse()); }, "LoadAsync", callback, state);
 }
Beispiel #23
0
 public DynamoDBAsyncState(string operation, AmazonDynamoCallback <T> callback, object state)
 {
     this.Operation = operation;
     this.Callback  = callback;
     this.State     = state;
 }
Beispiel #24
0
 /// <summary>
 /// Initiates the asynchronous execution of the PutItem operation.
 /// Puts a document into DynamoDB, using specified configs.
 /// Returns updated Document in callback
 /// </summary>
 /// <param name="doc">Document to save.</param>
 /// <param name="config">Configuration to use.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void PutItemAsync(Document doc, PutItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => PutItemHelper(doc, config, true), "PutItemAsync", callback, state);
 }
Beispiel #25
0
 /// <summary>
 /// Initiates the asynchronous execution of the UpdateItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.UpdateItem"/>
 /// </summary>
 /// <param name="doc">Document to update.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void UpdateItemAsync(Document doc, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => UpdateHelper(doc, MakeKey(doc), null, true), "UpdateItemAsync", callback, state);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the Load operation.
 /// Loads an object from DynamoDB for the given hash primary key.
 ///
 /// Uses DynamoDBContextConfig configured on the context.
 /// Type must be marked up with DynamoDBTableAttribute and at least
 /// one public field/property with DynamoDBHashKeyAttribute.
 /// </summary>
 /// <typeparam name="T">Type to populate.</typeparam>
 /// <param name="hashKey">Hash key element of the target item.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void LoadAsync <T>(object hashKey, AmazonDynamoCallback <T> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <T>(() => LoadHelper <T>(hashKey, null, null, true), "LoadAsync", callback, state);
 }
Beispiel #27
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// Returns the Document from DynamoDB in callback
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="callback">An AmazonDynamoCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>void</returns>
 public void GetItemAsync(Primitive hashKey, Primitive rangeKey, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => GetItemHelper(MakeKey(hashKey, rangeKey), null, true), "GetItemAsync", callback, state);
 }