owned this note changed 5 years ago
Linked with GitHub

Job Queue In Golang - 吳柏毅

歡迎來到 MOPCON 2019 共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

共筆入口:https://hackmd.io/@mopcon/2019
手機版請點選上方 按鈕展開議程列表。

會場 wifi-SSID: mopcon-2019
會場 wifi-PASSWD: mopcon-2019

tags: MOPCON 2019

Why not use open source

Single service

  • Build in SQLite(LDAP, Job List)
  • Build in Cache(LRU)
  • Build for single binary
  • No third-party dependency

Bufferd V.S. Unbuffered

在面試使用 Go 語言公司時,一定會被問到的問題

用五分鐘了解什麼是 unbuffered vs buffered channel

Unbuffered channel

func main () { C := make(chan bool) go func() { fmt.Println("GO GO GO") c <- true }() <-c }
func main () { C := make(chan bool) go func() { fmt.Println("GO GO GO") c <- true c <- true }() <-c time.Sleep(1 * time.Second) }

Buffered channel

func main () { C := make(chan bool, 1) go func() { fmt.Println("GO GO GO") c <- true }() <-c }

How to implement Job Queue in Go

func worker(jobCh) jobChan := make(chan Job, 1024)

BLOCK IF THERE ALREADY ARE 1024 JOB

一些網路相關資源

Golang Workers / Job Queue by harlow on Github
和講者有類似的Work Pool架構,同樣用HTTP做指令傳輸:
https://gist.github.com/harlow/dbcd639cf8d396a2ab73

Jobqueue by Olivere
有網頁UI:
https://github.com/olivere/jobqueue

Select a repo