Skip to content

Instantly share code, notes, and snippets.

@thinhdanggroup
Created April 2, 2020 10:10
Show Gist options
  • Save thinhdanggroup/a748c87d345a6f8803785c3f27680636 to your computer and use it in GitHub Desktop.
Save thinhdanggroup/a748c87d345a6f8803785c3f27680636 to your computer and use it in GitHub Desktop.
Executor Example
func main() {
executor, err := executor.New(executor.DefaultConfig())
if err != nil {
logrus.Error(err)
}
// close resource before quit
defer executor.Close()
for i := 0; i < 3; i++ {
executor.Publish(mul, i)
executor.Publish(pow, i)
executor.Publish(sum, i, i+1)
}
}
func mul(input int) {
fmt.Printf("2 * %d = %d \n", input, 2*input)
}
func pow(input int) {
fmt.Printf("2 ^ %d = %d \n", input, input^2)
}
func sum(a int, b int) {
fmt.Printf("%d + %d = %d \n", a, b, a+b)
}
// Output:
// 2 * 0 = 0
// 2 ^ 0 = 2
// 2 ^ 1 = 3
// 1 + 2 = 3
// 2 * 2 = 4
// 2 ^ 2 = 0
// 2 + 3 = 5
// 0 + 1 = 1
// 2 * 1 = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment