server

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package server provides support routines for running jrpc2 servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Local

func Local(assigner jrpc2.Assigner, opts *LocalOptions) (client *jrpc2.Client, wait func() error)

Local constructs a *jrpc2.Server and a *jrpc2.Client connected to it via an in-memory pipe, using the specified assigner and options. If opts == nil, it behaves as if the client and server options are also nil.

When the client is closed, the server is also stopped; the caller may invoke wait to wait for the server to complete.

func Loop

func Loop(lst net.Listener, assigner jrpc2.Assigner, opts *LoopOptions) error

Loop obtains connections from lst and starts a server for each with the given assigner and options, running in a new goroutine. If accept reports an error, the loop will terminate and the error will be reported once all the servers currently active have returned.

Types

type LocalOptions

type LocalOptions struct {
	ClientOptions *jrpc2.ClientOptions
	ServerOptions *jrpc2.ServerOptions
}

LocalOptions control the behaviour of the server and client constructed by the Local function.

type LoopOptions

type LoopOptions struct {
	// If non-nil, this function is used to convert a stream connection to an
	// RPC channel. If this field is nil, channel.JSON is used.
	Framing channel.Framing

	// If non-nil, these options are used when constructing the server to
	// handle requests on an inbound connection.
	ServerOptions *jrpc2.ServerOptions
}

LoopOptions control the behaviour of the Loop function. A nil *LoopOptions provides default values as described.

Jump to

Keyboard shortcuts

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