Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/DanLavine/GoAsync
Go Async is designed to simplify managing multi-process applications into easily understandable single purpose units of work.
The Task Manager
is responsible for running and managing any number of assigned tasks
.
For the Task Manager to operate, each task must follow 1 of two patterns.
Is expected to run for the entire process's execution.
Task interface:
// A Task is anything that can be managed by the TaskManager and added before the taskmanager
// start running. Any errors will cause the process to exit as all tasks are expected to run without erros
type Task interface {
// Initializate functions are ran serially in the order they were added to the TaskManager.
// These are useful when one Goroutine dependency requires a previous Worker to setup some common
// dendency like a DB connection.
Initialize() error
// Execute is the main Async function to house all the multi-threaded logic handled by GoAsync.
Execute(ctx context.Context) error
// Clenup functions are ran serially in reverse order they were added to the TaskManager.
// This way the 1st Initialze dependency is stopped last
Cleanup() error
}
Can be added to a process that is already running
Exeute Task interface:
// A ExecuteTask can be added to a Task Manager before or after it has already started managin the tasks.
// These tasks are expected to already be properly Initialized and don't require any Cleanup Code.
type ExecuteTask interface {
// Execute is the main Async function to house all the multi-threaded logic handled by GoAsync.
Execute(ctx context.Context) error
}
For a number of common basic tasks provided, see tasks directory
go get -u github.com/DanLavine/goasync
For a few simple and basic real world example check out the internal/examples
dir
To run all tests:
go test --race ./...
If we want to run one specific test we can use:
go test --race -run [NAME OF TEST] ./...
To ignore the test cache:
go test --race -count=1 ./...
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.