Skip to content
An event-driven example to demonstrate the use and impact of goroutines
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/eventdemo
.gitignore
LICENSE
README.md
arch.png
dispatcher.go
filter.go
generator.go
handler.go
handlerGoodbye.go
handlerHello.go
handlerPing.go
message.go

README.md

eventdemo

An event-driven example to demonstrate the use and impact of goroutines.

Installation

  • go get github.com/sebsprenger/eventdemo to download code into $HOME/go/src/
  • go run github.com/sebsprenger/eventdemo/cmd/eventdemo to build and execute

Overview

There is a generator generating events/messages into a channel. This channel is read by a filter, filtering all message types by default and passing them in yet another channel. The dispatcher reads the filtered channel and dispatches the messages to different handlers where they are printed. All parts are connected to a WaitGroup to synchronize. Various parts of the code contain a time.Sleep() to simulate some work. Adding the go keyword in the right places accelerates execution of the program by orders of magnitude.

Architecture

You can’t perform that action at this time.