Reorganized directories and packages.
This commit is contained in:
parent
965fb540c7
commit
dceb232cb2
61 changed files with 83 additions and 83 deletions
45
cmd/worker/main.go
Normal file
45
cmd/worker/main.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/mikestefanello/pagoda/config"
|
||||
"github.com/mikestefanello/pagoda/pkg/tasks"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Load the configuration
|
||||
cfg, err := config.GetConfig()
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to load config: %v", err))
|
||||
}
|
||||
|
||||
// Build the worker server
|
||||
srv := asynq.NewServer(
|
||||
asynq.RedisClientOpt{
|
||||
Addr: fmt.Sprintf("%s:%d", cfg.Cache.Hostname, cfg.Cache.Port),
|
||||
DB: cfg.Cache.Database,
|
||||
Password: cfg.Cache.Password,
|
||||
},
|
||||
asynq.Config{
|
||||
// See asynq.Config for all available options and explanation
|
||||
Concurrency: 10,
|
||||
Queues: map[string]int{
|
||||
"critical": 6,
|
||||
"default": 3,
|
||||
"low": 1,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
// Map task types to the handlers
|
||||
mux := asynq.NewServeMux()
|
||||
mux.Handle(tasks.TypeExample, new(tasks.ExampleProcessor))
|
||||
|
||||
// Start the worker server
|
||||
if err := srv.Run(mux); err != nil {
|
||||
log.Fatalf("could not run worker server: %v", err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue