Now we've got a better idea of what this feature is.
We're going to take a look at a couple of different ways of implementing it.
So let's get to it.
The first thing I want to do is just give you a very quick review on how our system works right now.
At present we have the Postal Service comments and query whenever a user submits a comment the comment
service is going to emit an event over to the event buzz of comment created the event buzz is then going
to take this event and send it out automatically to all the different services inside of our app including
the comment service.
Like so now at present the post service and comment service although the received this event they don't
actually process it in any way.
They just say OK here's an event I don't really care.
The query service however does do some processing of the query service is going to take this event and
use it to understand this new comment that was just created and it stores it inside of some local data
structure.
So again that's what's going on inside of our system right now.
I know we just did this.
And so it's kind of me repeating myself to tell you what's going on but it's really critical for you
to understand this flow because the options are about to go through for implementing this new feature
are going to be pretty darn complex.
So with that having been said let's get to it.
Let's take a look at option number one so an option number one.
I first want you to take a look at this diagram.
You'll notice I've added in a new moderation service right here.
So this is going to be a service that is in charge of taking a look at a comment and deciding whether
or not it should be approved or rejected.
You'll also notice in this diagram I have removed the post service entirely.
That is not because we're going to delete the post service I just removed it for clarity so you can
better understand this diagram.
This whole idea of comments in moderation and whatnot really doesn't have anything tied to the postal
service whatsoever OK.
So in this idea with option number one we're going to have a sort of chain going on where we're going
to have the common service emit an event saying that accomplishes created the moderation service will
then emit an event saying that the com was moderated.
And then finally the query service will process that comment.
So let's take a look at exactly what would occur.
So once again we're gonna have a user submitting a comment to the common service the comment service
will then immediately persist information about that comment as it is doing right now.
So it will create some new record with say an I.D. and some content and probably the post I.D. as well
but we'll just ignore that for right now because it's not a relevant property as soon as it persists
that new pope comment the comment service will then continue to emit any event over to the event buzz
of comment created.
So it's gonna throw this over to the event buzz and the event buzz in turn is going to send that event
out to all of our different services as it is doing right now.
Now with option number one we're gonna say that the only service that cares about comment created is
going to be the moderation service.
So we're gonna stay with option number one very service no longer cares about that event.
So functionally only the moderation service is going to process come and create it the moderation service.
We'll take a look at the content of this comment and decide whether or not to approve it or reject it.
So we'll say that in this case because content does not have the word orange the moderation service
will approve this comment.
So to tell all the other services that this comment has just been approved we'll have the moderation
service emit a brand new event that we're going to introduce right now.
All the comment moderated event the data of this event is going to have all the information about this
comment along with the status of the comment as well.
So in this case we'll say status approved the moderation service will emit this it'll go over to our
event plus and once again it'll be sent to all of the different services inside of our app
now the only service that probably cares about this event will be beat query service the query service
will listen for comment moderated.
It's going to take all the information out of that data property and persistence the query service will
now know the idea the comment its content and its status.
As well like so.
So now anytime soon makes a follow up request the query service they will see.
Okay.
Here is a comment and its status is approved.
So let's talk about the pros and cons of this approach because there are very much some very big negatives
to it the big negative to this approach is the fact that there is some delay between a user somebody
a comment and that common actually being persisted by the query service so I want you to think back
to the mockup you're looking at just a moment ago a comment truly has three states.
It can be approved as it is right here rejected or pending moderation.
I want you to really think about that pending moderation state.
Right now we are really assuming that this entire approval process by the moderation service is instantaneous
in nature but it is entirely possible that maybe at some point down the line we decide that rather than
just checking to see if a comment has the word orange in it maybe Instead we rely upon a human to moderate
these comments.
A human can not process comments or moderate them instantaneously.
It might take a person several seconds minutes hours even days to read a comment and decide whether
or not to approve it or reject it.
So think about what would happen if our moderation service took a long time to run let's go through
the scenario again and assume that it's going to take some amount of time.
The moderation service to actually process a comment.
OK.
So once again a user is going to submit a comment comment service will persist that and the comment
service will limit this event and that event is going to be sent on over to the moderation service where
it's then going to await actual moderation now.
At that point in time we're essentially paused in this workflow.
Nothing else is going to happen anytime soon.
And so in this scenario.
Well that might sound OK but I want you to really think about the user experience what happens to a
user as they are actually using our application.
Think about what would happen if a user typed in some comment right here and clicked on submit and then
critically refreshed the page when a user refreshes the page after submitted a comment they expect to
see the new comment listed on here immediately or at least something that says Hey your comment is waiting
pending or pending moderation or something similar so with the approach we're discussing right now we're
saying that after a user refreshes their page they are not going to immediately see that comment from
the query service right away because it's going to take some amount of time for the moderation service
to actually process that thing and then tell the query service that there's this new comment to the
downside of option number one is that this entire flow could potentially result in a user not seeing
the information that they just submitted very very easily.
Now I want you to understand that this idea of a user making a change and then not seeing that immediately
reflected that's something that's going to come up all the time in this idea of micros services.
So this is a very big thing that we're going to discuss quite a bit throughout the course but just in
this scenario because of the possibility of the moderation service being ran by an actual human we're
kind of exacerbating that problem.
So I think that option number one has a definite and immediate downside to it.
So as you can imagine we're not going to go with option number one.
Now let's take a quick pause right here.
We're then going to take a look at options 2 and 3 much more quickly now that we understand some of
the general issues that we're going to run into.