rpc

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package rpc provides a client for making remote procedure calls (RPC) to a server. It allows clients to connect to a server and invoke methods on the server using RPC. The client can be used to change the log level of the server or perform other commands. It uses the net/rpc package to handle the RPC communication and provides a simple interface for clients to interact with the server.

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
}

Client is a struct that represents an RPC client. It contains an RPC client that can be used to make remote procedure calls to a server.

func NewClient

func NewClient(addr string) (*Client, error)

NewClient creates a new RPC client with the specified address. The address is the server's address, and it defaults to the "/rpc" endpoint.

func NewClientWithPath

func NewClientWithPath(addr, path string) (*Client, error)

NewClientWithPath creates a new RPC client with the specified address and path. The address is the server's address, and the path is the RPC endpoint. If the path is empty, it defaults to "/rpc".

func (*Client) ChangeLogLevel

func (c *Client) ChangeLogLevel(ctx context.Context, level log.Level) error

ChangeLogLevel changes the log level of the server. It takes a context and a log level as parameters. The context is used to control the timeout and cancellation of the request.

func (*Client) Close

func (c *Client) Close() error

Close closes the RPC client connection. It returns an error if the connection could not be closed.

type Command

type Command uint8

Command represents the type of command that can be sent to a service. It is used to identify the action that should be performed by the service.

const (
	// Unknown Command is used when the command is not recognized.
	Unknown Command = iota
	// SetLevel Command is used to set the log level of a service.
	SetLevel
)

func (Command) String

func (c Command) String() string

String returns a string representation of the Command.

Jump to

Keyboard shortcuts

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