fix: protocol v1
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/client/logger"
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol"
|
||||
v1 "forge.cadoles.com/cadoles/go-emlid/reach/client/protocol/v1"
|
||||
v2 "forge.cadoles.com/cadoles/go-emlid/reach/client/protocol/v2"
|
||||
@ -10,6 +14,8 @@ type Options struct {
|
||||
Protocols *protocol.Registry
|
||||
PreferredProtocol protocol.Identifier
|
||||
FallbackProtocol protocol.Identifier
|
||||
AvailableTimeout time.Duration
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
type OptionFunc func(opts *Options)
|
||||
@ -19,6 +25,8 @@ func NewOptions(funcs ...OptionFunc) *Options {
|
||||
PreferredProtocol: v2.Identifier,
|
||||
FallbackProtocol: v1.Identifier,
|
||||
Protocols: protocol.DefaultRegistry(),
|
||||
AvailableTimeout: 5 * time.Second,
|
||||
Logger: slog.Default(),
|
||||
}
|
||||
|
||||
for _, fn := range funcs {
|
||||
@ -45,3 +53,15 @@ func WithProtocols(protocols *protocol.Registry) OptionFunc {
|
||||
opts.Protocols = protocols
|
||||
}
|
||||
}
|
||||
|
||||
func WithLogger(logger logger.Logger) OptionFunc {
|
||||
return func(opts *Options) {
|
||||
opts.Logger = logger
|
||||
}
|
||||
}
|
||||
|
||||
func WithAvailableTimeout(timeout time.Duration) OptionFunc {
|
||||
return func(opts *Options) {
|
||||
opts.AvailableTimeout = timeout
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user