xhertz

package
v3.7.20 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DebugMode indicates gin mode is debug.
	DebugMode = "debug"
	// ReleaseMode indicates gin mode is release.
	ReleaseMode = "release"
	// TestMode indicates gin mode is test.
	TestMode = "test"
)
View Source
const ModName = "server.hertz"

ModName ..

Variables

This section is empty.

Functions

func CGIVariableToHTTPHeader

func CGIVariableToHTTPHeader(key string) string

CGIVariableToHTTPHeader converts a CGI variable into an HTTP header key. For example, `ABC_DEF` will be converted to `abc-def`.

func HTTPHeaderToCGIVariable

func HTTPHeaderToCGIVariable(key string) string

HTTPHeaderToCGIVariable performs an CGI variable conversion. For example, an HTTP header key `abc-def` will result in `ABC_DEF`.

Types

type Config

type Config struct {
	Host                     string
	Port                     int
	Mode                     string
	Deployment               string
	DisableMetric            bool
	DisableTrace             bool
	DisableSlowQuery         bool
	ServiceAddress           string
	SlowQueryThresholdInMill int64
}

Config HTTP config

func New

func New() *Config

New ...

func (*Config) Address

func (config *Config) Address() string

Address ...

func (*Config) Build

func (config *Config) Build() *Server

Build create server instance, then initialize it with necessary interceptor

func (*Config) WithDeployment

func (config *Config) WithDeployment(deployment string) *Config

WithDeployment ...

func (*Config) WithDisableMetric

func (config *Config) WithDisableMetric(disableMetric bool) *Config

WithDisableMetric ...

func (*Config) WithDisableSlowQuery

func (config *Config) WithDisableSlowQuery(disableSlowQuery bool) *Config

WithDisableSlowQuery ...

func (*Config) WithDisableTrace

func (config *Config) WithDisableTrace(disableTrace bool) *Config

WithDisableTrace ...

func (*Config) WithHost

func (config *Config) WithHost(host string) *Config

WithHost ...

func (*Config) WithMode added in v3.7.15

func (config *Config) WithMode(mode string) *Config

WithMode ...

func (*Config) WithPort

func (config *Config) WithPort(port int) *Config

WithPort ...

func (*Config) WithServiceAddress

func (config *Config) WithServiceAddress(serviceAddress string) *Config

WithServiceAddress ...

func (*Config) WithSlowQueryThresholdInMilli

func (config *Config) WithSlowQueryThresholdInMilli(milli int64) *Config

WithSlowQueryThresholdInMilli WithPort ...

type HTTPHeader

type HTTPHeader map[string][]string

HTTPHeader is provided to wrap an http.Header into an HTTPHeaderCarrier.

func (HTTPHeader) Set

func (h HTTPHeader) Set(key, value string)

Set sets the header entries associated with key to the single element value. The key will converted into lowercase as the HTTP/2 protocol requires.

func (HTTPHeader) Visit

func (h HTTPHeader) Visit(v func(k, v string))

Visit implements the HTTPHeaderCarrier interface.

type HTTPHeaderCarrier

type HTTPHeaderCarrier interface {
	Visit(func(k, v string))
}

HTTPHeaderCarrier accepts a visitor to access all key value pairs in an HTTP header.

type HTTPHeaderSetter

type HTTPHeaderSetter interface {
	Set(key, value string)
}

HTTPHeaderSetter sets a key with a value into a HTTP header.

type Server

type Server struct {
	*hserver.Hertz
	// contains filtered or unexported fields
}

Server ...

func (*Server) GracefulStop

func (s *Server) GracefulStop(ctx context.Context) error

GracefulStop implements server.Server interface it will stop gin server gracefully

func (*Server) Health

func (s *Server) Health() bool

Health ...

func (*Server) Info

func (s *Server) Info() *server.ServiceInfo

Info returns server info, used by governor and consumer balancer

func (*Server) Serve

func (s *Server) Serve() error

Serve implements server.Server interface.

func (*Server) Stop

func (s *Server) Stop() error

Stop implements server.Server interface it will terminate gin server immediately

Jump to

Keyboard shortcuts

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