-
Notifications
You must be signed in to change notification settings - Fork 320
/
options.go
31 lines (22 loc) · 1.01 KB
/
options.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
// Copyright (c) 2019 IoTeX Foundation
// This is an alpha (internal) release and is not suitable for production. This source code is provided 'as is' and no
// warranties are given as to title or non-infringement, merchantability or fitness for purpose and, to the extent
// permitted by law, all liability for your use of the code is disclaimed. This source code is governed by Apache
// License 2.0 that can be found in the LICENSE file.
package actpool
import (
"time"
"github.com/facebookgo/clock"
)
type clockOption struct{ c clock.Clock }
// WithClock returns an option to overwrite clock.
func WithClock(c clock.Clock) interface{ ActQueueOption } {
return &clockOption{c}
}
func (o *clockOption) SetActQueueOption(aq *actQueue) { aq.clock = o.c }
type ttlOption struct{ ttl time.Duration }
// WithTimeOut returns an option to overwrite time out setting.
func WithTimeOut(ttl time.Duration) interface{ ActQueueOption } {
return &ttlOption{ttl}
}
func (o *ttlOption) SetActQueueOption(aq *actQueue) { aq.ttl = o.ttl }