-
Notifications
You must be signed in to change notification settings - Fork 1
/
provide.go
33 lines (28 loc) · 958 Bytes
/
provide.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Copyright (c) 2021-present unTill Pro, Ltd.
*/
package ibusmem
import (
"context"
"time"
ibus "github.com/untillpro/airs-ibus"
)
// requestCtx is already contained by sender but exposed also as a separate param because it is more useful in request handlers
func Provide(requestHandler func(requestCtx context.Context, sender interface{}, request ibus.Request)) ibus.IBus {
return provide(requestHandler, time.After, time.After, time.After)
}
func provide(requestHandler func(requestCtx context.Context, sender interface{}, request ibus.Request),
timerResponse func(time.Duration) <-chan time.Time,
timerSection func(time.Duration) <-chan time.Time,
timerElement func(time.Duration) <-chan time.Time,
) ibus.IBus {
if requestHandler == nil {
panic("request handler must be not nil")
}
return &bus{
requestHandler: requestHandler,
timerResponse: timerResponse,
timerSection: timerSection,
timerElement: timerElement,
}
}