grpcserver

package
v0.0.0-...-5d22bd2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package grpcserver provides the implementation of a gRPC server with support for both HTTP/1.1 and HTTP/2. It handles user authentication, file transfer, and key-value storage operations through the corresponding gRPC services.

This package offers both standard and TLS-encrypted server configurations, customizable through the provided configuration structure. It supports CORS and includes JWT-based authentication interceptors for enhanced security.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCORS

func NewCORS() *cors.Cors

NewCORS configures CORS (Cross-Origin Resource Sharing) for the server.

func NewError

func NewError(err error) error

Types

type Error

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

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type GRPC

type GRPC interface {
	// SetHost sets the server's hostname.
	SetHost(h string) *GRPCServer
	// SetPort sets the server's port number.
	SetPort(p int) *GRPCServer
	// GetHost retrieves the configured host.
	GetHost() string
	// GetPort retrieves the configured port.
	GetPort() int
	// ListenAndServe starts the server without TLS.
	ListenAndServe(cfg *settings.Settings) error
	// ListenAndServeTLS starts the server with TLS.
	ListenAndServeTLS(cfg *settings.Settings) error
	// LoadTLS loads TLS certificates and returns a TLS configuration.
	LoadTLS(cfg *settings.Settings) (*tls.Config, error)
	// ListenTLS creates a TLS-enabled HTTP server.
	ListenTLS(cfg *settings.Settings) (*http.Server, error)
}

GRPC defines the contract for setting up and running a gRPC server.

type GRPCServer

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

GRPCServer implements the Interface and is responsible for managing the gRPC services.

func NewGRPCServer

func NewGRPCServer() *GRPCServer

NewGRPCServer creates a new instance of GRPCServer with default logger settings.

func SetupGRPC

func SetupGRPC(host string, port int) *GRPCServer

SetupGRPC is a helper function to configure a new GRPCServer.

func (*GRPCServer) GetHost

func (s *GRPCServer) GetHost() string

GetHost returns the host configured for the server.

func (*GRPCServer) GetPort

func (s *GRPCServer) GetPort() int

GetPort returns the port configured for the server.

func (*GRPCServer) Listen

func (s *GRPCServer) Listen(_ *settings.Settings) (*http.Server, error)

Listen configures and returns an HTTP/2-enabled server.

func (*GRPCServer) ListenAndServe

func (s *GRPCServer) ListenAndServe(cfg *settings.Settings) error

ListenAndServe starts the server without TLS encryption.

func (*GRPCServer) ListenAndServeTLS

func (s *GRPCServer) ListenAndServeTLS(cfg *settings.Settings) error

ListenAndServeTLS starts the server with TLS encryption.

func (*GRPCServer) ListenTLS

func (s *GRPCServer) ListenTLS(cfg *settings.Settings) (*http.Server, error)

ListenTLS configures and returns a TLS-enabled server.

func (*GRPCServer) LoadTLS

func (s *GRPCServer) LoadTLS(cfg *settings.Settings) (*tls.Config, error)

LoadTLS loads and returns a TLS configuration using server certificates.

func (*GRPCServer) SetHost

func (s *GRPCServer) SetHost(h string) *GRPCServer

SetHost sets the host for the server.

func (*GRPCServer) SetPort

func (s *GRPCServer) SetPort(p int) *GRPCServer

SetPort sets the port for the server.

Jump to

Keyboard shortcuts

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