json

package
v1.35.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 6 Imported by: 30 modules, 83 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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