gateway

package
v3.1.16 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircuitBreaker added in v3.1.16

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

CircuitBreaker 熔断器

type Config

type Config struct {
	EtcdEndpoints   []string      `yaml:"etcd_endpoints"`
	EtcdDialTimeout time.Duration `yaml:"etcd_dial_timeout"`
	RoutePrefix     string        `yaml:"route_prefix"`
	HTTPAddr        string        `yaml:"http_addr"`
}

type ConnectionPool added in v3.1.16

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

ConnectionPool 连接池管理器

func NewConnectionPool added in v3.1.16

func NewConnectionPool() *ConnectionPool

NewConnectionPool 创建连接池管理器

func (*ConnectionPool) Close added in v3.1.16

func (cp *ConnectionPool) Close()

Close 关闭所有连接池

func (*ConnectionPool) Get added in v3.1.16

func (cp *ConnectionPool) Get(serviceName string) *ServicePool

Get 获取服务连接池

func (*ConnectionPool) GetOrCreate added in v3.1.16

func (cp *ConnectionPool) GetOrCreate(app *core.Core, serviceName string) *ServicePool

GetOrCreate 获取或创建服务连接池

func (*ConnectionPool) Remove added in v3.1.16

func (cp *ConnectionPool) Remove(serviceName string)

Remove 移除服务连接池

type EtcdGateway

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

EtcdGateway etcd 网关

func NewEtcdGateway

func NewEtcdGateway(app *core.Core, conf ...*Config) (*EtcdGateway, error)

func (*EtcdGateway) Close

func (gw *EtcdGateway) Close() error

type MethodDescriptor

type MethodDescriptor struct {
	FullMethod  string
	Package     string // proto package, e.g. "v1.auth"
	Service     string // service name, e.g. "UserService"
	Method      string // method name, e.g. "PostLogin"
	NewRequest  func() proto.Message
	NewResponse func() proto.Message
}

type ReflectionProxy

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

func NewReflectionProxy

func NewReflectionProxy(app *core.Core, addr string) (*ReflectionProxy, error)

func (*ReflectionProxy) Close

func (p *ReflectionProxy) Close() error

func (*ReflectionProxy) Invoke

func (p *ReflectionProxy) Invoke(ctx context.Context, fullMethod string, jsonReq []byte) ([]byte, error)

func (*ReflectionProxy) Methods

func (p *ReflectionProxy) Methods() map[string]*MethodDescriptor

Methods 返回所有已注册的方法

type Route

type Route struct {
	ID          string            `json:"id"`
	Method      string            `json:"method"`
	Path        string            `json:"path"`
	ServiceName string            `json:"service_name"`
	GRPCMethod  string            `json:"grpc_method"`
	Description string            `json:"description"`
	Headers     map[string]string `json:"headers,omitempty"`
	Enabled     bool              `json:"enabled"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
}

type ServicePool added in v3.1.16

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

ServicePool 服务连接池(按 instanceID 管理多个实例连接)

func NewServicePool added in v3.1.16

func NewServicePool(app *core.Core, name string) *ServicePool

NewServicePool 创建服务连接池

func (*ServicePool) AddOrUpdateInstance added in v3.1.16

func (p *ServicePool) AddOrUpdateInstance(instanceID, addr string) (*ReflectionProxy, bool, error)

AddOrUpdateInstance 添加或更新一个实例连接 返回 changed=true 表示是新增或重建了 proxy

func (*ServicePool) Close added in v3.1.16

func (p *ServicePool) Close()

Close 关闭所有连接

func (*ServicePool) Get added in v3.1.16

func (p *ServicePool) Get() *ReflectionProxy

Get 获取一个可用的 proxy(round-robin + 健康检查)

func (*ServicePool) RemoveInstance added in v3.1.16

func (p *ServicePool) RemoveInstance(instanceID string)

RemoveInstance 移除一个实例连接

func (*ServicePool) Size added in v3.1.16

func (p *ServicePool) Size() int

Size 返回实例数量

Jump to

Keyboard shortcuts

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