multirpc

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 9 Imported by: 0

README

MultiRPC


I made this module to overcome the limitations of the builtin RPC module that I ran into while I was working on my DistributedMandelbrot project. First off I noticed that you can only have one connection open from a specific struct at any time. Trying to open more than one RPC connection at a time for multiple objects of the same struct lead to all the RPC instances to no longer reference the correct object any longer. Essentially the RPC instance now referenced a nilled object of the struct type involved.

I decided I wanted to implement the module to meet two requirements and work over the TCP and HTTP wire protocols. First I needed multiple objects of the same struct type to host their own RPC server without losing the reference to the hosting object. Secondly I also needed to have the RPC connections stay alive throughout the entire execution of the program, which could be hours or days.

I hope that you will find this module useful.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpClient

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

func NewHttpClient

func NewHttpClient(serverAddress string) HttpClient

NewHttpClient will return a new HttpClient object

func (*HttpClient) Call

func (hc *HttpClient) Call(method string, request interface{}, reply interface{}) error

Call will execute the specified method on the RPC server

func (*HttpClient) Connect

func (hc *HttpClient) Connect() error

Connect will attempt to connect this RPC client to the RPC server specified when this object was created

func (*HttpClient) Disconnect

func (hc *HttpClient) Disconnect() error

Disconnect will close the HTTP connection to the RPC Server

func (*HttpClient) LoggerName added in v0.4.0

func (hc *HttpClient) LoggerName(name string)

LoggerName exposes the logger.Name field

func (*HttpClient) LoggerVerbosity added in v0.4.0

func (hc *HttpClient) LoggerVerbosity(verbosity bslogger.Verbosity)

LoggerVerbosity exposes the logger.Verbosity field

type HttpServer

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

func NewHttpServer

func NewHttpServer(object interface{}, address string) HttpServer

NewHttpServer will return a new HttpServer object

func (*HttpServer) LoggerName added in v0.4.0

func (hs *HttpServer) LoggerName(name string)

LoggerName exposes the loggers.Name field

func (*HttpServer) LoggerVerbosity added in v0.4.0

func (hs *HttpServer) LoggerVerbosity(verbosity bslogger.Verbosity)

LoggerVerbosity exposes the logger.Verbosity field

func (*HttpServer) Run

func (hs *HttpServer) Run() error

Run will start serving the object via RPC over HTTP

func (*HttpServer) Stop

func (hs *HttpServer) Stop() error

Stop is called to shut down the server by decrementing the wait group

func (*HttpServer) Wait

func (hs *HttpServer) Wait()

Wait can be called to have the code wait for the server to shut down before continuing

type HttpServerClient

type HttpServerClient struct {
	Client HttpClient
	Server HttpServer
}

func NewHttpServerClient

func NewHttpServerClient(object interface{}, serverAddress string, clientAddress string) HttpServerClient

type TcpClient

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

func NewTcpClient

func NewTcpClient(serverAddress string) TcpClient

NewTcpClient will return a new TcpClient object

func (*TcpClient) Call

func (tc *TcpClient) Call(method string, request interface{}, reply interface{}) error

Call will execute the specified method on the RPC server

func (*TcpClient) Connect

func (tc *TcpClient) Connect() error

Connect will attempt to connect this RPC client to the RPC server specified when this object was created

func (*TcpClient) Disconnect

func (tc *TcpClient) Disconnect() error

Disconnect will close the TCP connection to the RPC Server

func (*TcpClient) LoggerName added in v0.4.0

func (tc *TcpClient) LoggerName(name string)

LoggerName exposes the logger.Name field

func (*TcpClient) LoggerVerbosity added in v0.4.0

func (tc *TcpClient) LoggerVerbosity(verbosity bslogger.Verbosity)

LoggerVerbosity exposes the logger.Verbosity field

type TcpServer

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

func NewTcpServer

func NewTcpServer(object interface{}, address string) TcpServer

NewTcpServer will return a new TcpServer object

func (*TcpServer) LoggerName added in v0.4.0

func (ts *TcpServer) LoggerName(name string)

LoggerName exposes the logger.Name field

func (*TcpServer) LoggerVerbosity added in v0.4.0

func (ts *TcpServer) LoggerVerbosity(verbosity bslogger.Verbosity)

LoggerVerbosity exposes the logger.Verbosity field

func (*TcpServer) Run

func (ts *TcpServer) Run() error

Run will start serving the object via RPC over TCP

func (*TcpServer) Stop

func (ts *TcpServer) Stop() error

Stop is called to shut down the server by decrementing the wait group

func (*TcpServer) Wait

func (ts *TcpServer) Wait()

Wait can be called to have the code wait for the server to shut down before continuing

type TcpServerClient

type TcpServerClient struct {
	Client TcpClient
	Server TcpServer
}

func NewTcpServerClient

func NewTcpServerClient(object interface{}, serverAddress string, clientAddress string) TcpServerClient

Jump to

Keyboard shortcuts

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