Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,040 --> 00:00:04,410
The last couple of videos we've had have been just a bunch of lecturing for me.
2
00:00:04,420 --> 00:00:05,770
I know that's super boring.
3
00:00:05,770 --> 00:00:09,700
Just one more lecture and we're gonna start writing some code again in this video we're going to go
4
00:00:09,700 --> 00:00:11,950
over the design of the event bus.
5
00:00:11,950 --> 00:00:16,450
We're going to talk about how we can use the event bus to communicate events for one service over to
6
00:00:16,450 --> 00:00:18,120
another as a reminder.
7
00:00:18,130 --> 00:00:23,260
We're going to try to build as much of as this stuff as possible from scratch rather than using some
8
00:00:23,320 --> 00:00:24,790
off the shelf solution.
9
00:00:24,790 --> 00:00:26,360
And that includes the event bus.
10
00:00:26,430 --> 00:00:28,390
So we're going to build this event bus on our own.
11
00:00:28,420 --> 00:00:31,020
We're going to build it using JavaScript and express.
12
00:00:31,130 --> 00:00:34,570
I want to give you a couple notes on how this thing needs to work.
13
00:00:34,760 --> 00:00:40,150
OK so event buses the first thing to understand about them is that there are many different implementations
14
00:00:40,150 --> 00:00:41,080
available.
15
00:00:41,080 --> 00:00:45,900
You might have heard of terms like rabbit and Q Kafka or nets.
16
00:00:45,940 --> 00:00:48,010
These are all different types of event buses.
17
00:00:48,040 --> 00:00:49,460
They're open source projects.
18
00:00:49,570 --> 00:00:55,860
You can download them and run them yourself or you can get some kind of pre hosted provided solution.
19
00:00:55,920 --> 00:01:00,750
The one common thing between these different event buses is that they're going to receive events and
20
00:01:00,750 --> 00:01:04,750
then publish them out to listeners when we use the term events here.
21
00:01:04,750 --> 00:01:07,290
We're really talking about some piece of information.
22
00:01:07,330 --> 00:01:10,350
There's no set structure of what a event has to look like.
23
00:01:10,480 --> 00:01:11,440
It can be Jason.
24
00:01:11,440 --> 00:01:13,470
It can be Rob bytes of data.
25
00:01:13,480 --> 00:01:14,620
It can be a string.
26
00:01:14,620 --> 00:01:18,840
It can be whatever you want to share between your different services.
27
00:01:19,090 --> 00:01:23,740
When we use the term listeners we're talking about other services that want to listen to events that
28
00:01:23,740 --> 00:01:31,530
are being emitted now between these different implementations of say rabbit and Q Kafka Nats and many
29
00:01:31,530 --> 00:01:33,020
others that exist out there.
30
00:01:33,060 --> 00:01:38,370
Turns out that there are many very small features available in these different event buses that make
31
00:01:38,370 --> 00:01:41,680
some things a lot easier or a lot harder.
32
00:01:41,710 --> 00:01:46,190
So in this larger application that we're gonna work on in the second half of this course I picked a
33
00:01:46,210 --> 00:01:50,880
event bus that is really easy to get started with extremely fast.
34
00:01:50,880 --> 00:01:55,170
But there are some downsides to it as well somethings that are going to make our lives a little bit
35
00:01:55,170 --> 00:01:56,010
more complicated.
36
00:01:56,580 --> 00:02:01,140
So you just need to be aware that you cannot just pick one these implementations off the shelf you kind
37
00:02:01,140 --> 00:02:04,010
of have to evaluate them and understand what they can really do for you.
38
00:02:05,050 --> 00:02:08,280
Now once again we are going to build our own event buses Inn Express.
39
00:02:08,410 --> 00:02:15,800
It is not going to implement the vast vast majority of features that a normal event bus has to.
40
00:02:15,810 --> 00:02:21,910
Ours is going to be incredibly simplistic incredibly simple not very useful outside this one single
41
00:02:21,910 --> 00:02:23,010
implementation.
42
00:02:23,170 --> 00:02:27,220
But again we're going to build this from scratch just you have a really good idea of what is going on
43
00:02:27,220 --> 00:02:28,450
behind the scenes.
44
00:02:28,660 --> 00:02:32,200
And yes again for our next application we're going to work on the much larger one.
45
00:02:32,250 --> 00:02:35,080
We are going to use a production grade even bus.
46
00:02:35,110 --> 00:02:39,940
This is an event bus that is used in many many very large deployments and projects.
47
00:02:39,940 --> 00:02:43,860
So you're going to get some very practical experience with some real technology as well.
48
00:02:45,130 --> 00:02:45,440
All right.
49
00:02:45,460 --> 00:02:49,930
Let's talk about the Express based event bus that you and I are going to put together.
50
00:02:49,930 --> 00:02:53,890
Now this really is a very simplistic implementation for event bus.
51
00:02:53,890 --> 00:02:58,600
The reason we are doing such a simple implementation is just you can see how this stuff kind of works
52
00:02:58,600 --> 00:02:59,500
behind the scenes.
53
00:02:59,590 --> 00:03:03,640
And so you can very easily see the flow of data throughout our application.
54
00:03:03,640 --> 00:03:09,110
Let me tell you about how this thing is going to work we are going to add in a new route to our postal
55
00:03:09,110 --> 00:03:10,880
service intercom in service.
56
00:03:10,880 --> 00:03:14,780
We're also gonna make sure that our query service has a very similar route as well.
57
00:03:14,780 --> 00:03:19,520
Each of these routes are going to watch for a post request to a path of slash events.
58
00:03:19,520 --> 00:03:21,770
We'll talk about the purpose of that in just a moment.
59
00:03:22,460 --> 00:03:26,720
At some point time inside our application we're going to have our postal service or common service decide
60
00:03:26,720 --> 00:03:32,480
that it needs to emit an event whenever a service needs to emit any event it's going to make a post
61
00:03:32,480 --> 00:03:37,490
request off to this new event bus that you and I are going to put together again this event bus right
62
00:03:37,490 --> 00:03:40,540
here is going to be a plane express application.
63
00:03:40,600 --> 00:03:47,240
Essentially we're really just doing a post request from one service to another in that post request.
64
00:03:47,290 --> 00:03:52,360
We're going to attach along some event data so it's going to be some object that represents this event
65
00:03:52,360 --> 00:03:58,990
right here this event bus is going to receive this event that's going to take that event and make a
66
00:03:58,990 --> 00:04:01,850
series of post request with it.
67
00:04:01,900 --> 00:04:07,480
So it's going to take all that event data and it's going to take that exact information and just send
68
00:04:07,480 --> 00:04:12,040
it off to a post request to local host 4000 slash events.
69
00:04:12,130 --> 00:04:13,660
That would be our postal service.
70
00:04:13,960 --> 00:04:19,510
That's going to make an identical request off to a local Post four thousand one slash events.
71
00:04:19,510 --> 00:04:23,320
And same thing or local localized 4000 to social events.
72
00:04:23,740 --> 00:04:29,460
So in all three of these post requests it's going to send along this event data so in short any time
73
00:04:29,640 --> 00:04:34,980
one of our services makes a post request over to event bus event bus is just going to take that exact
74
00:04:34,980 --> 00:04:39,900
information and throw it out to everything else that we have running inside our application even the
75
00:04:39,900 --> 00:04:44,810
same service that emitted the event originally so that's it.
76
00:04:44,820 --> 00:04:47,460
That's how simple our event bus is going to be.
77
00:04:47,460 --> 00:04:51,900
Now again as we start to use some more production ready application or solutions here for the event
78
00:04:51,900 --> 00:04:55,260
bus you can see that there's a lot more to this implementation.
79
00:04:55,360 --> 00:05:00,150
But at the end of the day this is pretty much what is going on more or less we're throwing an event
80
00:05:00,180 --> 00:05:04,950
over to the event bus even bus is just going to echo that event back over to all of our different services
81
00:05:06,710 --> 00:05:08,430
now that we've got an idea of what's going on here.
82
00:05:08,540 --> 00:05:09,180
Quick pause.
83
00:05:09,200 --> 00:05:13,400
We're going to start building this event bus which is a very simple very straightforward in the next
84
00:05:13,400 --> 00:05:13,760
video.
8914
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.