2019-07-28 18:56:18 +01:00
|
|
|
package pool
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2023-04-11 22:20:37 +03:00
|
|
|
"go.unistack.org/micro/v4/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
|
|
|
|
}
|
|
|
|
}
|