package json
import "github.com/uber/tchannel-go/json"
Index ¶
- func CallPeer(ctx Context, peer *tchannel.Peer, serviceName, method string, arg, resp interface{}) error
- func CallSC(ctx Context, sc *tchannel.SubChannel, method string, arg, resp interface{}) error
- func Register(registrar tchannel.Registrar, funcs Handlers, onError func(context.Context, error)) error
- type Client
- func NewClient(ch *tchannel.Channel, targetService string, opts *ClientOptions) *Client
- func (c *Client) Call(ctx Context, method string, arg, resp interface{}) error
- type ClientOptions
- type Context
- func NewContext(timeout time.Duration) (Context, context.CancelFunc)
- func WithHeaders(ctx context.Context, headers map[string]string) Context
- func Wrap(ctx context.Context) Context
- type ErrApplication
- type Handlers
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 ¶
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 ¶
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 ¶
WithHeaders returns a Context that can be used to make a call with request headers.
func Wrap ¶
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.
Source Files ¶
- Version
- v1.34.6 (latest)
- Published
- Jan 8, 2025
- Platform
- darwin/amd64
- Imports
- 6 packages
- Last checked
- 16 hours ago –
Tools for package owners.