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

Rename prioritymechanisms to mechanismpriority #1391

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package prioritymechanisms prioritize mechanisms according to the list
package prioritymechanisms
// Package mechanismpriority prioritize mechanisms according to the list
package mechanismpriority

import (
"context"
Expand All @@ -30,13 +30,13 @@ import (
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
)

type priorityMechanismsClient struct {
type mechanismPriorityClient struct {
priorities map[string]int
}

// NewClient - returns a new client chain element that prioritize mechanisms according to the list
func NewClient(priorities ...string) networkservice.NetworkServiceClient {
c := &priorityMechanismsClient{
c := &mechanismPriorityClient{
priorities: map[string]int{},
}
for i, p := range priorities {
Expand All @@ -46,12 +46,12 @@ func NewClient(priorities ...string) networkservice.NetworkServiceClient {
return c
}

func (p *priorityMechanismsClient) Request(ctx context.Context, request *networkservice.NetworkServiceRequest, opts ...grpc.CallOption) (*networkservice.Connection, error) {
request.MechanismPreferences = prioritizeMechanismsByType(request.GetMechanismPreferences(), p.priorities)
func (m *mechanismPriorityClient) Request(ctx context.Context, request *networkservice.NetworkServiceRequest, opts ...grpc.CallOption) (*networkservice.Connection, error) {
request.MechanismPreferences = prioritizeMechanismsByType(request.GetMechanismPreferences(), m.priorities)
return next.Client(ctx).Request(ctx, request, opts...)
}

func (p *priorityMechanismsClient) Close(ctx context.Context, conn *networkservice.Connection, opts ...grpc.CallOption) (*empty.Empty, error) {
func (m *mechanismPriorityClient) Close(ctx context.Context, conn *networkservice.Connection, opts ...grpc.CallOption) (*empty.Empty, error) {
return next.Client(ctx).Close(ctx, conn, opts...)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package prioritymechanisms_test
package mechanismpriority_test

import (
"context"
Expand All @@ -30,10 +30,10 @@ import (
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/vxlan"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/wireguard"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/prioritymechanisms"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanismpriority"
)

func TestPriorityMechanismsClient_Request(t *testing.T) {
func TestMechanismPriorityClient_Request(t *testing.T) {
request := func() *networkservice.NetworkServiceRequest {
return &networkservice.NetworkServiceRequest{
MechanismPreferences: []*networkservice.Mechanism{
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestPriorityMechanismsClient_Request(t *testing.T) {
for _, s := range samples {
sample := s
t.Run(sample.Name, func(t *testing.T) {
c := prioritymechanisms.NewClient(sample.Priorities...)
c := mechanismpriority.NewClient(sample.Priorities...)
req := sample.Request
_, err := c.Request(context.Background(), req)
require.NoError(t, err)
Expand Down