Created
April 2, 2020 10:10
-
-
Save thinhdanggroup/a748c87d345a6f8803785c3f27680636 to your computer and use it in GitHub Desktop.
Executor Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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