Skip to content

Commit

Permalink
Manually update to the latest sdk version (#154)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov authored Jun 9, 2021
1 parent 451e85a commit a778757
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 40 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/edwarnicke/vpphelper v0.0.0-20210225052320-b4f1f1aff45d
github.com/google/uuid v1.1.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v0.0.0-20210607090113-57f36f2c295b
github.com/networkservicemesh/sdk v0.0.0-20210608053425-06aafeb2606f
github.com/networkservicemesh/api v0.0.0-20210609080649-aa4a0cc6c9ea
github.com/networkservicemesh/sdk v0.0.0-20210609081227-4199f461084e
github.com/networkservicemesh/sdk-vpp v0.0.0-20210608053942-fa13426047ac
github.com/onsi/gomega v1.10.1 // indirect
github.com/sirupsen/logrus v1.7.0
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nats-io/stan.go v0.6.0/go.mod h1:eIcD5bi3pqbHT/xIIvXMwvzXYElgouBvaVRftaE+eac=
github.com/networkservicemesh/api v0.0.0-20210607090113-57f36f2c295b h1:+7wAqJikkh4iOTK67BwyXLvIjxcNg5oefdLN/VV8Rsk=
github.com/networkservicemesh/api v0.0.0-20210607090113-57f36f2c295b/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU=
github.com/networkservicemesh/sdk v0.0.0-20210608053425-06aafeb2606f h1:n+9BqBg4ee9N0Qc2gYk8mJFmwUmeKabPjrr3VzvxZjs=
github.com/networkservicemesh/api v0.0.0-20210609080649-aa4a0cc6c9ea h1:Oz3k/v09FYoXiK7riuotF/vKDxCQBPc+GnwlGmppGds=
github.com/networkservicemesh/api v0.0.0-20210609080649-aa4a0cc6c9ea/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU=
github.com/networkservicemesh/sdk v0.0.0-20210608053425-06aafeb2606f/go.mod h1:i8dwCdHWGOzIIANoUDER7ujrLRuNUGwpX1OGJC3OHqw=
github.com/networkservicemesh/sdk v0.0.0-20210609081227-4199f461084e h1:snqZQXckNMIsVPSL4V7GD2TFi6W2hpheigWc1UH5VJ0=
github.com/networkservicemesh/sdk v0.0.0-20210609081227-4199f461084e/go.mod h1:6URyucmK3kQQ45Eg7fo57zDtrwIceNx3wBA3OuqN4S8=
github.com/networkservicemesh/sdk-vpp v0.0.0-20210608053942-fa13426047ac h1:XZzTYRUtFAjyQe9AJyn4SJDXh9v8tYZg/juJzf3bOPY=
github.com/networkservicemesh/sdk-vpp v0.0.0-20210608053942-fa13426047ac/go.mod h1:70H1pfYSr4Wl6/lQ0h+BUnzCobjCGOgVWloeYfE/P9s=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
Expand Down
2 changes: 2 additions & 0 deletions internal/imports/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package imports is used for generating list of imports to optimize use of docker build cache
package imports

//go:generate bash -c "rm -rf imports*.go"
//go:generate bash -c "cd $(mktemp -d) && GO111MODULE=on go get github.com/edwarnicke/imports-gen@v1.1.1"
//go:generate bash -c "GOOS=linux ${GOPATH}/bin/imports-gen"
1 change: 0 additions & 1 deletion internal/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
_ "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd"
_ "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd"
_ "github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
_ "github.com/networkservicemesh/sdk/pkg/tools/grpcutils"
_ "github.com/networkservicemesh/sdk/pkg/tools/log"
_ "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger"
_ "github.com/networkservicemesh/sdk/pkg/tools/nsurl"
Expand Down
56 changes: 21 additions & 35 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import (
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd"
"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
"github.com/networkservicemesh/sdk/pkg/tools/grpcutils"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger"
"github.com/networkservicemesh/sdk/pkg/tools/nsurl"
Expand Down Expand Up @@ -88,14 +87,13 @@ func main() {
}
starttime := time.Now()
// enumerating phases
log.FromContext(ctx).Infof("there are 6 phases which will be executed followed by a success message:")
log.FromContext(ctx).Infof("there are 5 phases which will be executed followed by a success message:")
log.FromContext(ctx).Infof("the phases include:")
log.FromContext(ctx).Infof("1: get config from environment")
log.FromContext(ctx).Infof("2: run vpp and get a connection to it")
log.FromContext(ctx).Infof("3: retrieve spiffe svid")
log.FromContext(ctx).Infof("4: create grpc connection")
log.FromContext(ctx).Infof("5: create network service client")
log.FromContext(ctx).Infof("6: connect to all passed services")
log.FromContext(ctx).Infof("4: create network service client")
log.FromContext(ctx).Infof("5: connect to all passed services")
log.FromContext(ctx).Infof("a final success message with start time duration")
// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 1: get config from environment (time since start: %s)", time.Since(starttime))
Expand Down Expand Up @@ -133,42 +131,28 @@ func main() {
log.FromContext(ctx).WithField("duration", time.Since(now)).Info("completed phase 3: retrieving svid")

// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 4: create grpc connection (time since start: %s)", time.Since(starttime))
log.FromContext(ctx).Infof("executing phase 4: create network service client (time since start: %s)", time.Since(starttime))
// ********************************************************************************

dialCtx, cancel := context.WithTimeout(ctx, config.DialTimeout)
defer cancel()

clientCC, err := grpc.DialContext(
dialCtx,
grpcutils.URLToTarget(&config.ConnectTo),
append(opentracing.WithTracingDial(),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime))),
),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(
tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny()),
),
dialOptions := append(opentracing.WithTracingDial(),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime))),
),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(
tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny()),
),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)...,
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)
if err != nil {
logrus.Fatalf("error getting clientCC: %+v", err)
}

// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 5: create network service client (time since start: %s)", time.Since(starttime))
// ********************************************************************************

c := client.NewClient(
ctx,
clientCC,
&config.ConnectTo,
client.WithName(config.Name),
client.WithAdditionalFunctionality(
metadata.NewClient(),
Expand All @@ -178,10 +162,12 @@ func main() {
sendfd.NewClient(),
recvfd.NewClient(),
),
client.WithDialTimeout(config.DialTimeout),
client.WithDialOptions(dialOptions...),
)

// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 6: connect to all passed services (time since start: %s)", time.Since(starttime))
log.FromContext(ctx).Infof("executing phase 5: connect to all passed services (time since start: %s)", time.Since(starttime))
// ********************************************************************************

for i := 0; i < len(config.NetworkServices); i++ {
Expand All @@ -203,7 +189,7 @@ func main() {

resp, err := c.Request(requestCtx, request)
if err != nil {
log.FromContext(ctx).Fatalf("requset has failed: %v", err.Error())
log.FromContext(ctx).Fatalf("request has failed: %v", err.Error())
}

defer func() {
Expand Down

0 comments on commit a778757

Please sign in to comment.