networkservicemesh / sdk

Apache License 2.0
34 stars 36 forks source link

Add chain element for selecting next element based on requested network service #997

Open d-uzlov opened 3 years ago

d-uzlov commented 3 years ago

Overview

Sometimes we need have an endpoint that implements several services, and we want part of its chain to behave differently depending on the name of network service in the request. It would be very convenient to have a set of elements that each only work for one network service and choose one of them automatically.

Example usage:

choosebynetsvc.NewServer(
    map[string]networkservice.NetworkServiceServer{
        "service-1": point2pointipam.NewServer(ipnet1),
        "service-2": point2pointipam.NewServer(ipnet2),
        "service-3": point2pointipam.NewServer(ipnet3),
    }
)
denis-tingaikin commented 3 years ago

I like the idea of adding a chain element for multiservice endpoints.

I would be suggesting to change choosebynetsvc to selectservice or services by analogy with https://github.com/networkservicemesh/sdk/blob/main/pkg/networkservice/common/mechanisms/server.go#L21

d-uzlov commented 3 years ago

I like selectservice, I think it would be easier to read.