$INPUT_BUFFERED_STICKY_DURATION
parent
4f48ee805f
commit
1fc6d71db6
|
|
@ -2,6 +2,7 @@ package input
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -18,14 +19,18 @@ type Buffered struct {
|
||||||
|
|
||||||
func NewBuffered(ctx context.Context, input Input) *Buffered {
|
func NewBuffered(ctx context.Context, input Input) *Buffered {
|
||||||
ctx, can := context.WithCancel(ctx)
|
ctx, can := context.WithCancel(ctx)
|
||||||
|
expirationInterval := time.Millisecond * 125
|
||||||
|
if d, err := time.ParseDuration(os.Getenv("INPUT_BUFFERED_STICKY_DURATION")); err == nil {
|
||||||
|
expirationInterval = d
|
||||||
|
}
|
||||||
result := &Buffered{
|
result := &Buffered{
|
||||||
input: input,
|
input: input,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
can: can,
|
can: can,
|
||||||
lock: sync.Mutex{},
|
lock: sync.Mutex{},
|
||||||
keys: map[byte]int64{},
|
keys: map[byte]int64{},
|
||||||
listenInterval: time.Millisecond * 20,
|
listenInterval: time.Millisecond * 10,
|
||||||
expirationInterval: time.Millisecond * 100,
|
expirationInterval: expirationInterval,
|
||||||
}
|
}
|
||||||
go result.listen()
|
go result.listen()
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue