grpc

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: BSD-3-Clause Imports: 16 Imported by: 76

Documentation

Overview

Package grpc is a generated protocol buffer package.

It is generated from these files:

fixtures_test.proto

It has these top-level messages:

FixtureRequest
FixtureReply

Package grpc provides functions to trace the google.golang.org/grpc package v1.2.

Example (Client)
package main

import (
	"log"

	grpctrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/google.golang.org/grpc"

	"google.golang.org/grpc"
)

func main() {
	// Create the client interceptor using the grpc trace package.
	si := grpctrace.StreamClientInterceptor(grpctrace.WithServiceName("my-grpc-client"))
	ui := grpctrace.UnaryClientInterceptor(grpctrace.WithServiceName("my-grpc-client"))

	// Dial in using the created interceptor...
	conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(),
		grpc.WithStreamInterceptor(si), grpc.WithUnaryInterceptor(ui))
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	// And continue using the connection as normal.
}
Output:

Example (Server)
package main

import (
	"log"
	"net"

	grpctrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/google.golang.org/grpc"

	"google.golang.org/grpc"
)

func main() {
	// Create a listener for the server.
	ln, err := net.Listen("tcp", ":50051")
	if err != nil {
		log.Fatal(err)
	}

	// Create the server interceptor using the grpc trace package.
	si := grpctrace.StreamServerInterceptor(grpctrace.WithServiceName("my-grpc-client"))
	ui := grpctrace.UnaryServerInterceptor(grpctrace.WithServiceName("my-grpc-client"))

	// Initialize the grpc server as normal, using the tracing interceptor.
	s := grpc.NewServer(grpc.StreamInterceptor(si), grpc.UnaryInterceptor(ui))

	// ... register your services

	// Start serving incoming connections.
	if err := s.Serve(ln); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFixtureServer

func RegisterFixtureServer(s *grpc1.Server, srv FixtureServer)

func StreamClientInterceptor added in v1.1.0

func StreamClientInterceptor(opts ...InterceptorOption) grpc.StreamClientInterceptor

StreamClientInterceptor returns a grpc.StreamClientInterceptor which will trace client streams using the given set of options.

func StreamServerInterceptor added in v1.1.0

func StreamServerInterceptor(opts ...InterceptorOption) grpc.StreamServerInterceptor

StreamServerInterceptor will trace streaming requests to the given gRPC server.

func UnaryClientInterceptor

func UnaryClientInterceptor(opts ...InterceptorOption) grpc.UnaryClientInterceptor

UnaryClientInterceptor returns a grpc.UnaryClientInterceptor which will trace requests using the given set of options.

func UnaryServerInterceptor

func UnaryServerInterceptor(opts ...InterceptorOption) grpc.UnaryServerInterceptor

UnaryServerInterceptor will trace requests to the given grpc server.

Types

type FixtureClient

type FixtureClient interface {
	Ping(ctx context.Context, in *FixtureRequest, opts ...grpc1.CallOption) (*FixtureReply, error)
	StreamPing(ctx context.Context, opts ...grpc1.CallOption) (Fixture_StreamPingClient, error)
}

func NewFixtureClient

func NewFixtureClient(cc *grpc1.ClientConn) FixtureClient

type FixtureReply

type FixtureReply struct {
	Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
}

The response message containing the greetings

func (*FixtureReply) Descriptor

func (*FixtureReply) Descriptor() ([]byte, []int)

func (*FixtureReply) GetMessage

func (m *FixtureReply) GetMessage() string

func (*FixtureReply) ProtoMessage

func (*FixtureReply) ProtoMessage()

func (*FixtureReply) Reset

func (m *FixtureReply) Reset()

func (*FixtureReply) String

func (m *FixtureReply) String() string

type FixtureRequest

type FixtureRequest struct {
	Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}

The request message containing the user's name.

func (*FixtureRequest) Descriptor

func (*FixtureRequest) Descriptor() ([]byte, []int)

func (*FixtureRequest) GetName

func (m *FixtureRequest) GetName() string

func (*FixtureRequest) ProtoMessage

func (*FixtureRequest) ProtoMessage()

func (*FixtureRequest) Reset

func (m *FixtureRequest) Reset()

func (*FixtureRequest) String

func (m *FixtureRequest) String() string

type FixtureServer

type FixtureServer interface {
	Ping(context.Context, *FixtureRequest) (*FixtureReply, error)
	StreamPing(Fixture_StreamPingServer) error
}

type Fixture_StreamPingClient added in v1.1.0

type Fixture_StreamPingClient interface {
	Send(*FixtureRequest) error
	Recv() (*FixtureReply, error)
	grpc1.ClientStream
}

type Fixture_StreamPingServer added in v1.1.0

type Fixture_StreamPingServer interface {
	Send(*FixtureReply) error
	Recv() (*FixtureRequest, error)
	grpc1.ServerStream
}

type InterceptorOption

type InterceptorOption func(*interceptorConfig)

InterceptorOption represents an option that can be passed to the grpc unary client and server interceptors.

func WithServiceName

func WithServiceName(name string) InterceptorOption

WithServiceName sets the given service name for the intercepted client.

func WithStreamCalls added in v1.1.0

func WithStreamCalls(enabled bool) InterceptorOption

WithStreamCalls enables or disables tracing of streaming calls.

func WithStreamMessages added in v1.1.0

func WithStreamMessages(enabled bool) InterceptorOption

WithStreamMessages enables or disables tracing of streaming messages.

Jump to

Keyboard shortcuts

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