rpcserver

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 25 Imported by: 2

Documentation

Overview

Package rpcserver contains implementations for net rpc server.

Package rpcserver contains implementations for net rpc server.

Package rpcserver contains implementations for net rpc server.

Package rpcserver contains implementations for net rpc server.

Package rpcserver contains implementations for net rpc server.

Package rpcserver contains implementations for net rpc server.

Package rpcserver contains implementations for net rpc server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error interface {
	Error() string  // returns the message
	ErrorCode() int // returns the code
}

Error contain an error code in addition to the message.

type ID

type ID string

ID defines a pseudo random number that is used to identify RPC subscriptions.

func NewID

func NewID() ID

NewID generates a identifier that can be used as an identifier in the RPC interface. e.g. filter and subscription identifier.

type Notifier

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

Notifier is tight to a RPC connection that supports subscriptions. Server callbacks use the notifier to send notifications.

func NotifierFromContext

func NotifierFromContext(ctx context.Context) (*Notifier, bool)

NotifierFromContext returns the Notifier value stored in ctx, if any.

func (*Notifier) Closed

func (n *Notifier) Closed() <-chan interface{}

Closed returns a channel that is closed when the RPC connection is closed.

func (*Notifier) CreateSubscription

func (n *Notifier) CreateSubscription() *Subscription

CreateSubscription returns a new subscription that is coupled to the RPC connection. By default subscriptions are inactive and notifications are dropped until the subscription is marked as active. This is done by the RPC server after the subscription ID is send to the client.

func (*Notifier) Notify

func (n *Notifier) Notify(id ID, data interface{}) error

Notify sends a notification to the client with the given data as payload. If an error occurs the RPC connection is closed and the error is returned.

type RpcApi

type RpcApi struct {
	Namespace string      // namespace under which the rpc methods of Service are exposed
	Version   string      // api version
	Service   interface{} // receiver instance which holds the methods
}

RpcApi describes the set of methods offered over the RPC interface

type Server

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

Server represents a RPC server

func NewServer

func NewServer(cors []string, addr string) *Server

NewServer create http server for rpc & websocket requests

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe()

ListenAndServe starts the request handler loop

func (*Server) RegisterApis

func (srv *Server) RegisterApis(apis []RpcApi)

RegisterApis register api for server

func (*Server) Shutdown

func (srv *Server) Shutdown()

type Subscription

type Subscription struct {
	ID ID
	// contains filtered or unexported fields
}

a Subscription is created by a notifier and tight to that notifier. The client can use this subscription to wait for an unsubscribe request for the client, see Err().

func (*Subscription) Err

func (s *Subscription) Err() <-chan error

Err returns a channel that is closed when the client send an unsubscribe request.

Jump to

Keyboard shortcuts

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