-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
583c09c
commit 8d210e9
Showing
11 changed files
with
94 additions
and
87 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package buzz_test | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/thenorthnate/buzz" | ||
) | ||
|
||
type logTask struct{} | ||
|
||
func (t *logTask) Do(ctx context.Context) error { | ||
log.Println("message here") | ||
return nil | ||
} | ||
|
||
func Example() { | ||
// This defines some middleware that logs before and after the task runs | ||
logger := func(ctx context.Context, chain *buzz.CallChain) error { | ||
// This happens before the task runs | ||
log.Println("Starting!") | ||
// This call runs the rest of the middleware and the task | ||
err := chain.Next(ctx) | ||
// This runs after the task has completed | ||
log.Printf("Finished with err=[%v]\n", err) | ||
return err | ||
} | ||
hive := buzz.New() | ||
worker := buzz.NewWorker(&logTask{}).Use(logger) | ||
hive.Submit(worker) | ||
// Some time later... during shutdown | ||
hive.StopAll() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
module github.com/thenorthnate/buzz | ||
|
||
go 1.22.0 | ||
|
||
require github.com/thenorthnate/evs v0.1.0 |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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