rpc

package
v0.0.0-...-7c2dc49 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Request

func Request(addr string, method byte, data []byte) ([]byte, error)

Request sends a request to given addr with given msg type and data.

Types

type Server

type Server interface {
	// Start starts the server.
	Start() error

	// Stop stops the server.
	Stop()

	// AddHandler adds a handler.
	AddHandler(method byte, handler func(data []byte) ([]byte, error)) Server
}

Server is the interface for the RPC Server.

func NewServerImplV1

func NewServerImplV1(port int) Server

NewServerImplV1 creates a new server.

type ServerImplV1

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

ServerImplV1 implements the Server interface.

func (*ServerImplV1) AddHandler

func (s *ServerImplV1) AddHandler(method byte, handler func(data []byte) ([]byte, error)) Server

AddHandler adds a handler.

func (*ServerImplV1) ServeHTTP

func (s *ServerImplV1) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles the api calls.

func (*ServerImplV1) Start

func (s *ServerImplV1) Start() error

Start starts the server.

func (*ServerImplV1) Stop

func (s *ServerImplV1) Stop()

Stop stops the server.

Jump to

Keyboard shortcuts

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