Learning Golang: Concurrency Patterns Fan-In and Fan-Out

preview_player
Показать описание
Welcome! Let's learn about Go/Golang Concurrency Patterns, this time we are covering Fan-in and Fan-Out!

* What is a Fan-In Concurrency Pattern in Go/Golang?
Consolidation of multiple channels into one channel by multiplexing each received value.

* What is a Fan-Out Concurrency Pattern in Go/Golang?
Breakup of one channel into multiple ones by distributing each value.

---

RELEVANT LINKS

00:00 Intro
00:25 What is Fan-In Concurrency Pattern?
01:06 Example of Fan-In Concurrency Pattern
07:56 What is Fan-Out Concurrency Pattern?
09:07 Example of Fan-In Concurrency Pattern
12:18 Conclusion

---

Who am I:

Hello👋🏼! I'm Mario, a Hands-on Software Architect and Lead Backend Engineer with more than 16 years of professional experience building all kinds of software including on-premise Industrial Automation Systems, Linux Accessibility Desktop and Browser Components as well as Distributed Advertising Microservices.

Every week I will share with you different topics I've learned while working for small startups and large companies including the processes I've followed over the years for successfully delivering complex enterprise systems from start to end.

Subscribe if you like Software Development, Software Architecture and Systems Design!

Keep it up. Don't give up!

#golang #tutorial #concurrency

--- Our affiliate links below

--- Follow us along on Instagram for our family adventures

Рекомендации по теме
Комментарии
Автор

Thanks, Mario! I'm doing a quick crash review on concurrency and such. Great presentations.

sovatorg
Автор

Thank you, need more videos like this

damir
Автор

in merge 2 you do not close wait channel, you need to close it after you break loop

TheShprota
Автор

Incredible channel man. Thank you for all your work.

abelian
Автор

Thank you Mario for your work,
Just one thing about merge2, we'll have a deadlock in the case we have zero parameter i.e calling merge2(), you need to check the value of chans and return nil if chans == 0, and also in the main function you need to check chM==nil and close(exit).

yakhoubakeita
Автор

👍 Good videos, more practical. Thanks

kakhabervk
Автор

can you explain why you put wg.wait() in a goroutine please? 4:39

KaiAlgo
Автор

You're a big help.. thank you so much.

ian
Автор

go func() {
for v := range chM {
fmt.Println(v)
}
close(exit)
}()
<-exit
Why making it a separate goroutine if we're waiting for it to run completely on the next line..?

MaksymMinenko
Автор

u r a legend buddy !! So helpful, Aamazing content.
Would you mind doing a video on communication between two microservices using rest, graphql and grpc, That gonna be a huge learning tutorial.

Thanks a ton !!

bjugdbjk
Автор

Great Video!! But you see, every instance in the video, where I did not understand a part of the code (or its necessity) you said, we'll cover that in another video 😂. Please provide good attached links to explain that part of the video, for e.g: using the exit channel, the way you did.

adityanittala
Автор

Im amaze how I can easily create backend following you. I hope you will add user management and authorizatiin

ian
Автор

Could you do the below for the merge function:

func merge(cs ... <-chan []string) <-chan []string {
out := make(chan []string)

go func() {
for _, c := range cs {
for n := range c {
out <- n
}
}

close(out)
}()

return out
}

The downside it it's only making use of one goroutine but if the goal is just to fan in the data from multiple channels into one exit channel and also the data to be consistently outputted then I guess this works. Also means you don't need to use the sync package which I like personally :) I guess this works without sync package because we're using buffered channels that block, but I get confused what blocks and doesn't so might be wrong on that. Thanks for the video though, much appreciated.

theJamieBenShaw
Автор

what the statement means: wait <- struct{}{}

tyro
Автор

Hi, Can you reorder playlist Learning Golang correctly? It looks like intro is after the second part. I will appreciate if you can order this playlist in a way one should follow.

and yes, thank you for the videos.

anujtyagi
join shbcf.ru