How to create Atomic Service?

Asked

Viewed 70 times

1

Description of Atomic

As operations are in memory and only are all persisted at once. If an operation fail, all operations are reversed.

Below is a fictional scenario to compose the question...

In the general banking scenario for transfer of values, we have the following business rules:

to) Choose the value to be moved

b) Check current balance

c) Remove Account Value from Source

d) Add Amount received to recipient account

We know that logically and besides being something banking where takes a huge security to this, all these steps (functions) should only affect the value, if all are persisted and completed successfully, for example: If the user is in the stage c) and the user internet fall and is not atomic, the balance value would be manipulated and would generate problems.

Question

Knowing this, in relation to the logic of the algorithm, how would an atomic application be in relation to the algorithm? Giving an example in a decoupled Frontend scenario of Backend, where Frontend communicates with Backend through requests.

In frontend I must store the "balance" (which is not what is in DB, only a visual representation in a tag html) and do the operations and go storing them in a localStorage, sessionStorage and from all actions check whether the situation was successfully completed and then yes send the request to the database?

Note

I read about the ACID, however it was not clear to me if I have the status of the above question.

  • The term has already been answered in https://answall.com/q/253852/101. I do not know if the rest is not broad. I don’t know what functional has to do with it, which starts to make the question unclear. Including "we know well that these actions are atomic" I do not know, nothing indicates there that they are, can and as far as I understand should be.

  • What about my friend @Maniero? So I had read this question that you posted, but what they say in the answer is something specific to threads and I would like to know in general not specific, about functional programming, we both know what it is.. What I meant about this is this: Every action there would be a specific function, but as the code is executed line by line from top to bottom, that’s the question.. when arriving at the letter a) would be executed and saved in the database and so on, usually works so correct? How do I approach this theme using the atomic description above?

  • 1

    It is that without some form of competition being atomic or not little matter in memory. In the database we talk about this in https://answall.com/q/203857/101, https://answall.com/q/203669/10. This may be useful: https://answall.com/q/159342/101. I don’t know if we both know what is functional ,I know I know, what you’re saying means you don’t know, or the text is too confusing for me to notice. I think all this ends up answering what you want to know, or I don’t understand what you want. This can be useful if you want to go lower: https://answall.com/q/192938/101.

  • @Maniero will soon read the links and perhaps "improve" the question.. Well I have always learned that functional programming emphasizes the application of functions and avoids unchanging states or data. I do not know if I explained well, but I considered this part of the concept with the above example and meant that the value in bank is an immutable data until the functions are correctly completed, and I took the description of atomic in consideration.

  • So it seems this matter has nothing to do with what you’re talking about. Even there’s nothing immutable about it, there’s a clear doubt that you have.

  • @Maniero now I am typing from the mobile phone, as soon as I arrive at my residence I will improve the question with technical terms and more descriptions.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.