Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add healing feature #1113

Merged
merged 9 commits into from
Nov 11, 2021
5 changes: 5 additions & 0 deletions pkg/networkservice/chains/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/google/uuid"
"github.com/networkservicemesh/api/pkg/api/networkservice"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/trimpath"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/begin"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/clientconn"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/clienturl"
Expand All @@ -43,6 +45,7 @@ func NewClient(ctx context.Context, clientOpts ...Option) networkservice.Network
var opts = &clientOptions{
name: "client-" + uuid.New().String(),
authorizeClient: null.NewClient(),
healClient: null.NewClient(),
refreshClient: refresh.NewClient(ctx),
}
for _, opt := range clientOpts {
Expand All @@ -59,6 +62,7 @@ func NewClient(ctx context.Context, clientOpts ...Option) networkservice.Network
opts.refreshClient,
clienturl.NewClient(opts.clientURL),
clientconn.NewClient(opts.cc),
opts.healClient,
dial.NewClient(ctx,
dial.WithDialOptions(opts.dialOptions...),
dial.WithDialTimeout(opts.dialTimeout),
Expand All @@ -67,6 +71,7 @@ func NewClient(ctx context.Context, clientOpts ...Option) networkservice.Network
append(
opts.additionalFunctionality,
opts.authorizeClient,
trimpath.NewClient(),
connect.NewClient(),
)...,
)...,
Expand Down
11 changes: 11 additions & 0 deletions pkg/networkservice/chains/client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type clientOptions struct {
additionalFunctionality []networkservice.NetworkServiceClient
authorizeClient networkservice.NetworkServiceClient
refreshClient networkservice.NetworkServiceClient
healClient networkservice.NetworkServiceClient
dialOptions []grpc.DialOption
dialTimeout time.Duration
}
Expand Down Expand Up @@ -78,6 +79,16 @@ func WithAuthorizeClient(authorizeClient networkservice.NetworkServiceClient) Op
})
}

// WithHealClient sets healClient for the client chain.
func WithHealClient(healClient networkservice.NetworkServiceClient) Option {
if healClient == nil {
panic("healClient cannot be nil")
}
return Option(func(c *clientOptions) {
c.healClient = healClient
})
}

// WithDialOptions sets dial options
func WithDialOptions(dialOptions ...grpc.DialOption) Option {
return Option(func(c *clientOptions) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/networkservice/chains/endpoint/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (

"google.golang.org/grpc"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/trimpath"

"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/begin"
Expand Down Expand Up @@ -112,7 +114,9 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options
metadata.NewServer(),
timeout.NewServer(ctx),
monitor.NewServer(ctx, &rv.MonitorConnectionServer),
trimpath.NewServer(),
}, opts.additionalFunctionality...)...)

return rv
}

Expand Down
Loading