https://github.com/ryankurte/go-async-mgr
A quick and dirty wrapper for parallel asynchronous services in go
https://github.com/ryankurte/go-async-mgr
asynchronous golang manager parallel
Last synced: 2 months ago
JSON representation
A quick and dirty wrapper for parallel asynchronous services in go
- Host: GitHub
- URL: https://github.com/ryankurte/go-async-mgr
- Owner: ryankurte
- License: mit
- Created: 2017-03-04T09:22:00.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-15T22:02:03.000Z (almost 9 years ago)
- Last Synced: 2025-03-09T13:18:50.125Z (about 1 year ago)
- Topics: asynchronous, golang, manager, parallel
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-async-mgr
[](https://godoc.org/github.com/ryankurte/go-async-mgr)
[](https://github.com/ryankurte/go-async-mgr)
[](https://travis-ci.org/ryankurte/go-async-mgr)
A quick and dirty wrapper for managing communication between parallel asynchronous services.
## Usage
```go
import(
"gopkg.in/ryankurte/go-async-mgr.v1"
)
// Create a service manager
// This requires that you specify the global input channel size
sm := async.NewServiceManager(32)
// Create async service instances around RunnableInterfaces
// Again, this requires that you specify the per-service input channel size
s1 := async.NewAsyncService(&FakeWorker{id: 1}, 2)
s2 := async.NewAsyncService(&FakeWorker{id: 2}, 2)
// Bind the services into the manager
sm.BindService(&s1)
sm.BindService(&s2)
// Run the service manager
// This launches all worker threads automatically
sm.Run()
// Send some events to the service manager
// These will be distributed to all workers (in parallel)
sm.SendEvent("test")
...
// Shut down the service manager
// This will wait and exit all async services
sm.Exit()
```