2019-07-28 18:56:18 +01:00
|
|
|
package pool
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2020-09-20 16:57:54 +03:00
|
|
|
"github.com/unistack-org/micro/v3/network/transport"
|
2019-07-28 18:56:18 +01:00
|
|
|
)
|
|
|
|
|
2021-02-14 16:16:01 +03:00
|
|
|
// Options struct
|
2019-07-28 18:56:18 +01:00
|
|
|
type Options struct {
|
|
|
|
Transport transport.Transport
|
|
|
|
TTL time.Duration
|
|
|
|
Size int
|
|
|
|
}
|
|
|
|
|
2021-02-14 16:16:01 +03:00
|
|
|
// Option func signature
|
2019-07-28 18:56:18 +01:00
|
|
|
type Option func(*Options)
|
|
|
|
|
2021-02-14 16:16:01 +03:00
|
|
|
// Size sets the size
|
2019-07-28 18:56:18 +01:00
|
|
|
func Size(i int) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Size = i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-14 16:16:01 +03:00
|
|
|
// Transport sets the transport
|
2019-07-28 18:56:18 +01:00
|
|
|
func Transport(t transport.Transport) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Transport = t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-14 16:16:01 +03:00
|
|
|
// TTL specifies ttl
|
2019-07-28 18:56:18 +01:00
|
|
|
func TTL(t time.Duration) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.TTL = t
|
|
|
|
}
|
|
|
|
}
|