connect

package
v1.3.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Overview

Package connect provides chain elements to 'connect' clients

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient added in v1.1.0

NewClient - returns a connect chain element

func NewServer

NewServer - returns a connect chain element

Example

ExampleForwarder - example of how to use the connect chain element in a forwarder

package main

import (
	"context"

	"github.com/networkservicemesh/api/pkg/api/networkservice"
	"google.golang.org/grpc"

	"github.com/networkservicemesh/sdk/pkg/networkservice/chains/client"
	"github.com/networkservicemesh/sdk/pkg/networkservice/chains/endpoint"
	"github.com/networkservicemesh/sdk/pkg/networkservice/common/connect"
	"github.com/networkservicemesh/sdk/pkg/tools/token"
)

func main() {
	var dialOptions []grpc.DialOption
	var callOptions []grpc.CallOption
	var additonalClientFunctionality []networkservice.NetworkServiceClient
	var beforeConnectServer1, beforeConnectServer2 networkservice.NetworkServiceServer
	var afterConnectServer1, afterConnectServer2 networkservice.NetworkServiceServer
	var chainCtx context.Context
	var tokenGenerator token.GeneratorFunc
	var name string
	forwarder := endpoint.NewServer(
		chainCtx,
		tokenGenerator,
		endpoint.WithName(name),
		endpoint.WithAdditionalFunctionality(
			beforeConnectServer1,
			beforeConnectServer2,
			connect.NewServer(
				client.NewClient(
					chainCtx,
					client.WithAdditionalFunctionality(additonalClientFunctionality...),
					client.WithDialOptions(dialOptions...),
					client.WithoutRefresh(),
					client.WithName(name),
				),
				callOptions...,
			),
			afterConnectServer1,
			afterConnectServer2,
		),
	)
	if forwarder != nil {
	}
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL