Exemplo n.º 1
0
        public void Retry_FireAndForget_Operation(HttpListenerContext _Context, Action_DeliveryEnsurer _Action, Action <string> _ErrorMessageAction = null)
        {
            if (++_Action.RetryCount > MAX_FAILED_QUERY_RETRY_COUNTS)
            {
                //Stop retrying and record the failed operation

                if (FailedDeliveryEnsurerOperationEntry.GenerateOperationTimestampID(out string OperationTimestampID, _ErrorMessageAction))
                {
                    DB_AddElementsToArrayItem_FireAndForget(
                        _Context,
                        FailedDeliveryEnsurerOperationEntry.DBSERVICE_FAILED_DELIVERY_ENSURER_OPERATIONS_TABLE_PREFIX + ServiceName.ToLower(),
                        FailedDeliveryEnsurerOperationEntry.KEY_NAME_OPERATION_TIMESTAMP_ID,
                        new BPrimitiveType(OperationTimestampID),
                        "operations",
                        new BPrimitiveType[]
                    {
                        new BPrimitiveType(JsonConvert.SerializeObject(new FailedDeliveryEnsurerOperationEntry()
                        {
                            OperationStringified = JsonConvert.SerializeObject(_Action)
                        }))
                    });
                }
                else
                {
                    _ErrorMessageAction?.Invoke("Retry_FireAndForget_Operation: Function has failed to record the failed operation. Serialized lost action: " + JsonConvert.SerializeObject(_Action));
                }
                return;
            }

            ProcessActionInternally(_Action, _ErrorMessageAction);
        }
Exemplo n.º 2
0
 public void BroadcastFailed_FireAndForget_Operation(Action_DeliveryEnsurer _Action, Action <string> _ErrorMessageAction = null)
 {
     Thread.Sleep(2000); //Cooldown
     PublishSerializedAction(JsonConvert.SerializeObject(_Action), ActionServiceIdentifier, _ErrorMessageAction);
 }
Exemplo n.º 3
0
        private void ProcessActionInternally(Action_DeliveryEnsurer _Action, Action <string> _ErrorMessageAction = null)
        {
            switch (_Action.QueryType)
            {
            //FS
            case Action_DeliveryEnsurer.QUERY_TYPE_FS_DELETE_FILE:
            {
                var Casted = (Action_DeliveryEnsurer_FS_DeleteFile)_Action;

                FS_DeleteFile_FireAndForget_Internal(Casted.BucketName, Casted.KeyName, Casted.RetryCount, _ErrorMessageAction);
                break;
            }

            case Action_DeliveryEnsurer.QUERY_TYPE_FS_DELETE_FOLDER:
            {
                var Casted = (Action_DeliveryEnsurer_FS_DeleteFolder)_Action;

                FS_DeleteFolder_FireAndForget_Internal(Casted.BucketName, Casted.KeyName, Casted.RetryCount, _ErrorMessageAction);
                break;
            }

            //DB
            case Action_DeliveryEnsurer.QUERY_TYPE_DB_UPDATE_ITEM:
            case Action_DeliveryEnsurer.QUERY_TYPE_DB_PUT_ITEM:
            {
                var Casted = (Action_DeliveryEnsurer_DB_UpdateOrPutItem)_Action;

                DB_UpdateOrPutItem_FireAndForget_Internal(
                    Casted.QueryType,
                    Casted.TableName,
                    Casted.KeyName,
                    Casted.KeyValue.GetKeyValuePrimitiveReference(),
                    JObject.Parse(Casted.UpdateItemStringified),
                    Casted.RetryCount,
                    _ErrorMessageAction);
                break;
            }

            case Action_DeliveryEnsurer.QUERY_TYPE_DB_DELETE_ITEM:
            {
                var Casted = (Action_DeliveryEnsurer_DB_DeleteItem)_Action;

                DB_DeleteItem_FireAndForget_Internal(
                    Casted.TableName,
                    Casted.KeyName,
                    Casted.KeyValue.GetKeyValuePrimitiveReference(),
                    Casted.RetryCount,
                    _ErrorMessageAction);
                break;
            }

            case Action_DeliveryEnsurer.QUERY_TYPE_DB_ADD_ELEMENTS_TO_ARRAY_ITEM:
            case Action_DeliveryEnsurer.QUERY_TYPE_DB_REMOVE_ELEMENTS_FROM_ARRAY_ITEM:
            {
                var Casted       = (Action_DeliveryEnsurer_DB_Add_Remove_ElementsToArrayItem)_Action;
                var ValueEntries = new List <BPrimitiveType>();
                foreach (var JEntry in Casted.ElementValueEntries)
                {
                    ValueEntries.Add(JEntry.GetKeyValuePrimitiveReference());
                }

                DB_AddOrRemoveElementsFromArrayItem_FireAndForget_Internal(
                    Casted.QueryType,
                    Casted.TableName,
                    Casted.KeyName,
                    Casted.KeyValue.GetKeyValuePrimitiveReference(),
                    Casted.ElementName,
                    ValueEntries.ToArray(),
                    Casted.RetryCount,
                    _ErrorMessageAction);
                break;
            }
            }
        }