11package localstatequery
22
33import (
4+ "time"
5+
46 "github.com/cloudstruct/go-ouroboros-network/protocol"
57)
68
@@ -89,11 +91,13 @@ type LocalStateQuery struct {
8991}
9092
9193type Config struct {
92- AcquireFunc AcquireFunc
93- QueryFunc QueryFunc
94- ReleaseFunc ReleaseFunc
95- ReAcquireFunc ReAcquireFunc
96- DoneFunc DoneFunc
94+ AcquireFunc AcquireFunc
95+ QueryFunc QueryFunc
96+ ReleaseFunc ReleaseFunc
97+ ReAcquireFunc ReAcquireFunc
98+ DoneFunc DoneFunc
99+ AcquireTimeout time.Duration
100+ QueryTimeout time.Duration
97101}
98102
99103// Callback function types
@@ -115,7 +119,10 @@ func New(protoOptions protocol.ProtocolOptions, cfg *Config) *LocalStateQuery {
115119type LocalStateQueryOptionFunc func (* Config )
116120
117121func NewConfig (options ... LocalStateQueryOptionFunc ) Config {
118- c := Config {}
122+ c := Config {
123+ AcquireTimeout : 5 * time .Second ,
124+ QueryTimeout : 180 * time .Second ,
125+ }
119126 // Apply provided options functions
120127 for _ , option := range options {
121128 option (& c )
@@ -152,3 +159,15 @@ func WithDoneFunc(doneFunc DoneFunc) LocalStateQueryOptionFunc {
152159 c .DoneFunc = doneFunc
153160 }
154161}
162+
163+ func WithAcquireTimeout (timeout time.Duration ) LocalStateQueryOptionFunc {
164+ return func (c * Config ) {
165+ c .AcquireTimeout = timeout
166+ }
167+ }
168+
169+ func WithQueryTimeout (timeout time.Duration ) LocalStateQueryOptionFunc {
170+ return func (c * Config ) {
171+ c .QueryTimeout = timeout
172+ }
173+ }
0 commit comments