proxy

package
v0.0.61 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package proxy implements a transparent JSON-RPC proxy that dispatches to a jrpc2.Client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

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

A Proxy is a JSON-RPC transparent proxy. It implements a jrpc2.Assigner that assigns each requested method to a handler that forwards the request to a server connected through a *jrpc2.Client.

func New

func New(c *jrpc2.Client) *Proxy

New creates a proxy that dispatches inbound requests to the given client. The resulting value satisfies the jrpc2.Assigner interface, allowing it to be used as the assigner for a jrpc2.Server.

For example:

cli := jrpc2.NewClient(ch, clientOpts)
...
s := jrpc2.NewServer(proxy.New(cli), &jrpc2.ServerOptions{
    DisableBuiltin: true,  // disable the proxy's rpc.* handlers
})

func (*Proxy) Assign

func (p *Proxy) Assign(_ string) jrpc2.Handler

Assign implements part of the jrpc2.Assigner interface. All methods are assigned to the proxy's internal handler, which forwards them across the client.

func (*Proxy) Close

func (p *Proxy) Close() error

Close closes the underlying client for p and reports its result.

func (Proxy) Names

func (Proxy) Names() []string

Names implements part of the jrpc2.Assigner interface. It always returns nil, since the resolution of method names is delegated to the remote server.

Jump to

Keyboard shortcuts

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