diff --git a/transport/options.go b/network/transport/options.go similarity index 82% rename from transport/options.go rename to network/transport/options.go index 7cfe3a3c..377c4162 100644 --- a/transport/options.go +++ b/network/transport/options.go @@ -31,6 +31,19 @@ type Options struct { Context context.Context } +func NewOptions(opts ...Option) Options { + options := Options{ + Logger: logger.DefaultLogger, + Context: context.Background(), + } + + for _, o := range opts { + o(&options) + } + + return options +} + type DialOptions struct { // Tells the transport this is a streaming connection with // multiple calls to send/recv and that send may not even be called @@ -46,6 +59,18 @@ type DialOptions struct { Context context.Context } +func NewDialOptions(opts ...DialOption) DialOptions { + options := DialOptions{ + Context: context.Background(), + } + + for _, o := range opts { + o(&options) + } + + return options +} + type ListenOptions struct { // TODO: add tls options when listening // Currently set in global options @@ -55,6 +80,18 @@ type ListenOptions struct { Context context.Context } +func NewListenOptions(opts ...ListenOption) ListenOptions { + options := ListenOptions{ + Context: context.Background(), + } + + for _, o := range opts { + o(&options) + } + + return options +} + // Addrs to use for transport func Addrs(addrs ...string) Option { return func(o *Options) { diff --git a/transport/transport.go b/network/transport/transport.go similarity index 100% rename from transport/transport.go rename to network/transport/transport.go