The programmatic way of storing data, so that it can be used efficiently. Almost every enterprise application uses various types of data structures in one or the other way.
Introduction and Characteristics of Algorithms, Algorithm is a step-by-step programmatic way of storing data, so that it can be used efficiently. Almost every enterprise application uses various types of data structures in one or the other way.
As we saw in this article about Algorithm, Let us see in details here.
Algorithm is step-by-step procedure for solving a problem in finite number of steps. In other words it is finite set of well-defined instructions written in human readable language for solving a given problem. An algorithm is division of a problem into small steps which are in sequence. Algorithm is very important way for computers to understand the problem and process the information accordingly.
Problem can always be solved in multiple ways or can have multiple solutions to solve. Similarly Algorithms also can be written any number ways to solve the problem. Let us see the characteristic of an Algorithm.
What are the Saga design pattern and types available?
The Saga Pattern is a microservices architectural pattern to implement a transaction that extends multiple services.
A saga is a sequence of local transactions. Each service in a saga performs its own transaction and publishes an event. The other services listen to that event and perform the next local transaction. If one transaction fails for some reason, the saga also executes compensating transactions to undo the impact of the preceding transactions.
Consider a Food delivery service flow, When a user places an order, below could be the flow.
The food ordering service creates an order. At this point, the order is in PENDING status.
With the Saga pattern, it contacts the restaurant via the restaurant service.
The restaurant service attempts to place an order with the selected restaurant, Once the order is received by Restaurant it sends back an ORDER_ACCEPTED (if the order is accepted) or ORDER_REJECTED (if the order cannot be accepted) status.
The saga received the status ORDER_ACCEPTED or ORDER_REJECTED status and process the response to the customer accordingly.
The food order service then changes the status of the order, if the order is accepted then it displays an order confirmation message if the order is rejected it display an apologies message and suggest alternative restaurants.
Types of Saga:
In the next article, we will see in detail about the Type of Saga design patterns.