grpc_api_server

package
v0.0.0-...-595e2a2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGrpcConfigSection string = "grpc"
View Source
const HeaderSizeKey = "gu-hsize"
View Source
const OriginType = "grpc"
View Source
const RequestContextKey = "gu-request"

Variables

This section is empty.

Functions

func AuthKey

func AuthKey(key string, directKeyName ...bool) string

func HTTPToGRPC

func HTTPToGRPC(httpCode int) codes.Code

func StatusError

func StatusError(status codes.Code) bool

func StatusWarn

func StatusWarn(status codes.Code) bool

Types

type CallContext

type CallContext = context.Context

type GrpcServerRunner

type GrpcServerRunner struct {
	*grpc.Server
}

func (*GrpcServerRunner) Shutdown

func (g *GrpcServerRunner) Shutdown(ctx context.Context) error

type Request

type Request struct {
	api_server.RequestBase
	// contains filtered or unexported fields
}

func (*Request) CheckRequestContent

func (r *Request) CheckRequestContent(smsMessage *string, skipSms *bool) error

func (*Request) ClientIp

func (r *Request) ClientIp() string

func (*Request) Close

func (r *Request) Close(successMessage ...string)

func (*Request) Context

func (r *Request) Context() context.Context

func (*Request) Error

func (r *Request) Error() error

func (*Request) FormData

func (r *Request) FormData() map[string][]string

func (*Request) FormFile

func (r *Request) FormFile() (*multipart.FileHeader, error)

func (*Request) GetAuthParameter

func (r *Request) GetAuthParameter(authMethodProtocol string, key string, directKeyName ...bool) string

func (*Request) GetParameter

func (r *Request) GetParameter(key string) (any, bool)

func (*Request) GetRequestClientIp

func (r *Request) GetRequestClientIp() string

func (*Request) GetRequestContent

func (r *Request) GetRequestContent() []byte

func (*Request) GetRequestMethod

func (r *Request) GetRequestMethod() string

func (*Request) GetRequestPath

func (r *Request) GetRequestPath() string

func (*Request) GetRequestUserAgent

func (r *Request) GetRequestUserAgent() string

func (*Request) GetResourceId

func (r *Request) GetResourceId(resourceType string) api.ResourceId

func (*Request) GetTenancyId

func (r *Request) GetTenancyId() string

func (*Request) Init

func (r *Request) Init(s *Server, ctx CallContext, fields ...logger.Fields) error

func (*Request) MessageFromRequest

func (r *Request) MessageFromRequest(builder func() interface{}) (interface{}, error)

func (*Request) Method

func (r *Request) Method() string

func (*Request) ParseAndValidate

func (r *Request) ParseAndValidate(cmd interface{}) error

func (*Request) PayloadSize

func (r *Request) PayloadSize() int

func (*Request) ResourceIds

func (r *Request) ResourceIds() api.ResourceIds

func (*Request) Response

func (r *Request) Response() api_server.Response

func (*Request) Server

func (r *Request) Server() api_server.Server

func (*Request) SetAuthParameter

func (r *Request) SetAuthParameter(authMethodProtocol string, key string, value string, directKeyName ...bool)

func (*Request) SetParameter

func (r *Request) SetParameter(key string, value any)

func (*Request) StatusCode

func (r *Request) StatusCode() codes.Code

func (*Request) StatusMessage

func (r *Request) StatusMessage() string

func (*Request) UserAgent

func (r *Request) UserAgent() string

func (*Request) Validate

func (r *Request) Validate(cmd interface{}) error

type RequestCodec

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

func (*RequestCodec) Marshal

func (c *RequestCodec) Marshal(v any) (mem.BufferSlice, error)

func (*RequestCodec) Name

func (c *RequestCodec) Name() string

func (*RequestCodec) Unmarshal

func (c *RequestCodec) Unmarshal(data mem.BufferSlice, v any) (err error)

type RequestWrapper

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

type Response

type Response struct {
	api_server.ResponseBase
}

type Server

