Skip to content

Commit 868cd96

Browse files
harissudrajatagungdwiprasetyo
authored andcommitted
Add method for handle multi topic in single method
1 parent 685f6bf commit 868cd96

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

codebase/factory/types/worker_type.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ type WorkerHandlerGroup struct {
2626
Handlers []WorkerHandler
2727
}
2828

29+
// AddMultiRoute method from WorkerHandlerGroup to handle multi topic in single method
30+
func (m *WorkerHandlerGroup) AddMultiRoute(patternRoutes []string, mainHandlerFunc WorkerHandlerFunc, opts ...WorkerHandlerOptionFunc) {
31+
for _, route := range patternRoutes {
32+
if len(route) == 0 {
33+
continue
34+
}
35+
m.Add(route, mainHandlerFunc, opts...)
36+
}
37+
}
38+
2939
// Add method from WorkerHandlerGroup, patternRoute can contains unique topic name, key, or task name
3040
func (m *WorkerHandlerGroup) Add(patternRoute string, mainHandlerFunc WorkerHandlerFunc, opts ...WorkerHandlerOptionFunc) {
3141
h := WorkerHandler{

0 commit comments

Comments
 (0)