1 00:00:00,810 --> 00:00:05,070 We're now going to take a look at a second option for adding in this moderation service and adding in 2 00:00:05,070 --> 00:00:06,630 some events to support it. 3 00:00:06,630 --> 00:00:11,340 So Here's option number two option number two is can you very select two option number one with very 4 00:00:11,400 --> 00:00:15,950 one very small difference as a matter of fact option number two is probably what you thought. 5 00:00:15,960 --> 00:00:18,440 Option number one was going to be OK. 6 00:00:18,480 --> 00:00:19,590 So let's walk through it. 7 00:00:19,740 --> 00:00:22,620 We're still going to have a user submitted come into the come and service. 8 00:00:22,620 --> 00:00:28,330 We are still going to have to common service emit an event of something like comment created the event 9 00:00:28,330 --> 00:00:31,960 bus is still going to send that event off to the moderation service. 10 00:00:32,110 --> 00:00:37,270 But now we're going to also have it go off to the query service and actually be processed by the query 11 00:00:37,270 --> 00:00:38,210 service. 12 00:00:38,230 --> 00:00:43,480 So this is similar to what is going on inside our application right now without adding in this moderation 13 00:00:43,480 --> 00:00:47,500 feature as soon as the query service sees come and created. 14 00:00:47,590 --> 00:00:52,570 We're going to have the query service persist some information about that comment and critically it's 15 00:00:52,570 --> 00:00:59,550 also going to have a default status of something like pending the query service is going to instantly 16 00:00:59,550 --> 00:01:05,310 know about this comment even if it takes some amount of time for the moderation Service to process and 17 00:01:05,310 --> 00:01:08,730 actually moderate the given comment. 18 00:01:08,750 --> 00:01:12,920 So now we can imagine that if a user goes over to application and they enter and a common right here 19 00:01:12,920 --> 00:01:18,650 and hit submit we're going to be in instantly emit comment created and that event will instantly go 20 00:01:18,650 --> 00:01:22,980 over to the query service in the query service will have this record of the comments. 21 00:01:23,000 --> 00:01:27,280 So as soon as the user refreshes the page in theory they will see that coming up here right away. 22 00:01:27,360 --> 00:01:32,350 And because we know its status is pending we can show a nice little and a picture of that thing. 23 00:01:32,480 --> 00:01:38,240 Something like this right here or a nice little something note that says this comment is awaiting moderation. 24 00:01:38,280 --> 00:01:43,620 Now of course we still want to go ahead and moderate this comment so the comment created is still going 25 00:01:43,620 --> 00:01:50,010 to go to moderation service and at some point in time in the future maybe seconds months who knows what 26 00:01:50,310 --> 00:01:51,820 it will still continue to leave it. 27 00:01:51,840 --> 00:01:58,840 You met an event of something like comment moderated this will go over to the query service query service 28 00:01:58,840 --> 00:02:04,720 will see it and update the status of that given comment to approved or rejected or whatever it needs 29 00:02:04,720 --> 00:02:07,880 to be that's option number two. 30 00:02:07,980 --> 00:02:12,270 This definitely solves the issue of a user submitting a comment and not immediately seeing it appear 31 00:02:12,270 --> 00:02:18,440 on the screen but it does also in a persistent issue that we did not discuss about option number one. 32 00:02:18,480 --> 00:02:22,290 It's an issue that's present in option number 1 And option number two as well. 33 00:02:22,320 --> 00:02:28,420 So let me tell you about what the issue is that is common with one and two I want you to really think 34 00:02:28,510 --> 00:02:33,910 about the query service right now and once job is that query service is all about presentation. 35 00:02:33,910 --> 00:02:37,300 Logic is a matter fact its name is query service. 36 00:02:37,300 --> 00:02:43,580 It's about making a query or storing some data and serving that data up very quickly to users. 37 00:02:43,600 --> 00:02:48,490 So right now it's really joining just two resources just the posted comments. 38 00:02:48,520 --> 00:02:52,900 But at some point time in the future we could totally imagine that there might be other resources that 39 00:02:52,900 --> 00:02:58,240 it joins together as well such as maybe upvotes downvotes images. 40 00:02:58,240 --> 00:03:03,280 Who knows what else this query service might take many different resources and jammed them altogether 41 00:03:04,700 --> 00:03:07,610 and that's what this query service is really all about. 42 00:03:07,640 --> 00:03:09,230 So quick question for you. 43 00:03:09,440 --> 00:03:16,310 Does it make sense for this presentation service to understand how to process this very precise update 44 00:03:16,520 --> 00:03:19,490 to a comment like a comment moderated event. 45 00:03:19,640 --> 00:03:24,890 Does it make sense for the query service to understand how to process event like this. 46 00:03:24,890 --> 00:03:30,920 Well right now it's kind of easy to say yes because the common moderated event really just means go 47 00:03:30,920 --> 00:03:35,780 and find this comment and update updated status to approved or rejected or whatever else. 48 00:03:35,780 --> 00:03:41,000 So processing this event very simple and straightforward in nature it's one line of code more or less 49 00:03:41,540 --> 00:03:45,710 what I want you to think about a real world commenting system. 50 00:03:45,710 --> 00:03:51,170 Think about all the different ways in which a real world commenting system or a real world comment might 51 00:03:51,170 --> 00:03:56,530 be able to be updated a real world comment you might be able to moderate it. 52 00:03:56,530 --> 00:04:00,730 You might be able to upload it to downvoting you might be able to promote it. 53 00:04:00,730 --> 00:04:05,590 So maybe a moderator or someone in charge of a Web site can say this is a really high quality comment. 54 00:04:05,590 --> 00:04:08,480 I want to boost it up towards the top of all the comments. 55 00:04:08,810 --> 00:04:10,070 You might be able to make a comment. 56 00:04:10,090 --> 00:04:12,980 Anonymous you might be able to flag it as searchable. 57 00:04:13,060 --> 00:04:17,980 You might be able to market as an advertised comments like a comment that someone paid money to promote 58 00:04:17,980 --> 00:04:18,880 in some way. 59 00:04:19,650 --> 00:04:25,240 Each of these different precise updates to a comment has some very precise business logic associated 60 00:04:25,260 --> 00:04:27,920 with it to update the definition of that comment. 61 00:04:29,850 --> 00:04:36,760 So if we continue down this line of saying that our where a service is going to be able to process this 62 00:04:36,760 --> 00:04:41,890 comment my moderated event we're essentially saying that somewhere down the line we might end up in 63 00:04:41,890 --> 00:04:48,220 a scenario like this one right here where the query service needs to understand how to handle this multitude 64 00:04:48,490 --> 00:04:51,210 of different possible updates that can be made to a comment. 65 00:04:52,600 --> 00:04:57,700 And you can easily imagine that if there were other services like our query service maybe something 66 00:04:57,700 --> 00:05:03,280 to process weekly updates for popular blog posts or maybe something that functions as a recommendation 67 00:05:03,280 --> 00:05:04,110 service. 68 00:05:04,110 --> 00:05:06,850 And if those had to store the idea of what a comment is as well. 69 00:05:06,850 --> 00:05:09,800 In theory they might also have to handle these events. 70 00:05:10,060 --> 00:05:15,610 And so we start to get into this scenario where every possible way of changing a comment has to be handled 71 00:05:15,610 --> 00:05:18,450 by a ton of different services. 72 00:05:18,610 --> 00:05:19,950 And as you can imagine. 73 00:05:20,080 --> 00:05:20,310 Yeah. 74 00:05:20,320 --> 00:05:22,790 This is not even remotely what we want. 75 00:05:22,810 --> 00:05:29,100 So even though this all works and this is a more or less viable approach for our current application 76 00:05:29,100 --> 00:05:32,640 as it stands right now I'm going to suggest that maybe it's not the best solution. 77 00:05:32,860 --> 00:05:34,250 So we're going take one more pause. 78 00:05:34,270 --> 00:05:36,670 Come back the next video and discuss option number three.