import github.com/raidancampbell/go-workpoolgo-workpool provides a pool-of-work pattern, to synchronize events before passing them to an asynchronous/parallel processing pipeline.
For example, if you have 3 events:
- an account creation for account
a - an account update for account
a - an account update for account
b
Events 1 and 3 can be processed simultaneously, while event 2 must wait until event 1 is complete.
A workpool is instantiated via workpool.New(). The workpool expects submitted work to implement the Work interface. This interface has a Key() function to return a string ("a" or "b" in the above example), and has a Do() function to perform whatever work is required. The workpool_test.go file contains some simple examples.