rpc

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 9 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 {
	GRPCClient *grpc.ClientConn
	Creds      credentials.TransportCredentials
	Endpoint   string
	// contains filtered or unexported fields
}

Client encapsulates logic for new gRPC clint

func NewClient

func NewClient(creds credentials.TransportCredentials, endpoint string, enableMetrics bool, logger *logrus.Logger) (*Client, error)

NewClient creates new Client object with hostTCP, port, creds and calls init function Receives credentials for connection, connection endpoint (for example 'tcp://localhost:8888') and logrus logger Returns an instance of Client struct or error if initClient() function failed

func (*Client) Close

func (c *Client) Close() error

Close function calls Close method in ClientConn Returns error if something went wrong

func (*Client) GetEndpoint

func (c *Client) GetEndpoint() (string, error)

GetEndpoint returns endpoint representation Returns url.Path if Scheme is unix or url.Host otherwise

func (*Client) SetLogger

func (c *Client) SetLogger(logger *logrus.Logger)

SetLogger sets logrus logger to Client struct Receives logrus logger

type ServerRunner

type ServerRunner struct {
	GRPCServer *grpc.Server

	Creds    credentials.TransportCredentials
	Endpoint string
	// contains filtered or unexported fields
}

ServerRunner encapsulates logic for creating/starting/stopping gRPC server

func NewServerRunner

func NewServerRunner(creds credentials.TransportCredentials, endpoint string, enableMetrics bool, logger *logrus.Logger) *ServerRunner

NewServerRunner returns ServerRunner object based on parameters that had provided Receives credentials for connection, connection endpoint (for example 'tcp://localhost:8888') and logrus logger Returns an instance of ServerRunner struct

func (*ServerRunner) GetEndpoint

func (sr *ServerRunner) GetEndpoint() (string, string)

GetEndpoint returns endpoint representation Returns url.Path if Scheme is unix or url.Host otherwise

func (*ServerRunner) RunServer

func (sr *ServerRunner) RunServer() error

RunServer creates Listener and starts gRPC server on endpoint Receives error if error occurred during Listener creation or during GRPCServer.Serve

func (*ServerRunner) SetLogger

func (sr *ServerRunner) SetLogger(logger *logrus.Logger)

SetLogger sets logrus logger to ServerRunner struct Receives logrus logger

func (*ServerRunner) StopServer

func (sr *ServerRunner) StopServer()

StopServer gracefully stops gRPC server and closes listener

Jump to

Keyboard shortcuts

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