grpcserver

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package grpcserver implements the GRPCServer.

Index

Constants

View Source
const (
	// Category is the category of GRPCServer.
	Category = supervisor.CategoryTrafficGate

	// Kind is the kind of HTTPServer.
	Kind = "GRPCServer"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GRPCServer

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

GRPCServer is TrafficGate Object GRPCServer

func (*GRPCServer) Category

func (g *GRPCServer) Category() supervisor.ObjectCategory

Category returns the category of GrpcServer.

func (*GRPCServer) Close

func (g *GRPCServer) Close()

Close close GrpcServer

func (*GRPCServer) DefaultSpec

func (g *GRPCServer) DefaultSpec() interface{}

DefaultSpec returns the default Spec of GrpcServer.

func (*GRPCServer) Inherit

func (g *GRPCServer) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object, muxMapper context.MuxMapper)

Inherit inherits previous generation of GrpcServer.

func (*GRPCServer) Init

func (g *GRPCServer) Init(superSpec *supervisor.Spec, muxMapper context.MuxMapper)

Init first create GrpcServer by Spec.name

func (*GRPCServer) Kind

func (g *GRPCServer) Kind() string

Kind returns the kind of GrpcServer.

func (*GRPCServer) Status

func (g *GRPCServer) Status() *supervisor.Status

Status returns the status of GrpcServer.

type Header struct {
	Key    string   `json:"key" jsonschema:"required"`
	Values []string `json:"values,omitempty" jsonschema:"uniqueItems=true"`
	Regexp string   `json:"regexp,omitempty" jsonschema:"format=regexp"`
	// contains filtered or unexported fields
}

Header is the third level entry of router. A header entry is always under a specific path entry, that is to mean the headers entry will only be checked after a path entry matched. However, the headers entry has a higher priority than the path entry itself.

func (*Header) Validate

func (h *Header) Validate() error

Validate validates Header.

type Method

type Method struct {
	IPFilter       *ipfilter.Spec `json:"ipFilter,omitempty"`
	Method         string         `json:"method,omitempty" jsonschema:"pattern=^/"`
	MethodPrefix   string         `json:"methodPrefix,omitempty" jsonschema:"pattern=^/"`
	MethodRegexp   string         `json:"methodRegexp,omitempty" jsonschema:"format=regexp"`
	Backend        string         `json:"backend" jsonschema:"required"`
	Headers        []*Header      `json:"headers,omitempty"`
	MatchAllHeader bool           `json:"matchAllHeader,omitempty"`
}

Method is second level entry of router.

func (*Method) Validate

func (m *Method) Validate() error

Validate validates Method.

type MuxMethod

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

MuxMethod describes gRPCserver's method

type Rule

type Rule struct {
	// NOTICE: If the field is a pointer, it must have `omitempty` in tag `json`
	// when it has `omitempty` in tag `jsonschema`.
	// Otherwise it will output null value, which is invalid in json schema (the type is object).
	// the original reason is the jsonscheme(genjs) has not support multiple types.
	// Reference: https://github.com/alecthomas/jsonschema/issues/30
	// In the future if we have the scenario where we need marshal the field, but omitempty
	// in the schema, we are suppose to support multiple types on our own.
	IPFilter   *ipfilter.Spec `json:"ipFilter,omitempty"`
	Host       string         `json:"host,omitempty"`
	HostRegexp string         `json:"hostRegexp,omitempty" jsonschema:"format=regexp"`
	Methods    []*Method      `json:"methods,omitempty"`
}

Rule is first level entry of router.

type Spec

type Spec struct {
	Port           uint16 `json:"port" jsonschema:"required,minimum=1025"`
	MaxConnections uint32 `json:"maxConnections,omitempty" jsonschema:"minimum=1"`

	// MinTime see keepalive.EnforcementPolicy
	MinTime string `json:"minTimeClientSendPing,omitempty" jsonschema:"format=duration"`
	// PermitWithoutStream see keepalive.EnforcementPolicy, false by default.
	PermitWithoutStream bool `json:"permitClintSendPingWithoutStream,omitempty" jsonschema:"format=duration"`

	// MaxConnectionIdle see keepalive.ServerParameters
	MaxConnectionIdle string `json:"maxConnectionIdle,omitempty" jsonschema:"format=duration"`
	// MaxConnectionAge see keepalive.ServerParameters
	MaxConnectionAge string `json:"maxConnectionAge,omitempty" jsonschema:"format=duration"`
	// MaxConnectionAgeGrace see keepalive.ServerParameters
	MaxConnectionAgeGrace string `json:"maxConnectionAgeGrace,omitempty" jsonschema:"format=duration"`
	// Time see keepalive.ServerParameters
	Time string `json:"keepaliveTime,omitempty" jsonschema:"format=duration"`
	// Timeout see keepalive.ServerParameters
	Timeout       string         `json:"keepaliveTimeout,omitempty" jsonschema:"format=duration"`
	IPFilter      *ipfilter.Spec `json:"ipFilter,omitempty"`
	Rules         []*Rule        `json:"rules,omitempty"`
	CacheSize     uint32         `json:"cacheSize,omitempty"`
	GlobalFilter  string         `json:"globalFilter,omitempty"`
	XForwardedFor bool           `json:"xForwardedFor,omitempty"`
}

Spec describe gRPC server

type Status

type Status struct {
	Health bool      `json:"health"`
	State  stateType `json:"state"`
	Error  string    `json:"error,omitempty"`
}

Status contains all status generated by runtime, for displaying to users.

Jump to

Keyboard shortcuts

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