KEMBAR78
Workshop - Golang language | PDF
www.eleven-labs.com
WORKSHOP
Factory
Vincent Composieux
@vcomposieux
GO
1972
(or 2008)
FIRST COMMIT
WHAT ABOUT GO?
Open-source & built by Google.
“Go is an open source programming
language that makes it easy to build
simple, reliable, and efficient
software.”
GO
RE-WRITTEN IN GO
WHO USE IT? (some)
WHY THEY USE IT?
SIMPLE, POWERFUL & COMPLETE
➔ Looks like C but way more simple
➔ Some really great core packages included
➔ A complete documentation of all packages
with godoc.org
➔ Build your application for all platforms
➔ High performances
CONCURRENCY
➔ Goroutines are easy to use to run something
in another thread (just prefix with go)
➔ Channels are here to help you synchronizing
data between Goroutines
WHAT IS CONCURRENCY?
APPLICATION
GOROUTINE #1
GOROUTINE #2
GOROUTINE #3
GOROUTINE #n
GOROUTINE #2 - 1
GOROUTINE #2 - 2
You can run unlimited goroutines, depending of your available resources.
You can run a goroutine from another goroutine (inception).
THE WORKSHOP
ABOUT
WHAT ARE WE BUILDING?
WORKMQ - A WORKER SERVICE
We will write ~290 lines of code that will allow to:
➔ Publish data over UDP protocol
➔ Multiple workers handling these data in concurrency (Goroutines)
➔ Synchronize data between these workers (Channels)
➔ Create a HTTP server to expose statistics information (number of
messages remaining, how many messages sent and processes by second
and by queue, …)
WORKMQ
SERVER
SENDER
CLIENT
UDP HTTP
FINAL HTTP OUTPUT
ABOUT THE WORKER
WORKMQ
SERVER
GOROUTINE QUEUE #1
GOROUTINE QUEUE #1
GOROUTINE QUEUE #1
GOROUTINE QUEUE #2
GOROUTINE QUEUE #2
GOROUTINE QUEUE #2
GOROUTINE QUEUE #4
GOROUTINE QUEUE #4
GOROUTINE QUEUE #4
GOROUTINE QUEUE #3
GOROUTINE QUEUE #3
GOROUTINE QUEUE #3
MESSAGE
CHANNEL
CHANNEL
CHANNEL
CHANNEL
WORKERS
QUEUE1
WORKERS
QUEUE3
WORKERS
QUEUE4
WORKERS
QUEUE2
UDP HTTP
YOUR ENGINE
LET’S START
THANK YOU

Workshop - Golang language

  • 1.
  • 2.
    1972 (or 2008) FIRST COMMIT WHATABOUT GO? Open-source & built by Google. “Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.” GO RE-WRITTEN IN GO
  • 3.
  • 4.
    WHY THEY USEIT? SIMPLE, POWERFUL & COMPLETE ➔ Looks like C but way more simple ➔ Some really great core packages included ➔ A complete documentation of all packages with godoc.org ➔ Build your application for all platforms ➔ High performances CONCURRENCY ➔ Goroutines are easy to use to run something in another thread (just prefix with go) ➔ Channels are here to help you synchronizing data between Goroutines
  • 5.
    WHAT IS CONCURRENCY? APPLICATION GOROUTINE#1 GOROUTINE #2 GOROUTINE #3 GOROUTINE #n GOROUTINE #2 - 1 GOROUTINE #2 - 2 You can run unlimited goroutines, depending of your available resources. You can run a goroutine from another goroutine (inception).
  • 6.
  • 7.
    WHAT ARE WEBUILDING? WORKMQ - A WORKER SERVICE We will write ~290 lines of code that will allow to: ➔ Publish data over UDP protocol ➔ Multiple workers handling these data in concurrency (Goroutines) ➔ Synchronize data between these workers (Channels) ➔ Create a HTTP server to expose statistics information (number of messages remaining, how many messages sent and processes by second and by queue, …) WORKMQ SERVER SENDER CLIENT UDP HTTP
  • 8.
  • 9.
    ABOUT THE WORKER WORKMQ SERVER GOROUTINEQUEUE #1 GOROUTINE QUEUE #1 GOROUTINE QUEUE #1 GOROUTINE QUEUE #2 GOROUTINE QUEUE #2 GOROUTINE QUEUE #2 GOROUTINE QUEUE #4 GOROUTINE QUEUE #4 GOROUTINE QUEUE #4 GOROUTINE QUEUE #3 GOROUTINE QUEUE #3 GOROUTINE QUEUE #3 MESSAGE CHANNEL CHANNEL CHANNEL CHANNEL WORKERS QUEUE1 WORKERS QUEUE3 WORKERS QUEUE4 WORKERS QUEUE2 UDP HTTP
  • 10.
  • 11.