Skip to content

Commit

Permalink
Add method for handle multi topic in single method
Browse files Browse the repository at this point in the history
  • Loading branch information
harissudrajat authored and agungdwiprasetyo committed Nov 13, 2024
1 parent 685f6bf commit 868cd96
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions codebase/factory/types/worker_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ type WorkerHandlerGroup struct {
Handlers []WorkerHandler
}

// AddMultiRoute method from WorkerHandlerGroup to handle multi topic in single method
func (m *WorkerHandlerGroup) AddMultiRoute(patternRoutes []string, mainHandlerFunc WorkerHandlerFunc, opts ...WorkerHandlerOptionFunc) {
for _, route := range patternRoutes {
if len(route) == 0 {
continue
}
m.Add(route, mainHandlerFunc, opts...)
}
}

// Add method from WorkerHandlerGroup, patternRoute can contains unique topic name, key, or task name
func (m *WorkerHandlerGroup) Add(patternRoute string, mainHandlerFunc WorkerHandlerFunc, opts ...WorkerHandlerOptionFunc) {
h := WorkerHandler{
Expand Down

0 comments on commit 868cd96

Please sign in to comment.