Skip to content

Commit

Permalink
Add default NSE registry client
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov committed Feb 1, 2021
1 parent 75b0296 commit 35e4fb2
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 5 deletions.
46 changes: 46 additions & 0 deletions pkg/registry/chains/client/nse_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2021 Doc.ai and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package client provides default registry clients
package client

import (
"context"

"github.com/networkservicemesh/api/pkg/api/registry"
"google.golang.org/grpc"

"github.com/networkservicemesh/sdk/pkg/registry/common/refresh"
"github.com/networkservicemesh/sdk/pkg/registry/common/sendfd"
"github.com/networkservicemesh/sdk/pkg/registry/core/chain"
)

// NewNetworkServiceEndpointClient creates a new default NSE registry client chain
func NewNetworkServiceEndpointClient(
ctx context.Context,
cc grpc.ClientConnInterface,
additionalFunctionality ...registry.NetworkServiceEndpointRegistryClient,
) registry.NetworkServiceEndpointRegistryClient {
return chain.NewNetworkServiceEndpointRegistryClient(
append(
append([]registry.NetworkServiceEndpointRegistryClient{
refresh.NewNetworkServiceEndpointRegistryClient(
refresh.WithChainContext(ctx)),
sendfd.NewNetworkServiceEndpointRegistryClient(),
}, additionalFunctionality...),
registry.NewNetworkServiceEndpointRegistryClient(cc),
)...)
}
9 changes: 4 additions & 5 deletions pkg/registry/common/sendfd/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 Cisco and/or its affiliates.
// Copyright (c) 2020-2021 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -14,10 +14,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !windows
// +build linux

// Package sendfd provides a registry.NetworkServiceEndpointRegistryClient chain element to convert any unix file socket
// endpoint.URLs into 'inode://${dev}/${ino}' urls and send the fd over the unix file socket.
package sendfd

import (
Expand All @@ -35,7 +33,8 @@ import (

type sendFDNSEClient struct{}

// NewNetworkServiceEndpointRegistryClient - creates a Client that if endpoint.Url is of scheme "unix" will replace it with an "inode" scheme url and send the FD over the unix socket
// NewNetworkServiceEndpointRegistryClient - creates a Client that if endpoint.Url is of scheme "unix" will replace it
// with an "inode" scheme url and send the FD over the unix socket
func NewNetworkServiceEndpointRegistryClient() registry.NetworkServiceEndpointRegistryClient {
return &sendFDNSEClient{}
}
Expand Down
31 changes: 31 additions & 0 deletions pkg/registry/common/sendfd/client_notlinux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2020-2021 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !linux

package sendfd

import (
"github.com/networkservicemesh/api/pkg/api/registry"

"github.com/networkservicemesh/sdk/pkg/registry/common/null"
)

// NewNetworkServiceEndpointRegistryClient - creates a Client that if endpoint.Url is of scheme "unix" will replace it
// with an "inode" scheme url and send the FD over the unix socket
func NewNetworkServiceEndpointRegistryClient() registry.NetworkServiceEndpointRegistryClient {
return null.NewNetworkServiceEndpointRegistryClient()
}
19 changes: 19 additions & 0 deletions pkg/registry/common/sendfd/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2020-2021 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package sendfd provides a registry.NetworkServiceEndpointRegistryClient chain element to convert any unix file socket
// endpoint.URLs into 'inode://${dev}/${ino}' urls and send the fd over the unix file socket.
package sendfd

0 comments on commit 35e4fb2

Please sign in to comment.