golang context package explained: the package that changed concurrency forever

  Рет қаралды 6,719

Kantan Coding

Kantan Coding

2 ай бұрын

In this video we go over a visualization of how the context package works in golang.
Golang Microservices Full Course!:
kantan-coding.teachable.com/p...
► Join my Discord community 👉 / discord

Пікірлер: 38
@kantancoding
@kantancoding Ай бұрын
🌟 Hey devs! 🌟 Ready to level up your coding game? Check out this awesome course on Microservices using Go! 🚀 From beginner to pro, learn to build scalable apps with ease. Don't miss out! Enroll now 👉 kantan-coding.teachable.com/p/early-bird-special-pricing #GoLang #Microservices #CodeWithConfidence 🔥🎉
@sinahassani9880
@sinahassani9880 17 күн бұрын
This explanation is worth paying time for
@kantancoding
@kantancoding 2 күн бұрын
Thank you! I’m glad it helped 🙂
@brandon_wallace
@brandon_wallace 2 ай бұрын
Excellent!
@kantancoding
@kantancoding 2 ай бұрын
Glad you liked it!
@folklinoff
@folklinoff 2 ай бұрын
Amazingly structured comprehensive video! Thank you very much
@kantancoding
@kantancoding 2 ай бұрын
Thank you! Happy to help 😊
@user-tw8wb1id3l
@user-tw8wb1id3l 2 ай бұрын
Thanks mate. I've enjoyed your video series on concurrency in GO. Nice and clear explanation. Very helpful. Keep on the good work.
@kantancoding
@kantancoding 2 ай бұрын
Hey! Thanks for the encouragement. I’m glad you enjoyed it 😊
@defnd3r
@defnd3r 2 ай бұрын
Glad you're back to making Go videos man... They're super useful
@kantancoding
@kantancoding 2 ай бұрын
Thank you! More to come!
@ShadwTrooper
@ShadwTrooper Ай бұрын
Super helpful. Thanks!
@kantancoding
@kantancoding Ай бұрын
Happy to help 🙂
@marioluigi2995
@marioluigi2995 2 ай бұрын
hey man, welcome back, I'll watch your vid.
@kantancoding
@kantancoding 2 ай бұрын
Thank you for watching! More to come 😊
@LeviElekes
@LeviElekes 2 ай бұрын
🙏
@Porumb007
@Porumb007 8 күн бұрын
Good explanation. Do you really need to duplicate the code for ctx cancel handling? Can't you have it in a separate function? Your function naming in the example is kind of bad.
@kantancoding
@kantancoding 8 күн бұрын
Thanks! Happy to help 🙂
@aamirshekh934
@aamirshekh934 Ай бұрын
can you do a video on ticker package and go sarama package. Both of them doesn't have any good resources on youtube.
@kantancoding
@kantancoding Ай бұрын
not sure at the moment but I will keep it in mind! ☺️
@user-pc7bv8vk4p
@user-pc7bv8vk4p 2 ай бұрын
Sir upload go tutorial for beginners
@kantancoding
@kantancoding 2 ай бұрын
Hmm I have quite a few geared towards beginners. Is there anything specific you want to see?
@user-pc7bv8vk4p
@user-pc7bv8vk4p 2 ай бұрын
@@kantancoding yes, I am beginner in programming. Golang is my first programming language
@kantancoding
@kantancoding 2 ай бұрын
Introduction to Programming Using Go kzbin.info/www/bejne/ZmmlnZ6mpJZ5bqs
@stupidfilip23
@stupidfilip23 2 ай бұрын
hiii, we missed you
@kantancoding
@kantancoding 2 ай бұрын
Hello!! Me too!!
@dawnrazor
@dawnrazor 6 күн бұрын
Great video, but what happens when you DO want to cancel a parent context from a child. I have this exact scenario and in this case I pass in the parents cancel to the child gr. this works fine but this seems to be going against the grain. How do you cancel the parent without passing cancel func? What is wrong with this?
@kantancoding
@kantancoding 6 күн бұрын
I can’t think of any valid scenario where you’d cancel the parent from a child goroutine. I’d say the fact that you want/need to do this points out a fundamental design flaw in your application. I can help more if you tell me WHY you feel it is necessary to cancel the parent from the child.
@dawnrazor
@dawnrazor 5 күн бұрын
@@kantancoding great thanks. I knew it was wrong but I couldn’t figure out how to fix it properly. I have designed a worker pool. The worker pool exposes an optional output channel that the client can read from for results. But if the client doesn’t define a consumer for the channel, then the pool will lockup. So I decided to introduce a feature that would timeout and allow the pool exit gracefully. I do this by allowing the worker to cancel the parent context so the whole pool including other workers to exit gracefully. Only the worker knows when the timeout occurs not the parent. How can I fix this? (gh/snivilised/lorax/boost/issues/68)
@kantancoding
@kantancoding 5 күн бұрын
@@dawnrazorif you’re just using a timeout mechanism, just set the timeout in the context that you pass from the parent to the children using WithTimeout() (I explained how to use it in the video). Hope that helps!
@dawnrazor
@dawnrazor 5 күн бұрын
@@kantancoding hi again, actually I don’t think your approach will work and the reason is this. The worker is running a task and there is no way to know how long the task will take. So what value do you set for the timeout in the parent context. There is no sensible value that you could come up with. And besides, the timer should only start at the point when the worker has attempted to sent to the output channel. Am I wrong about this?
@dawnrazor
@dawnrazor 11 сағат бұрын
@@kantancoding just wanna say thanks for making me realise that trying to cancel a parent from a child was totally wrong. I’m junking my entire worker pool and starting again with a better design
@NigelTatschner
@NigelTatschner 27 күн бұрын
You alllll get a context 😂
@kantancoding
@kantancoding 26 күн бұрын
😂🤣
@rishirajrao5337
@rishirajrao5337 Күн бұрын
Honest feedback, it was bit verbose and was lacking clarity unlike other tutorials. Thanks anyway for the effort.
@kantancoding
@kantancoding Күн бұрын
Thanks for watching! 🙂
Master Go Programming With These Concurrency Patterns (in 40 minutes)
46:15
zig is the future of programming. here's why.
9:34
Low Level Learning
Рет қаралды 174 М.
СҰЛТАН СҮЛЕЙМАНДАР | bayGUYS
24:46
bayGUYS
Рет қаралды 580 М.
Don’t take steroids ! 🙏🙏
00:16
Tibo InShape
Рет қаралды 64 МЛН
Chips evolution !! 😔😔
00:23
Tibo InShape
Рет қаралды 37 МЛН
Golang Channels Or Wait Groups? Let Me Explain.
18:32
Anthony GG
Рет қаралды 16 М.
Read and Write files in Golang #golang
7:07
practicego
Рет қаралды 272
Python Hash Sets Explained & Demonstrated - Computerphile
18:39
Computerphile
Рет қаралды 104 М.
Master Golang with Abstraction
13:30
Kantan Coding
Рет қаралды 1,9 М.
Learn Go context from code and its original blog post
6:45
Bitwise Man
Рет қаралды 3,5 М.
#24 Golang - Concurrency: Unbuffered vs Buffered Channels
7:48
Why The Golang 1.22 HTTP Router Is Not Great
8:19
Anthony GG
Рет қаралды 12 М.
How To Use Goroutines For Aggregating Data In Golang?!
17:15
Anthony GG
Рет қаралды 33 М.
Function Iterators might just change the way we write loops in Go
11:35
СҰЛТАН СҮЛЕЙМАНДАР | bayGUYS
24:46
bayGUYS
Рет қаралды 580 М.