runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package runtime contains the API used by code that is generated from Protocol Buffers files.

It is not intended to be called directly by users, but it can not be placed inside an internal package as it must be called by the generated code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call interface {
	// Send sends an input message to the call.
	//
	// u is an unmarshaler that produces the input message.
	// err is the error produced by the unmarshaler.
	//
	// more is true if the call can accept additional input messages.
	Send(u Unmarshaler) (more bool, err error)

	// Done is called to indicate that no more input messages will be sent.
	Done()

	// Recv returns the next output message produced by this call.
	//
	// more is true if the call can produce additional output messages.
	//
	// err is the error returned by the RPC method, if any.
	Recv() (out proto.Message, more bool, err error)
}

Call represents a single invocation of an RPC method.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements the common logic for generated clients.

func NewClient

func NewClient(
	baseURL *url.URL,
	opts ClientOptions,
) *Client

NewClient returns a new client with the given options.

func (*Client) CallUnary

func (c *Client) CallUnary(
	ctx context.Context,
	methodPath string,
	in, out proto.Message,
) error

CallUnary invokes a unary RPC method.

type ClientOptions

type ClientOptions struct {
	HTTPClient      *http.Client
	InputMediaType  string
	OutputMediaType string
}

ClientOptions contains options for a client.

type Method

type Method interface {
	// Name returns the name of the RPC method.
	Name() string

	// InputIsStream returns true if the method accepts a stream of input
	// messages, as opposed to a single input message.
	InputIsStream() bool

	// OutputIsStream returns true if the method produces a stream of output
	// messages, as opposed to a single output message.
	OutputIsStream() bool

	// NewCall starts a new call to the method.
	//
	// ctx is the context for the lifetime of the call, including any time taken
	// to stream input and output messages.
	NewCall(ctx context.Context, i middleware.ServerInterceptor) Call
}

Method encapsulates information about an RPC method.

type Registry

type Registry interface {
	RegisterService(Service)
}

Registry is a type that allows services to be registered.

type Service

type Service interface {
	// Name returns the unqualified service name.
	Name() string

	// Package returns the Protocol Buffers package name in which the service is
	// defined.
	Package() string

	// MethodByName returns the method with the given name.
	//
	// If no such method exists, ok is false.
	MethodByName(name string) (_ Method, ok bool)
}

Service is a generalized interface to a Protocol Buffers service.

The implementation is provided by the code generated from the service definition.

type Unmarshaler

type Unmarshaler func(m proto.Message) error

Unmarshaler is a function that unmarshals a protocol buffers message into m.

Jump to

Keyboard shortcuts

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