rpc

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func (*Client) InitConnections

func (c *Client) InitConnections(nodes []*model.Node, cfg model.TransportConfig) error

InitConnections initializes a set of connections to the given nodes. It returns an error if any connection fails.

func (*Client) SendRequest

func (c *Client) SendRequest(nodeId string, request *model.Request, response *model.Response) error

SendRequest sends the command request

type Config

type Config struct {
	// ServerCA defines the set of root certificate authorities
	// that servers use if required to verify a client certificate
	// by the policy in ClientAuth.
	ServerCAs        []string `json:"server_cas"`
	ServerKey        string   `json:"server_key"`
	ServerCert       string   `json:"server_cert"`
	ServerSkipVerify bool     `json:"server_skip_verify"`

	// ClientCAs defines the set of root certificate authorities
	// that clients use when verifying server certificates.
	// If ClientCAs is nil, TLS uses the host's root CA set.
	ClientCAs        []string `json:"client_cas"`
	ClientCert       string   `json:"client_cert"`
	ClientKey        string   `json:"client_key"`
	ClientSkipVerify bool     `json:"client_skip_verify"`
	// ConnectTimeout is the maximum amount of time a dial will wait for
	// a createClient to complete, in seconds.
	ConnectTimeout uint `json:"connect_timeout"`
}

func (*Config) Validate

func (c *Config) Validate() error

type RPC

type RPC struct {
	Server
	Client
}

func NewRPC

func NewRPC(logger *slog.Logger) (*RPC, error)

func (*RPC) Decode

func (r *RPC) Decode(raw any, target any) error

type RPCHandler

type RPCHandler struct {
	CmdHandler model.CommandHandler
}

func (*RPCHandler) Handle

func (h *RPCHandler) Handle(request *model.Request, response *model.Response) error

func (*RPCHandler) Ping

func (h *RPCHandler) Ping(_ struct{}, reply *string) error

type Server

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

func (*Server) Start

func (s *Server) Start(listenAddress string, handler model.CommandHandler, serverConfig model.TransportConfig) error

Start initiates the server to begin listening on the specified address.

Jump to

Keyboard shortcuts

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