Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

thinhdanggroup/executor

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Executor

version contributors Build Status Coverage Status

Executor is a simple worker pool implemented for Golang.

Features:

  • Execute concurrent job by Goroutine
  • Rate limiter
  • Dynamic handler by reflect

More information at Blog.

Install

$ go get github.com/thinhdanggroup/executor

Usage

executor, err := executor.NewExecutor(executor.DefaultExecutorConfig())

if err != nil {
  logrus.Error(err)
}

// close resource before quit
defer executor.Close()

for i := 0; i < 10; i++ {
  executor.Publish(func(input int) {
    fmt.Printf("2 * %d = %d \n", input, 2*input)
  }, i)

  executor.Publish(func(input int) {
    fmt.Printf("2 ^ %d = %d \n", input, input^2)
  }, i)

  executor.Publish(func(a int, b int) {
    fmt.Printf("%d + %d = %d \n", a, b, a+b)
  }, i, i+1)
}

// 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

About

Executor is a simple worker pool implemented for Golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.