type Server struct {
	ServerConfig
	api_server.ServerBase
	generic_error.ErrorManagerBaseHttp
	auth.WithAuthBase
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) AddEndpoint

func (s *Server) AddEndpoint(service api_server.Service, ep api_server.Endpoint, methods *[]grpc.MethodDesc)

func (*Server) Config

func (s *Server) Config() interface{}

func (*Server) ConfigPoolService

func (s *Server) ConfigPoolService() pool.PoolService

func (*Server) DynamicTables

func (s *Server) DynamicTables() api_server.DynamicTables

func (*Server) FullMethodName

func (s *Server) FullMethodName(service api_server.Service, ep api_server.Endpoint) string

func (*Server) GrpcUnaryHandler

func (s *Server) GrpcUnaryHandler(service api_server.Service, ep api_server.Endpoint) *UnaryHandler

func (*Server) Init

func (s *Server) Init(ctx app_context.Context, auth auth.Auth, tenancyManager multitenancy.Multitenancy, configPath ...string) error

func (*Server) IsMultitenancy

func (s *Server) IsMultitenancy() bool

func (*Server) ListEndpoints

func (s *Server) ListEndpoints()

func (*Server) MakeResponseError

func (s *Server) MakeResponseError(gerr generic_error.Error) (int, generic_error.Error)

func (*Server) RegisterService

func (s *Server) RegisterService(service api_server.Service) error

func (*Server) Run

func (s *Server) Run(fin background_worker.Finisher)

func (*Server) SetConfigFromPoolService

func (s *Server) SetConfigFromPoolService(service pool.PoolService, public ...bool)

func (*Server) SetPropagateAuthUser

func (s *Server) SetPropagateAuthUser(val bool)

func (*Server) SetPropagateContextId

func (s *Server) SetPropagateContextId(val bool)

func (*Server) TenancyManager

func (s *Server) TenancyManager() multitenancy.Multitenancy

func (*Server) Testing

func (s *Server) Testing() bool

type ServerConfig

type ServerConfig struct {
	api_server.ServerBaseConfig

	HOST                       string `default:"127.0.0.1" validate:"ip"`
	PORT                       uint16 `validate:"required"`
	PROTOCOL                   string `default:"tcp" validate:"omitempty,oneof=tcp udp"`
	TRUSTED_PROXIES            []string
	VERBOSE                    bool
	VERBOSE_BODY_MAX_LENGTH    int `default:"2048"`
	ALLOW_BLOCKED_TENANCY_PATH bool
	AUTH_FROM_TENANCY_DB       bool `default:"true"`
	SHADOW_TENANCY_PATH        bool

	TENANCY_ALLOWED_IP_LIST_TAG string
	TENANCY_ALLOWED_IP_LIST     bool

	REAL_IP_HEADER string `validate:"required" default:"X-Forwarded-For"`

	TENANCY_HEADER string `validate:"omitempty,hostname_rfc1123|alphanum" default:"X-Tenancy-Id"`

	TRANSPORT_CODEC_TYPE string `validate:"required,hostname_rfc1123|alphanum" default:"proto-hatn"`

	STATUS_HEADER             string `validate:"required,hostname_rfc1123|alphanum" default:"x-hatn-status"`
	ID_HEADER                 string `validate:"omitempty,hostname_rfc1123|alphanum" default:"x-hatn-id"`
	MESSAGE_TYPE_HEADER       string `validate:"required,hostname_rfc1123|alphanum" default:"x-hatn-mtype"`
	ERROR_FAMILY_HEADER       string `validate:"omitempty,hostname_rfc1123|alphanum" default:"x-hatn-efamily"`
	ERROR_DESCRIPTION_HEADER  string `default:"x-hatn-edescription"`
	ERROR_DETAILS_HEADER      string `default:"x-hatn-edetails"`
	RESOURCE_ID_HEADER_PREFIX string `default:"x-hatn-rid"`

	TLS_CERTIFICATE_FILE string
	TLS_PRIVATE_KEY_FILE string
	DISABLE_TLS          bool
}

type SizeInfo

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

type UnaryHandler

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

Jump to

Keyboard shortcuts

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