raw

package
v1.29.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package raw provides the raw encoding for YARPC.

To make outbound requests,

client := raw.New(clientConfig)
resBody, err := client.Call(ctx, "submit", []byte{1, 2, 3})

Use the Procedure function to build procedures to register against a Router.

func Submit(ctx context.Context, reqBody []byte) ([]byte, error) {
	// ...
}

dispatcher.Register(raw.Procedure("submit", Submit))

Similarly, use the OnewayProcedure function to build procedures to register against a Router.

func RunTask(ctx context.Context, reqBody []byte) error {
	// ...
}

dispatcher.Register(raw.OnewayProcedure("RunTask", RunTask))

Index

Constants

View Source
const Encoding transport.Encoding = "raw"

Encoding is the name of this encoding.

Variables

This section is empty.

Functions

func OnewayProcedure added in v0.4.0

func OnewayProcedure(name string, handler OnewayHandler) []transport.Procedure

OnewayProcedure builds a Procedure from the given raw handler

func Procedure

func Procedure(name string, handler UnaryHandler) []transport.Procedure

Procedure builds a Procedure from the given raw handler.

func Register deprecated

func Register(r transport.RouteTable, rs []transport.Procedure)

Register calls the RouteTable's Register method.

This function exists for backwards compatibility only. It will be removed in a future version.

Deprecated: Use the RouteTable's Register method directly.

Types

type Client

type Client interface {
	// Call performs a unary outbound Raw request.
	Call(ctx context.Context, procedure string, body []byte, opts ...yarpc.CallOption) ([]byte, error)

	// CallOneway performs a oneway outbound Raw request.
	CallOneway(ctx context.Context, procedure string, body []byte, opts ...yarpc.CallOption) (transport.Ack, error)
}

Client makes Raw requests to a single service.

func New

New builds a new Raw client.

type OnewayHandler added in v0.4.0

type OnewayHandler func(context.Context, []byte) error

OnewayHandler implements a single, onweway procedure

type UnaryHandler added in v0.4.0

type UnaryHandler func(context.Context, []byte) ([]byte, error)

UnaryHandler implements a single, unary procedure.

Jump to

Keyboard shortcuts

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