1 00:00:01,310 --> 00:00:03,580 Now we've got a better idea of what this feature is. 2 00:00:03,590 --> 00:00:06,740 We're going to take a look at a couple of different ways of implementing it. 3 00:00:06,770 --> 00:00:08,040 So let's get to it. 4 00:00:08,090 --> 00:00:12,060 The first thing I want to do is just give you a very quick review on how our system works right now. 5 00:00:12,170 --> 00:00:18,060 At present we have the Postal Service comments and query whenever a user submits a comment the comment 6 00:00:18,060 --> 00:00:24,650 service is going to emit an event over to the event buzz of comment created the event buzz is then going 7 00:00:24,650 --> 00:00:30,620 to take this event and send it out automatically to all the different services inside of our app including 8 00:00:30,650 --> 00:00:32,000 the comment service. 9 00:00:32,000 --> 00:00:39,910 Like so now at present the post service and comment service although the received this event they don't 10 00:00:39,910 --> 00:00:41,640 actually process it in any way. 11 00:00:41,770 --> 00:00:44,630 They just say OK here's an event I don't really care. 12 00:00:44,740 --> 00:00:50,110 The query service however does do some processing of the query service is going to take this event and 13 00:00:50,110 --> 00:00:55,060 use it to understand this new comment that was just created and it stores it inside of some local data 14 00:00:55,060 --> 00:00:56,050 structure. 15 00:00:56,080 --> 00:00:58,820 So again that's what's going on inside of our system right now. 16 00:00:58,840 --> 00:00:59,920 I know we just did this. 17 00:00:59,920 --> 00:01:04,210 And so it's kind of me repeating myself to tell you what's going on but it's really critical for you 18 00:01:04,210 --> 00:01:08,440 to understand this flow because the options are about to go through for implementing this new feature 19 00:01:08,440 --> 00:01:10,690 are going to be pretty darn complex. 20 00:01:10,690 --> 00:01:13,020 So with that having been said let's get to it. 21 00:01:13,030 --> 00:01:17,820 Let's take a look at option number one so an option number one. 22 00:01:17,850 --> 00:01:20,150 I first want you to take a look at this diagram. 23 00:01:20,190 --> 00:01:23,550 You'll notice I've added in a new moderation service right here. 24 00:01:23,550 --> 00:01:28,470 So this is going to be a service that is in charge of taking a look at a comment and deciding whether 25 00:01:28,470 --> 00:01:31,170 or not it should be approved or rejected. 26 00:01:31,170 --> 00:01:35,850 You'll also notice in this diagram I have removed the post service entirely. 27 00:01:36,120 --> 00:01:39,870 That is not because we're going to delete the post service I just removed it for clarity so you can 28 00:01:39,870 --> 00:01:41,460 better understand this diagram. 29 00:01:41,460 --> 00:01:46,310 This whole idea of comments in moderation and whatnot really doesn't have anything tied to the postal 30 00:01:46,310 --> 00:01:48,530 service whatsoever OK. 31 00:01:48,540 --> 00:01:54,150 So in this idea with option number one we're going to have a sort of chain going on where we're going 32 00:01:54,150 --> 00:01:58,920 to have the common service emit an event saying that accomplishes created the moderation service will 33 00:01:58,920 --> 00:02:01,500 then emit an event saying that the com was moderated. 34 00:02:01,500 --> 00:02:04,240 And then finally the query service will process that comment. 35 00:02:04,260 --> 00:02:06,920 So let's take a look at exactly what would occur. 36 00:02:06,930 --> 00:02:12,300 So once again we're gonna have a user submitting a comment to the common service the comment service 37 00:02:12,330 --> 00:02:16,850 will then immediately persist information about that comment as it is doing right now. 38 00:02:17,040 --> 00:02:22,260 So it will create some new record with say an I.D. and some content and probably the post I.D. as well 39 00:02:22,380 --> 00:02:27,550 but we'll just ignore that for right now because it's not a relevant property as soon as it persists 40 00:02:27,640 --> 00:02:34,000 that new pope comment the comment service will then continue to emit any event over to the event buzz 41 00:02:34,330 --> 00:02:36,020 of comment created. 42 00:02:36,070 --> 00:02:41,140 So it's gonna throw this over to the event buzz and the event buzz in turn is going to send that event 43 00:02:41,380 --> 00:02:46,170 out to all of our different services as it is doing right now. 44 00:02:48,920 --> 00:02:54,260 Now with option number one we're gonna say that the only service that cares about comment created is 45 00:02:54,260 --> 00:02:56,370 going to be the moderation service. 46 00:02:56,390 --> 00:03:01,310 So we're gonna stay with option number one very service no longer cares about that event. 47 00:03:01,460 --> 00:03:07,510 So functionally only the moderation service is going to process come and create it the moderation service. 48 00:03:07,520 --> 00:03:13,760 We'll take a look at the content of this comment and decide whether or not to approve it or reject it. 49 00:03:13,820 --> 00:03:18,740 So we'll say that in this case because content does not have the word orange the moderation service 50 00:03:18,770 --> 00:03:21,300 will approve this comment. 51 00:03:21,340 --> 00:03:26,120 So to tell all the other services that this comment has just been approved we'll have the moderation 52 00:03:26,120 --> 00:03:30,440 service emit a brand new event that we're going to introduce right now. 53 00:03:30,570 --> 00:03:36,630 All the comment moderated event the data of this event is going to have all the information about this 54 00:03:36,630 --> 00:03:40,020 comment along with the status of the comment as well. 55 00:03:40,020 --> 00:03:46,740 So in this case we'll say status approved the moderation service will emit this it'll go over to our 56 00:03:46,740 --> 00:03:52,690 event plus and once again it'll be sent to all of the different services inside of our app 57 00:03:57,050 --> 00:04:02,120 now the only service that probably cares about this event will be beat query service the query service 58 00:04:02,120 --> 00:04:04,250 will listen for comment moderated. 59 00:04:04,250 --> 00:04:08,930 It's going to take all the information out of that data property and persistence the query service will 60 00:04:08,930 --> 00:04:12,640 now know the idea the comment its content and its status. 61 00:04:13,710 --> 00:04:17,140 As well like so. 62 00:04:17,290 --> 00:04:20,830 So now anytime soon makes a follow up request the query service they will see. 63 00:04:20,840 --> 00:04:21,240 Okay. 64 00:04:21,250 --> 00:04:24,120 Here is a comment and its status is approved. 65 00:04:24,970 --> 00:04:30,820 So let's talk about the pros and cons of this approach because there are very much some very big negatives 66 00:04:30,820 --> 00:04:37,450 to it the big negative to this approach is the fact that there is some delay between a user somebody 67 00:04:37,450 --> 00:04:43,260 a comment and that common actually being persisted by the query service so I want you to think back 68 00:04:43,260 --> 00:04:47,630 to the mockup you're looking at just a moment ago a comment truly has three states. 69 00:04:47,790 --> 00:04:54,210 It can be approved as it is right here rejected or pending moderation. 70 00:04:54,210 --> 00:04:57,560 I want you to really think about that pending moderation state. 71 00:04:57,660 --> 00:05:04,230 Right now we are really assuming that this entire approval process by the moderation service is instantaneous 72 00:05:04,260 --> 00:05:10,770 in nature but it is entirely possible that maybe at some point down the line we decide that rather than 73 00:05:10,770 --> 00:05:16,710 just checking to see if a comment has the word orange in it maybe Instead we rely upon a human to moderate 74 00:05:16,710 --> 00:05:18,000 these comments. 75 00:05:18,030 --> 00:05:22,260 A human can not process comments or moderate them instantaneously. 76 00:05:22,260 --> 00:05:28,440 It might take a person several seconds minutes hours even days to read a comment and decide whether 77 00:05:28,440 --> 00:05:30,900 or not to approve it or reject it. 78 00:05:30,900 --> 00:05:37,250 So think about what would happen if our moderation service took a long time to run let's go through 79 00:05:37,250 --> 00:05:40,490 the scenario again and assume that it's going to take some amount of time. 80 00:05:40,550 --> 00:05:43,930 The moderation service to actually process a comment. 81 00:05:43,990 --> 00:05:44,350 OK. 82 00:05:44,390 --> 00:05:49,730 So once again a user is going to submit a comment comment service will persist that and the comment 83 00:05:49,730 --> 00:05:56,510 service will limit this event and that event is going to be sent on over to the moderation service where 84 00:05:56,510 --> 00:06:01,160 it's then going to await actual moderation now. 85 00:06:01,170 --> 00:06:04,050 At that point in time we're essentially paused in this workflow. 86 00:06:04,080 --> 00:06:06,730 Nothing else is going to happen anytime soon. 87 00:06:06,810 --> 00:06:07,910 And so in this scenario. 88 00:06:07,920 --> 00:06:13,650 Well that might sound OK but I want you to really think about the user experience what happens to a 89 00:06:13,650 --> 00:06:16,730 user as they are actually using our application. 90 00:06:16,740 --> 00:06:22,020 Think about what would happen if a user typed in some comment right here and clicked on submit and then 91 00:06:22,230 --> 00:06:28,950 critically refreshed the page when a user refreshes the page after submitted a comment they expect to 92 00:06:28,950 --> 00:06:34,530 see the new comment listed on here immediately or at least something that says Hey your comment is waiting 93 00:06:34,530 --> 00:06:41,100 pending or pending moderation or something similar so with the approach we're discussing right now we're 94 00:06:41,120 --> 00:06:46,670 saying that after a user refreshes their page they are not going to immediately see that comment from 95 00:06:46,670 --> 00:06:51,800 the query service right away because it's going to take some amount of time for the moderation service 96 00:06:51,950 --> 00:06:57,470 to actually process that thing and then tell the query service that there's this new comment to the 97 00:06:57,470 --> 00:07:02,990 downside of option number one is that this entire flow could potentially result in a user not seeing 98 00:07:02,990 --> 00:07:07,430 the information that they just submitted very very easily. 99 00:07:07,430 --> 00:07:12,020 Now I want you to understand that this idea of a user making a change and then not seeing that immediately 100 00:07:12,050 --> 00:07:16,830 reflected that's something that's going to come up all the time in this idea of micros services. 101 00:07:16,910 --> 00:07:20,780 So this is a very big thing that we're going to discuss quite a bit throughout the course but just in 102 00:07:20,780 --> 00:07:26,030 this scenario because of the possibility of the moderation service being ran by an actual human we're 103 00:07:26,030 --> 00:07:28,990 kind of exacerbating that problem. 104 00:07:29,080 --> 00:07:33,070 So I think that option number one has a definite and immediate downside to it. 105 00:07:33,110 --> 00:07:35,910 So as you can imagine we're not going to go with option number one. 106 00:07:35,960 --> 00:07:37,210 Now let's take a quick pause right here. 107 00:07:37,210 --> 00:07:41,490 We're then going to take a look at options 2 and 3 much more quickly now that we understand some of 108 00:07:41,500 --> 00:07:43,390 the general issues that we're going to run into.