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

Add the possible to make chain of chains via pkg/next #173

Merged
merged 5 commits into from
Apr 3, 2020

Conversation

denis-tingaikin
Copy link
Member

Signed-off-by: denis-tingajkin denis.tingajkin@xored.com

Motivation

#172

Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>
@denis-tingaikin denis-tingaikin changed the title Add the possible to make chain of chains for pkg/next Add the possible to make chain of chains via pkg/next Mar 31, 2020
@denis-tingaikin denis-tingaikin marked this pull request as ready for review March 31, 2020 06:34
Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>
@edwarnicke
Copy link
Member

I'm not following the problem we are trying to solve here... could you say more?

It's unclear to me why the existing code does not allow you to use one chain as an element in another.

@denis-tingaikin
Copy link
Member Author

denis-tingaikin commented Mar 31, 2020

@edwarnicke

could you say more?

Sure, we are trying to use chains inside chains. For example:

next.NewServer(next.NetServer(somepkg.NewServer()), somepkg.NewServer())

It's unclear to me why the existing code does not allow you to use one chain as an element in another.

The problem related to two things:

  1. tailServer, tailClient elements are not using next.Client()/next.Servers() (the chains brokes here)
  2. Inner chain elements rewrites value ofnextServer/nextClient

@edwarnicke
Copy link
Member

Oh... that is nicely subtle. Good catch.

Question thought... might it not be simpler and clearer to simply do something like replacing

https://github.com/networkservicemesh/sdk/blob/master/pkg/networkservice/core/next/server.go#L64

return n.servers[n.index].Request(withNextServer(ctx, nil), request)

with

return n.servers[n.index].Request(ctx, request)

That way any 'nextServer' coming from the parent would show up for the child?

Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>
Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>
@denis-tingaikin
Copy link
Member Author

@edwarnicke good idea. Thanks, fixed.

@@ -48,6 +48,9 @@ func withNextServer(parent context.Context, next networkservice.NetworkServiceSe
// Server -
// Returns the Server networkservice.NetworkServiceServer to be called in the chain from the context.Context
func Server(ctx context.Context) networkservice.NetworkServiceServer {
if ctx == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question... why return nil here instead of tailServer?

Copy link
Member Author

@denis-tingaikin denis-tingaikin Apr 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually it can be nil in two cases:

  1. At the first call of method request/close with ctx = nil. In this case, we looking for the next parent chain and value can be nil
  2. Call this method outside of the chain. I.e. user not used next.NewServer() and passed nil context. Not sure that we should return tailServer in this case

Copy link
Member Author

@denis-tingaikin denis-tingaikin Apr 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, I think it will be better just throw nil panic exception for the case №2.
Fixed by 1d5588c

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we panic if called outside of a chain?

Copy link
Member Author

@denis-tingaikin denis-tingaikin Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair :)

Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>
@edwarnicke edwarnicke merged commit fd5d675 into networkservicemesh:master Apr 3, 2020
nsmbot pushed a commit that referenced this pull request Apr 11, 2024
…i@main

PR link: networkservicemesh/api#173

Commit: f357d8c
Author: Nikita Skrynnik
Date: 2024-04-12 00:04:02 +0700
Message:
  - Remove some triggers from Update dependent repositories (#173)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
denis-tingaikin pushed a commit that referenced this pull request Apr 15, 2024
…i@main (#1611)

PR link: networkservicemesh/api#173

Commit: f357d8c
Author: Nikita Skrynnik
Date: 2024-04-12 00:04:02 +0700
Message:
  - Remove some triggers from Update dependent repositories (#173)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants