move transport

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-09-20 16:52:26 +03:00
parent 9b11ea527a
commit aa667728a1
2 changed files with 37 additions and 0 deletions

View File

@ -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) {