Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-09-20 16:57:54 +03:00
parent aa667728a1
commit 1cbd1d2bad
17 changed files with 33 additions and 25 deletions

View File

@ -11,7 +11,7 @@ import (
"github.com/unistack-org/micro/v3/router" "github.com/unistack-org/micro/v3/router"
"github.com/unistack-org/micro/v3/selector" "github.com/unistack-org/micro/v3/selector"
"github.com/unistack-org/micro/v3/selector/random" "github.com/unistack-org/micro/v3/selector/random"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
type Options struct { type Options struct {

View File

@ -5,7 +5,7 @@ import (
"github.com/unistack-org/micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/proxy" "github.com/unistack-org/micro/v3/proxy"
"github.com/unistack-org/micro/v3/router" "github.com/unistack-org/micro/v3/router"
"github.com/unistack-org/micro/v3/tunnel" "github.com/unistack-org/micro/v3/network/tunnel"
) )
type Option func(*Options) type Option func(*Options)

View File

@ -7,8 +7,8 @@ import (
"github.com/unistack-org/micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
"github.com/unistack-org/micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
"github.com/unistack-org/micro/v3/tunnel" "github.com/unistack-org/micro/v3/network/tunnel"
) )
type tunBroker struct { type tunBroker struct {

View File

@ -5,7 +5,7 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/unistack-org/micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
var ( var (

View File

@ -1,8 +1,8 @@
package transport package transport
import ( import (
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
"github.com/unistack-org/micro/v3/tunnel" "github.com/unistack-org/micro/v3/network/tunnel"
) )
type tunListener struct { type tunListener struct {

View File

@ -5,8 +5,8 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
"github.com/unistack-org/micro/v3/tunnel" "github.com/unistack-org/micro/v3/network/tunnel"
) )
type tunTransport struct { type tunTransport struct {

View File

@ -5,7 +5,7 @@ import (
"errors" "errors"
"time" "time"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
var ( var (

View File

@ -19,7 +19,7 @@ import (
"github.com/unistack-org/micro/v3/server" "github.com/unistack-org/micro/v3/server"
"github.com/unistack-org/micro/v3/store" "github.com/unistack-org/micro/v3/store"
"github.com/unistack-org/micro/v3/tracer" "github.com/unistack-org/micro/v3/tracer"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
// Options for micro service // Options for micro service

View File

@ -10,8 +10,16 @@ type HandlerOptions struct {
Context context.Context Context context.Context
} }
func NewHandlerOptions() HandlerOptions { func NewHandlerOptions(opts ...HandlerOption) HandlerOptions {
return HandlerOptions{Context: context.Background()} options := HandlerOptions{
Context: context.Background(),
}
for _, o := range opts {
o(&options)
}
return options
} }
type SubscriberOption func(*SubscriberOptions) type SubscriberOption func(*SubscriberOptions)
@ -26,16 +34,16 @@ type SubscriberOptions struct {
} }
func NewSubscriberOptions(opts ...SubscriberOption) SubscriberOptions { func NewSubscriberOptions(opts ...SubscriberOption) SubscriberOptions {
opt := SubscriberOptions{ options := SubscriberOptions{
AutoAck: true, AutoAck: true,
Context: context.Background(), Context: context.Background(),
} }
for _, o := range opts { for _, o := range opts {
o(&opt) o(&options)
} }
return opt return options
} }
// EndpointMetadata is a Handler option that allows metadata to be added to // EndpointMetadata is a Handler option that allows metadata to be added to

View File

@ -12,7 +12,7 @@ import (
"github.com/unistack-org/micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/unistack-org/micro/v3/tracer" "github.com/unistack-org/micro/v3/tracer"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
type Options struct { type Options struct {

View File

@ -15,7 +15,7 @@ import (
rtreg "github.com/unistack-org/micro/v3/router/registry" rtreg "github.com/unistack-org/micro/v3/router/registry"
"github.com/unistack-org/micro/v3/server" "github.com/unistack-org/micro/v3/server"
grpcsrv "github.com/unistack-org/micro/v3/server/grpc" grpcsrv "github.com/unistack-org/micro/v3/server/grpc"
tmemory "github.com/unistack-org/micro/v3/transport/memory" tmemory "github.com/unistack-org/micro/v3/network/transport/memory"
cw "github.com/unistack-org/micro/v3/util/client" cw "github.com/unistack-org/micro/v3/util/client"
) )

View File

@ -4,7 +4,7 @@ package io
import ( import (
"io" "io"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
type rwc struct { type rwc struct {

View File

@ -5,7 +5,7 @@ import (
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
type pool struct { type pool struct {

View File

@ -6,8 +6,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
"github.com/unistack-org/micro/v3/transport/memory" "github.com/unistack-org/micro/v3/network/transport/memory"
) )
func testPool(t *testing.T, size int, ttl time.Duration) { func testPool(t *testing.T, size int, ttl time.Duration) {

View File

@ -3,7 +3,7 @@ package pool
import ( import (
"time" "time"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
type Options struct { type Options struct {

View File

@ -4,7 +4,7 @@ package pool
import ( import (
"time" "time"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
// Pool is an interface for connection pooling // Pool is an interface for connection pooling

View File

@ -4,7 +4,7 @@ package socket
import ( import (
"io" "io"
"github.com/unistack-org/micro/v3/transport" "github.com/unistack-org/micro/v3/network/transport"
) )
// Socket is our pseudo socket for transport.Socket // Socket is our pseudo socket for transport.Socket