Building a Config Service in Go | Home Automation #03
HTML-код
- Опубликовано: 30 авг 2018
- Learn how to think like a Computer Scientist at brilliant.org/jakewright
This is a bit of a lengthy video where I build the entire config service in golang. The config service will simply return another service's config over through an HTTP endpoint. Let me know if this is too long - might need to rethink how I do these videos in future.
The code from this video:
github.com/jakewright/tutoria...
The actual home automation repo:
github.com/jakewright/home-au...
----------------------------------------
4K CAMERA amzn.to/2EGMQRi
MICROPHONE amzn.to/2B0KqKS
CHEAPER MIC amzn.to/2EGFZHo
VLOGGING CAMERA amzn.to/2EGqGhZ
SMALLER CAMERA amzn.to/2EHMPg7
LED LIGHT amzn.to/2AZgMpB
TINY LIGHT amzn.to/2B0KJFx
SOCIAL MEDIA
twitter / jakewrightuk
facebook / jakewrightuk
instagram / jakewrightuk
snapchat jakewrightuk
jakewright.net - Наука
It's very rare to find videos like these, I am just starting out with Go after doing web development for more than 10 years (PHP and JS) and I subscribed to your channel. Thank you!
Always nice to see errors and your train of thought for fixing them, great video
I love this series! Am a total noob at coding, but your project is exactly what I wanna achieve for my home. So for me this is very very interesting and I'm hoping to be able to use some of your code on github for my own home automation system at some time in the future. Already excited for the next video 😊👍
Please continue the series on this. It is very interesting, and I love the content!
Great quality, doesn't matter if you can't post videos regularly, when you do they're 🔥. I couldn't helped but think on why you weren't using consul for this, this is its main use case but then I remembered you wanted to do everything so congrats for doing it
Hey man, a lot of us have been following your journey and would love more vlogs! Thanks and Keep it Up!
This is a good use case for Chef. Perfect for central config management. You can provision all of your RaspPis/containers with their respective apps, and drop their config files locally or populate envars with one command. You could even write a microservice to interact with Chef (using sous chef) and a web frontend to manage configs/envars, deploy new versions of your microservice, etc.
am coming from that video of PHP .. you posted it 5 years ago .. man !! you killed it .. big up ..
Glad to see another video of the series
Glad to see another video.
I love that you explain the code you write. I like Go, but I don't use it enough to know all the small things yet. Swift is pretty similar to Go, but not enough :D
*doesn't even know what does one call the **_thing_** you write the codes on*
*watches and frankly finds the home automation series entertaining anyway*
Love the series!! Keep up the good work, Jack!
"something that sits in the background all the time" you are looking for the word "daemon"
Excellent job sir. Both educational and interesting! Keep it up.
Greetings from Portugal.
I only found you yesterday and I'm already a big fan of your videos.
I have a little challenge for you :) What about adding golang tests to your code?
Great job.
This is a wonderful video. thanks for doing this series.
LOVE THIS SERIES!!!!! PLEASE POST MORE
Hey I just got into learning html with your older vids you did very helpful btw :) Really enjoying watching them and learning. What editor are you using for mac tho? I will go on vacation and I thought to take my mac with me and learn some stuff on the go why not? Any recommendations jake? (Maybe free ones for starters/ noobs ? :P ) Would appreciate your answer on that one cheers have a good one.
Ah finally you're back.
saludos Jack ,desde Veracruz, México !!!
Tnx for sharing idea. Will try to refactor this to run as gRPC API
Hi Jake,
love your vids. They're pretty pacy but you always explain things so well, so I can always pause and backtrack to make sure I've got it right.
Can you do one Hass.io? It looks like a great home automation solution. Cheers Rob.
Really nice video! Is there a reason you didn't want to use system events, for example inotify?
03:37 "not gonna say lets go" 😂😂😂so funny and u looking cute Jake
thanks for the series.. i am getting error while importing from "github.com/..../domain" it can not find package, it tries to load (from $GOROOT) and (from $GOPATH) . is there anyway to import this package from workspace/sub-dir, like we did in the python before.
Most interesting... One question... Would it be beneficial to monitor the config file and reload when it’s changed? That way you don’t have to wait the 30 seconds.
Cheers!
Jack you need to be constant bro .
nice video
Hi! Which terminal you are using?
Where are the vlogs?????
Hello Jake
Good to see you
I am in 11 and has taken computer science ur videos gonna help me....
And m so unlucky i cant go to hostel like you...And come to home for feeling good....
Staying at home studying isnt good distract from studies....
BTW Love you Jake ❤
pls continue the series
oh jakey jakey
How awesome would it be to do the reload, and then use websockets to let the other services know
That would also mean that you don't have to restart the other services to make sure they get the changed values
yay new vid :D
Where is the next tutorial?
You need to be consistent and committed man, At least ship out a video every 2 weeks or something or just keep us in the loop.
Nice
On the one hand, this seems like a lot of fun to write.
On the other... it'd have taken 10% of the time to write it in node.
Dylan Hanner except go is a much faster language
@@lego942 Performance isn't everything, cost of development time is a real thing. But also not strictly too true anyway. The JIT can do a lot of legwork and oftentimes produces some ridiculously fast code.
Also for a webserver, node's non blocking nature of file reads means it'd be able to handle more simultaneous requests.
Honestly I'm still waiting for a Cooking With Jake video 😭
Great video, unfortunately, I am hitting an error. at the 20ish minute mark, when typing c.Readconfig into the main i get this warning from VS Code "cannot use c.ReadConfig (type func(http.ResponseWriter, *http.Request)) as type http.Handler in argument to router.Get:
func(http.ResponseWriter, *http.Request) does not implement http.Handler (missing ServeHTTP method)"
Anyone know what this is?
Better late then never, the api changed a bit, after some google your main.go should look like so:
func main() {
config := domain.Config{}
configWorker := worker.ConfigWorker{
Config: &config,
Location: "config.yml",
}
go configWorker.Watch(time.Second * 3)
c := controller.Controller{
Config: &config,
}
router := mux.NewRouter()
router.SkipClean(true)
router.HandleFunc("/read/{serviceName}", c.ReadConfig)
http.ListenAndServe(":8080", router)
}
Coding is my life 😎
Hey did you abandoned this project?
Jake likes blue and yellow.
The video isnt long Jake Study related videos are long
wouldn't it make more sense to use a native file system notifications library instead, to reduce the overall cpu usage? eg. github.com/fsnotify/fsnotify
Yes, that's a good idea actually. I might switch to that, though the difference will be negligible in this case since I'm only reading one file every 30 seconds.
6:25 I always panic if there's an error
This is a really cool topic and you did great work in this video but over all wouldn't Consul (consul.io) be a good option to use. Trying to avoid SPF Consul has the the concept of clusters. Then you can query that however you would like. Since you are using Docker store.docker.com/images/consul. Keep up the great work!
Why go?
Can you please go unemployed again so we can have more vlogs? Thanks in advance....
Why are there dislikes for learning new things
People disagreeing with his methods
You should try github.com/ghodss/yaml for reading / writing yaml. It always takes string as key.
Oh god, that GO linter complains if there's no block comment? That's horrendous. I can only imagine the half assed kinds of explanations and gunk that usually leads to
I'm so lost :(
Brother please make a video about cracking
Are u a wright descendant
It is hard
One letter variable names. Eesh!
I believe that's idiomatic in Go
Hi
I am looking for next update.....
wish u can be my partner..
U r looking younger than me I m 23
Hey, bro. First I just wanna to say that my english can be bad... I came from Russian youtuber who was saying that you are making $3000000 per year and have a lot of channels on youtube with personal workers. I just wanna ask you. Is it real? 'cause now our russian youtubers just trying to hype on something and 99% of their videos are fake
Go syntax is ugly
Agreed