Skip to content

Commit

Permalink
Rename prioritymechanisms to mechanismpriority
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art committed Dec 7, 2022
1 parent b6979bf commit e1a8ea0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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

0 comments on commit e1a8ea0

Please sign in to comment.