-
Notifications
You must be signed in to change notification settings - Fork 36
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
Fix connect #585
Fix connect #585
Conversation
186192d
to
a1bd7d4
Compare
a1bd7d4
to
dcc1e6d
Compare
One other potentially thought here... rather than having translation factories as arguments to connect ... we could have connect store its client connection in metadata and then appropriate subsequent chain elements could handle the translation without having to complicate the connect logic with translation. |
Yep, it can be very helpful to store some additional info about the server+client connections in s single place, but we need to perform translation logic before the client chain: connect.NewServer(
ctx,
client.NewClientFactory(
name,
// What to call onHeal
addressof.NetworkServiceClient(adapters.NewServerToClient(rv)),
tokenGenerator,
// <-- all these chain elements comes after the updatepath, refresh, updatetoken...
connectioncontextkernel.NewClient(),
tag.NewClient(ctx, vppConn),
// mechanisms
memif.NewClient(vppConn, &lastSocketID),
kernel.NewClient(vppConn),
recvfd.NewClient(),
),
clientDialOptions...,
), so if we want to perform some translation, we should do it before the |
There are actually 2 different approaches we can use to implement server request -> client request and client connection -> server connection translations. Use metadata and stored
|
rv = chain.NewNetworkServiceClient( | |
append( | |
append([]networkservice.NetworkServiceClient{ | |
authorize.NewClient(), | |
updatepath.NewClient(name), | |
heal.NewClient(ctx, networkservice.NewMonitorConnectionClient(cc), onHeal), | |
refresh.NewClient(ctx), | |
}, additionalFunctionality...), | |
injectpeer.NewClient(), | |
updatetoken.NewClient(tokenGenerator), | |
networkservice.NewNetworkServiceClient(cc), | |
)...) |
so it should be performed in server chain and so we need 2 translation elements:
- to translate server request before starting processing client chain
- to translate client connection after the client chain
Another one thing I really don't like is thatNewRequestServer
,connection.NewServer
andNewConnectionServer
are the part of the server chain but they are processing client request.
Use translationFactory
endpoint := chain.NewNetworkServiceServer(
...
connection.NewServer( // <-- uses only `request`
translation.NewClient, // <-- is inserted before the `clientChain`, replaces `request` with
// `clientRequest`, returns `serverConn` instead of `clientConn`
client.NewFactory(clientChain), // <-- already uses `clientRequest`, no need for translation
),
...
)
Here we have only 1 chain element incapsulating all translation logic and so it is only one who is processing both server and client request. No one in the server chain knows about the client request/connection, same for the client chain and the server request/connection.
34815d2
to
568fd7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other things look for me over desined.
But I tihnk this PR can be merged as bug fixing.
I would suggest to solve this with something like: Create two separte client factories:
- For nsmgr and so on.
- For forwarders.
Something like
nsmgr.NewClientFactory
forwarder.NewClientFactory
I like this approach very much :) |
24a6093
to
24c607c
Compare
24c607c
to
1f05c41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
583c8ab
to
fe5ced7
Compare
Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com>
fe5ced7
to
554baa8
Compare
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
554baa8
to
9691fe2
Compare
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bolodya1997 Could you also update vpp-forwarder and vppagent-forwarder?
…k@master networkservicemesh/sdk#585 networkservicemesh/sdk PR link: networkservicemesh/sdk#585 networkservicemesh/sdk commit message: commit d0ca5e402484ded32f2b85dd94d4f283360424f8 Author: Vladimir Popov <vladimir.popov@xored.com> Date: Tue Dec 1 15:12:47 2020 +0700 Fix connect (#585) * Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@master networkservicemesh/sdk#585 networkservicemesh/sdk PR link: networkservicemesh/sdk#585 networkservicemesh/sdk commit message: commit d0ca5e402484ded32f2b85dd94d4f283360424f8 Author: Vladimir Popov <vladimir.popov@xored.com> Date: Tue Dec 1 15:12:47 2020 +0700 Fix connect (#585) * Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@master networkservicemesh/sdk#585 networkservicemesh/sdk PR link: networkservicemesh/sdk#585 networkservicemesh/sdk commit message: commit d0ca5e402484ded32f2b85dd94d4f283360424f8 Author: Vladimir Popov <vladimir.popov@xored.com> Date: Tue Dec 1 15:12:47 2020 +0700 Fix connect (#585) * Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@master networkservicemesh/sdk#585 networkservicemesh/sdk PR link: networkservicemesh/sdk#585 networkservicemesh/sdk commit message: commit d0ca5e402484ded32f2b85dd94d4f283360424f8 Author: Vladimir Popov <vladimir.popov@xored.com> Date: Tue Dec 1 15:12:47 2020 +0700 Fix connect (#585) * Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@master networkservicemesh/sdk#585 networkservicemesh/sdk PR link: networkservicemesh/sdk#585 networkservicemesh/sdk commit message: commit d0ca5e402484ded32f2b85dd94d4f283360424f8 Author: Vladimir Popov <vladimir.popov@xored.com> Date: Tue Dec 1 15:12:47 2020 +0700 Fix connect (#585) * Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
@edwarnicke Let us know if you have something in mind related to this changes. |
…k@master networkservicemesh/sdk#585 networkservicemesh/sdk PR link: networkservicemesh/sdk#585 networkservicemesh/sdk commit message: commit d0ca5e402484ded32f2b85dd94d4f283360424f8 Author: Vladimir Popov <vladimir.popov@xored.com> Date: Tue Dec 1 15:12:47 2020 +0700 Fix connect (#585) * Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@master networkservicemesh/sdk#585 networkservicemesh/sdk PR link: networkservicemesh/sdk#585 networkservicemesh/sdk commit message: commit d0ca5e402484ded32f2b85dd94d4f283360424f8 Author: Vladimir Popov <vladimir.popov@xored.com> Date: Tue Dec 1 15:12:47 2020 +0700 Fix connect (#585) * Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@master networkservicemesh/sdk#585 networkservicemesh/sdk PR link: networkservicemesh/sdk#585 networkservicemesh/sdk commit message: commit d0ca5e402484ded32f2b85dd94d4f283360424f8 Author: Vladimir Popov <vladimir.popov@xored.com> Date: Tue Dec 1 15:12:47 2020 +0700 Fix connect (#585) * Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
* Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: Sergey Ershov <sergey.ershov@xored.com>
* Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: Sergey Ershov <sergey.ershov@xored.com>
* Added translateMechanism chain element Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com> * Rework connect.NewServer Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add RefcountMap.LoadUnsafe() Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Move translation client implementations to the related places Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Add new clients, rework connect Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rename translation to mechanismtranslation Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Make RefcountMap.Delete() return bool Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Co-authored-by: Tigran Manasyan <tigran.manasyan@xored.com> Signed-off-by: Sergey Ershov <sergey.ershov@xored.com>
Issue
Existing
connect.NewServer()
chain elements provides some request, connection translation which should be different for the different cases (ex: NSMgr, interpose NSE, pass through NSE) #552.Solution
AddtranslationClientFactory
to extract all translation logic from theconnect.NewServer()
, addtranslation
package with common translation clientstranslation.NewNSMgrClient()
..., andtranslation.Builder
to create custom ones.Add
NewCrossConnectClientFactory
for the cross connect (interpose NSE, pass through NSE) cases, rework connect.