rpc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package rpc allows higher level components to register methods that can be called by other network hosts.

Usage:

r := rpc.NewRPC()

r.RegisterMethod("hello_world", func(sender *host.Host, args [][]byte) ([]byte, error) {
	fmt.Println("Hello World")
	return nil, nil
})

r.Invoke(&host.Host{}, "hello_world", [][]byte{})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	Create() RPC
}

Factory allows to create new RPC.

func NewRPCFactory

func NewRPCFactory(methods map[string]RemoteProcedure) Factory

NewRPCFactory creates new RPC Factory.

type RPC

type RPC interface {
	// Invoke is used to actually call remote procedure.
	Invoke(sender *host.Host, method string, args [][]byte) ([]byte, error)
	// RegisterMethod allows to register new function in RPC module.
	RegisterMethod(name string, method RemoteProcedure)
}

RPC is remote procedure call module.

func NewRPC

func NewRPC() RPC

NewRPC creates new RPC module.

type RemoteProcedure

type RemoteProcedure func(sender *host.Host, args [][]byte) ([]byte, error)

RemoteProcedure is remote procedure call function.

Jump to

Keyboard shortcuts

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