Creatures with Depth

There was once a little boy, one who listened keenly and shouted incrementally. He gave a sense of personhood whilst still being a child. He had lost the path to himself as he found listless joys to…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Building a marketplace with Zenaton

The most important feature of a marketplace is how it organizes communications between sellers and buyers. This article illustrates how it can easily be implemented using Zenaton, without any cron jobs, or database requests or modifications — just pure & simple code.

Lets assume we operate a marketplace where users post a request for a service and several providers can bid and provide this service. We will make some assumptions about how our marketplace works:

After the user request, our web application will launch a RequestManagementWorkflow with the $request object:

The first action of this workflow is to wait for moderation. For that, we use the Wait class provided by Zenaton.

The moderator has a UI listing all requests and decides what to do with each. According to their decision, moderation application will send a RequestModerationEvent to RequestManagementWorkflow

RequestModerationEvent class has 2 public properties, rejected and reason. Following the above workflow implementation, if $event->rejected is true then we will send a rejection notification to the user and end there.

Then we execute a SelectProvidersForRequest task that will return an array of providers objects. For each of them, we will notify the provider by dispatching a NotifyProviderOfNewRequest task. We use a dispatch (instead of execute) here as there is no need to execute these tasks sequentially. All providers can be notified at once.

Each time a provider enters a quote through the provider interface, a ProviderQuotationEvent will be sent to this workflow,

This event will be received by the onEvent method of our workflow:

The complete implementation is below:

It took me just a few hours to implement this class (without tasks implementation). Doing this without Zenaton, with cron and states variables, would probably have taken me days or perhaps weeks…not to mention the time to debug and test.

What’s more, updating this workflow is really easy — eg. we can add some timeouts for the user choice or manage the case in which the user doesn’t choose any quotes. With Zenaton, it’s becoming very easy to improve your business workflows :)

Add a comment

Related posts:

This is the story of my recovery from anorexia in chapters.

Severe starvation can cause your stomach to essentially shut down, as it knows that it is not going to get any food. Your body learns to survive on less, and it gets to the point where you can’t eat…

How peer support can improve employee retention

Many brands are working hard to accommodate these needs by making vital changes to their traditional office structure. Breakout rooms have been built, workplace wellness programmes have been…

La Conferenza mondiale delle persone con sclerosi multipla. Per parlare di ricerca e accesso alle terapie.

I rappresentanti di 39 associazioni di tutto il mondo che lottano contro la sclerosi multipla, malattia che colpisce oltre 3 milioni di persone, si sono riunite a Roma dal 24 al 26 ottobre per la…