json

package
v1.34.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 6 Imported by: 74

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallPeer

func CallPeer(ctx Context, peer *tchannel.Peer, serviceName, method string, arg, resp interface{}) error

CallPeer makes a JSON call using the given peer.

func CallSC

func CallSC(ctx Context, sc *tchannel.SubChannel, method string, arg, resp interface{}) error

CallSC makes a JSON call using the given subchannel.

func Register

func Register(registrar tchannel.Registrar, funcs Handlers, onError func(context.Context, error)) error

Register registers the specified methods specified as a map from method name to the JSON handler function. The handler functions should have the following signature: func(context.Context, *ArgType)(*ResType, error)

Types

type Client

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

Client is used to make JSON calls to other services.

func NewClient

func NewClient(ch *tchannel.Channel, targetService string, opts *ClientOptions) *Client

NewClient returns a json.Client used to make outbound JSON calls.

func (*Client) Call

func (c *Client) Call(ctx Context, method string, arg, resp interface{}) error

Call makes a JSON call, with retries.

type ClientOptions

type ClientOptions struct {
	HostPort string
}

ClientOptions are options used when creating a client.

type Context

type Context tchannel.ContextWithHeaders

Context is a JSON Context which contains request and response headers.

func NewContext

func NewContext(timeout time.Duration) (Context, context.CancelFunc)

NewContext returns a Context that can be used to make JSON calls.

func WithHeaders

func WithHeaders(ctx context.Context, headers map[string]string) Context

WithHeaders returns a Context that can be used to make a call with request headers.

func Wrap

func Wrap(ctx context.Context) Context

Wrap returns a JSON Context that wraps around a Context.

type ErrApplication

type ErrApplication map[string]interface{}

ErrApplication is an application error which contains the object returned from the other side.

func (ErrApplication) Error

func (e ErrApplication) Error() string

type Handlers

type Handlers map[string]interface{}

Handlers is the map from method names to handlers.

Jump to

Keyboard shortcuts

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