grpchelpers

package
v0.0.0-...-54d5584 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateProtectedConnection

func CreateProtectedConnection(
	certType string, protectedURL string, cryptocontext *cryptutils.CryptoContext,
	certProvider CertProvider, insecureConn bool,
) (connection *grpc.ClientConn, err error)

CreateProtectedConnection creates protected GRPC connection.

func CreatePublicConnection

func CreatePublicConnection(serverURL string, cryptocontext *cryptutils.CryptoContext, insecureConn bool) (
	connection *grpc.ClientConn, err error,
)

CreatePublicConnection creates public GRPC connection.

func NewProtectedServerOptions

func NewProtectedServerOptions(cryptocontext *cryptutils.CryptoContext, certProvider CertProvider,
	certType string, insecureConn bool,
) ([]grpc.ServerOption, error)

NewProtectedServerOptions creates protected server options.

Types

type CertProvider

type CertProvider interface {
	GetCertificate(certType string, issuer []byte, serial string) (certURL, keyURL string, err error)
	SubscribeCertChanged(certType string) (<-chan *iamanager.CertInfo, error)
}

CertProvider certificate provider interface.

type GRPCConn

type GRPCConn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

GRPCConn is a wrapper for grpc connection that blocks all incoming requests for stopped connection. It is used to recover connection without canceling grpc requests.

func NewGRPCConn

func NewGRPCConn() *GRPCConn

NewGRPCConn creates new GRPCConn object.

func (*GRPCConn) Close

func (conn *GRPCConn) Close()

Close closes grpc connection and releases all spawned goroutines.

func (*GRPCConn) Invoke

func (conn *GRPCConn) Invoke(ctx context.Context, method string, args any, reply any,
	opts ...grpc.CallOption,
) error

Invoke performs a unary RPC and returns after the response is received into reply.

func (*GRPCConn) NewStream

func (conn *GRPCConn) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string,
	opts ...grpc.CallOption,
) (grpc.ClientStream, error)

NewStream begins a streaming RPC.

func (*GRPCConn) Start

func (conn *GRPCConn) Start(connection *grpc.ClientConn) error

Start starts new grpc connection.

func (*GRPCConn) Stop

func (conn *GRPCConn) Stop()

Stop stops current grpc connection.

type GRPCServer

type GRPCServer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

GRPCServer implementation restarts GRPC server on every server options update.

func NewGRPCServer

func NewGRPCServer(address string) *GRPCServer

NewGRPCServer creates a new instance of GRPCServer.

func (*GRPCServer) RegisterService

func (server *GRPCServer) RegisterService(desc *grpc.ServiceDesc, impl interface{})

RegisterService registers a new grpc service.

func (*GRPCServer) RestartServer

func (server *GRPCServer) RestartServer(options []grpc.ServerOption) error

StartServer starts the gRPC server with new options.

func (*GRPCServer) StopServer

func (server *GRPCServer) StopServer()

Stop shuts down the server.

type RegisteredService

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

RegisteredService registered service information.

Jump to

Keyboard shortcuts

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